diff --git a/.zuul.d/project-template.yaml b/.zuul.d/project-template.yaml index f18151f2bf..539cc24ee9 100644 --- a/.zuul.d/project-template.yaml +++ b/.zuul.d/project-template.yaml @@ -10,6 +10,21 @@ - job: name: requirements-check parent: unittests + description: | + Check that requirements in the target repo match OpenStack + global requirements. + + **Job Variables** + + .. zuul:jobvar:: zuul_work_dir + :default: {{ zuul.project.src_dir }} + + Directory holding the project to check. + + .. zuul:jobvar:: zuul_branch + :default: {{ zuul.branch }} + + Branch to check. # NOTE(gmann): Update the nodeset if we move testing to the new version # of ubuntu. We are explicitly setting the nodeset here because the base # job (unittests) moving to the ubuntu latest version can break this @@ -28,3 +43,15 @@ - ^doc/requirements.txt$ - playbooks/requirements-check.yaml - ^lower-constraints.txt$ + +- job: + name: requirements-check-self + description: | + Run the requirements-check job on another repo in order to + self-test changes to its job configuration. + parent: requirements-check + # This could be any project, nova is chosen arbitrarily. + required-projects: openstack/nova + vars: + zuul_work_dir: "{{ zuul.projects['opendev.org/openstack/nova'].src_dir }}" + zuul_branch: "master" diff --git a/.zuul.d/project.yaml b/.zuul.d/project.yaml index b566fa8a0d..e5d63fe636 100644 --- a/.zuul.d/project.yaml +++ b/.zuul.d/project.yaml @@ -13,6 +13,7 @@ files: - bindep.txt - openstack-tox-validate + - requirements-check-self - requirements-tox-babel - requirements-tox-bindep: voting: false @@ -79,6 +80,7 @@ files: - bindep.txt - openstack-tox-validate + - requirements-check-self - requirements-tox-babel - requirements-tox-py39-check-uc - requirements-tox-py310-check-uc diff --git a/playbooks/requirements-check.yaml b/playbooks/requirements-check.yaml index e12491b816..d4fd2b06a9 100644 --- a/playbooks/requirements-check.yaml +++ b/playbooks/requirements-check.yaml @@ -1,16 +1,4 @@ - hosts: all - pre_tasks: - - name: Ensure pip - include_role: - name: ensure-pip - - tasks: - - name: Install openstack_requirements - command: "pip3 install --user {{ zuul.projects['opendev.org/openstack/requirements'].src_dir }}" - - - name: Run requirements check script - # Use command module here instead of script since Zuul gets output - # with command into job-output.txt file. - # Command expects the file to be at the remote system - the system - # running the tests. Ask zuul variables for the path. - command: "{{ zuul.projects['opendev.org/openstack/requirements'].src_dir }}/playbooks/files/project-requirements-change.py {{ zuul.project.src_dir }} {{ zuul.branch }}" + roles: + - ensure-pip + - check-requirements diff --git a/roles/check-requirements/README.rst b/roles/check-requirements/README.rst new file mode 100644 index 0000000000..985532a692 --- /dev/null +++ b/roles/check-requirements/README.rst @@ -0,0 +1,13 @@ +Check that a project's requirements match the global requirements repo. + +**Role Variables** + +.. zuul:rolevar:: zuul_work_dir + :default: {{ zuul.project.src_dir }} + + Directory holding the project to check. + +.. zuul:rolevar:: zuul_branch + :default: {{ zuul.branch }} + + Branch to check. diff --git a/roles/check-requirements/defaults/main.yaml b/roles/check-requirements/defaults/main.yaml new file mode 100644 index 0000000000..3657c3e3e4 --- /dev/null +++ b/roles/check-requirements/defaults/main.yaml @@ -0,0 +1,2 @@ +zuul_work_dir: "{{ zuul.project.src_dir }}" +zuul_branch: "{{ zuul.branch }}" diff --git a/roles/check-requirements/tasks/main.yaml b/roles/check-requirements/tasks/main.yaml new file mode 100644 index 0000000000..b973902c60 --- /dev/null +++ b/roles/check-requirements/tasks/main.yaml @@ -0,0 +1,9 @@ +- name: Install openstack_requirements + command: "pip3 install --user {{ zuul.projects['opendev.org/openstack/requirements'].src_dir }}" + +- name: Run requirements check script + # Use command module here instead of script since Zuul gets output + # with command into job-output.txt file. + # Command expects the file to be at the remote system - the system + # running the tests. Ask zuul variables for the path. + command: "{{ zuul.projects['opendev.org/openstack/requirements'].src_dir }}/playbooks/files/project-requirements-change.py {{ zuul_work_dir }} {{ zuul_branch }}"