Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some more validations #2309

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions roles/reproducer/tasks/validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,58 @@
cifmw_network_dnsmasq_config is set and not empty. This feature is NOT
supported anymore. Please contact the CI Framework team to check your
configuration, and see if you really need to pass anything to dnsmasq.

- name: Verify cifmw_arch_automation_file is undefined
ansible.builtin.assert:
quiet: true
that:
- cifmw_arch_automation_file is undefined
msg: >-
cifmw_arch_automation_file is defined. This parameter is NOT supported
anymore. You can use cifmw_architecture_automation_file instead, providing
the absolute path to the automation file. Note that you shouldn't need to
set it at all.

# Ensure we don't mix upstream and midstream content
- name: Ensure we're consuming consistent project sources
when:
- cifmw_reproducer_validate_project_sources | default(true) | bool
vars:
_custom_rep_dict: >-
{{
cifmw_reproducer_repositories |
items2dict(key_name='dest', value_name='src')
}}
# Don't consider local paths, only remotes.
# This should prevent failing whenver we sync local repositories
# while developping with the Framework.
_projects_src: >-
{{
cifmw_reproducer_default_repositories |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we worry about default values for this var here? IIRC it defaults to upstream

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to extend the whole thing. For now, it doesn't check the value, but only the consistency. It's weak, to be fair, and we probably want/need something better here, to ensure we're in the right context.

I don't know if we could get anything from within zuul env showing "where" we run, and create some "validation map" stating something like this:

cifmw_src_base_validation:
  upstream:
    src_base: https://github.com/openstack-k8s-operators
    branch: main
  downstream_trunk:
    src_base: /home/zuul/src/....
    branch: trunk  # whatever it should be
  downstream_18_proposed:
    src_base: https://github.com/openstack-k8s-operators.
    branch: 18.0-proposed  # whatever it should be

That would really consolidate the whole thing. Any thoughts? Of course, it must be extensible in an easy way, to be future proof (new branch, new entry in the mapping).

items2dict(key_name='dest', value_name='src') |
combine(_custom_rep_dict) |
dict2items |
map(attribute='value') |
select('match', '^http')
}}
_src_name: >-
{{
_projects_src | map('dirname') | unique
}}
block:
- name: Debug found sources
ansible.builtin.debug:
var: _projects_src

- name: Debug _src_name
ansible.builtin.debug:
var: _src_name

- name: Assert everything comes from the same source
ansible.builtin.assert:
that:
- _src_name | length == 1

- name: End play
ansible.builtin.fail:
msg: on-demand