Zuul v3: Add use-cached-repos role
This adds a role to clone the cached repos into the workspace, and alters base-test to use it as well as follow-up roles to synchronize their states and start zuul_console, instead of the default prepare-workspace role which uses rsync and is less efficient. Change-Id: Ifb0fedf1df1d50444ecb1f3fb03f21b112c9dad9 Depends-On: Ib50ddff0198411e7cd5857d5bfbb915f02baadf1
This commit is contained in:
parent
2d813488cf
commit
0d94dbf838
@ -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
|
||||
|
9
roles/use-cached-repos/README.rst
Normal file
9
roles/use-cached-repos/README.rst
Normal file
@ -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.
|
26
roles/use-cached-repos/tasks/main.yaml
Normal file
26
roles/use-cached-repos/tasks/main.yaml
Normal file
@ -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 }}"
|
Loading…
Reference in New Issue
Block a user