diff --git a/playbooks/base-test/pre.yaml b/playbooks/base-test/pre.yaml index 3118e0a22e..4ac124ec07 100644 --- a/playbooks/base-test/pre.yaml +++ b/playbooks/base-test/pre.yaml @@ -1,7 +1,9 @@ - hosts: all roles: - add-build-sshkey - - prepare-workspace + - start-zuul-console + - use-cached-repos + - mirror-workspace-git-repos - role: validate-host # TODO(mordred) When we have site-local variables, these should go there zuul_traceroute_host: git.openstack.org diff --git a/roles/use-cached-repos/README.rst b/roles/use-cached-repos/README.rst new file mode 100644 index 0000000000..8ce3516ef9 --- /dev/null +++ b/roles/use-cached-repos/README.rst @@ -0,0 +1,9 @@ +Clone repos from the image cache into the workspace + +Clon any repos cached on the remote node (via the image build process) +that this job uses into the workspace. If a repo doesn't exist, clone +it from its source. + +These repos are neither up to date, nor do they contain the changes +that Zuul has prepared. A separate role should synchronize the local +and remote repos. diff --git a/roles/use-cached-repos/tasks/main.yaml b/roles/use-cached-repos/tasks/main.yaml new file mode 100644 index 0000000000..515b35ba7a --- /dev/null +++ b/roles/use-cached-repos/tasks/main.yaml @@ -0,0 +1,26 @@ +- name: Find locally cached git repos + stat: + path: "/opt/git/{{ item.name }}" + with_items: "{{ zuul.projects }}" + register: cached_repos + +- name: Clone cached repo to workspace + command: "git clone /opt/git/{{ item.0.name }} {{ ansible_user_dir }}/{{ item.0.src_dir}}" + creates: "{{ ansible_user_dir }}/{{ item.0.src_dir}}" + when: item.1.stat.exists + with_together: + - " {{ zuul.projects }}" + - " {{ cached_repos }}" + +- name: Clone upstream repo to workspace + command: "git clone https://{{ item.0.canonical_hostname }}/{{ item.0.name}} {{ ansible_user_dir }}/{{ item.0.src_dir}}" + creates: "{{ ansible_user_dir }}/{{ item.0.src_dir}}" + when: not item.1.stat.exists + with_together: + - " {{ zuul.projects }}" + - " {{ cached_repos }}" + +- name: Remove origin from local git repos + command: "git remote rm origin" + chdir: "{{ ansible_user_dir }}/{{ item.src_dir}}" + with_items: " {{ zuul.projects }}"