zuul-jobs/test-playbooks/base-roles/prepare-workspace-git.yaml
Lukas Kranz 5eca8feda9 prepare-workspace-git: Add ability to define synced pojects
The prepare_workspace_sync_required_projects_only variable allows
users to define which projects to sync to the node. This can prevent
syncing of unnecessary repositories. For some builds e.g. the
depends-on repositories dont need to be synced. The projects are
filtered based on the 'required' flag present in each zuul.project
entry and the required projects list also does not contain projects
which are present due to Depends-On or gate queue sequencing.
Having unnecessary repos in the workspace can for example also break
the analysis phase of bazel.

Change-Id: I3cc36cbfc60c81956caf5137da63973aeade4e21
Co-Authored-By: James E. Blair <jim@acmegating.com>
Co-Authored-By: Bernhard Berg <bernhard.berg@bearingpoint.com>
2024-02-28 10:56:48 -08:00

38 lines
1.3 KiB
YAML

- name: Test the prepare-workspace-git role
hosts: all
pre_tasks:
- name: Delete remote source directory to start with clean state
file:
state: absent
path: "{{ ansible_user_dir }}/{{ item.value.src_dir }}"
with_dict: "{{ zuul.projects }}"
roles:
- role: prepare-workspace-git
post_tasks:
# opendev/base-jobs is in 'required-projects'.
# Also check that the project being tested is being prepared.
# We're checking them explicitly rather than with_items on zuul.projects
# in case there is a regression which would take an item out.
- name: Check that opendev/base-jobs was prepared
stat:
path: "{{ ansible_user_dir }}/src/opendev.org/opendev/base-jobs"
register: base_jobs
- name: Check that zuul/project-config was prepared
stat:
path: "{{ ansible_user_dir }}/src/opendev.org/zuul/project-config"
register: project_config
- name: Check this project was prepared
stat:
path: "{{ ansible_user_dir }}/src/{{ zuul.project.canonical_name }}"
register: self_config
- name: Validate that required projects have been prepared
assert:
that:
- base_jobs.stat.exists
- project_config.stat.exists
- self_config.stat.exists