build-docker-image: fix up siblings copy
There are a number of issues with this. Firstly, it needs to copy the parent directories to make a heirarchy in the .zuul-siblings directory. The current "cp -r" was only copying the final directory. Switch into the source directory and use "--parent" to do this. Also, it should be copying into the context dir. Add the {{ item.context }} to the path where appropriate. Also print out ZUUL_SIBLINGS in the Dockerfile so we can see it being set. Expand the testing to make a directory heirarchy, and test the copy with asserts. Change-Id: I9f3b0a1f71d20cf7511f224648dd2fa51a039015
This commit is contained in:
parent
0b0cb18a60
commit
4242524a6b
|
@ -1,6 +1,6 @@
|
|||
- name: Check sibling directory
|
||||
stat:
|
||||
path: '{{ zuul_work_dir }}/.zuul-siblings'
|
||||
path: '{{ zuul_work_dir }}/{{ item.context }}/.zuul-siblings'
|
||||
register: _dot_zuul_siblings
|
||||
|
||||
# This should have been cleaned up; multiple builds may specify
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
- name: Create sibling source directory
|
||||
file:
|
||||
path: '{{ zuul_work_dir }}/.zuul-siblings'
|
||||
path: '{{ zuul_work_dir }}/{{ item.context }}/.zuul-siblings'
|
||||
state: directory
|
||||
mode: 0755
|
||||
when: item.siblings is defined
|
||||
|
@ -19,7 +19,9 @@
|
|||
# NOTE(ianw): could use recursive copy: with remote_src, but it's
|
||||
# Ansible 2.8 only. take the simple approach.
|
||||
- name: Copy sibling source directories
|
||||
command: 'cp -r ~/src/{{ sibling }} {{ zuul_work_dir }}/.zuul-siblings/'
|
||||
command:
|
||||
cmd: 'cp --parents -r {{ sibling }} /home/zuul/{{ zuul_work_dir }}/{{ item.context }}/.zuul-siblings'
|
||||
chdir: '~/src'
|
||||
loop: '{{ item.siblings }}'
|
||||
loop_control:
|
||||
loop_var: sibling
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
FROM debian:testing
|
||||
ARG ZUUL_SIBLINGS=""
|
||||
CMD echo "Zuul siblings: ${ZUUL_SIBLINGS}"
|
||||
CMD echo "Zuul container test"; sleep infinity
|
||||
|
|
|
@ -126,10 +126,10 @@
|
|||
|
||||
- name: Create fake sibling projects
|
||||
command: >-
|
||||
mkdir -p src/opendev.org/fake-sibling-1 &&
|
||||
mkdir -p src/opendev.org/fake-sibling-2 &&
|
||||
touch src/opendev.org/fake-sibling-1/file &&
|
||||
touch src/opendev.org/fake-sibling-2/file
|
||||
mkdir -p src/opendev.org/project/fake-sibling &&
|
||||
mkdir -p src/openstack.org/project/fake-sibling &&
|
||||
touch src/opendev.org/project/fake-sibling/file &&
|
||||
touch src/openstack.org/project/fake-sibling/file
|
||||
|
||||
- name: Build docker image
|
||||
include_role:
|
||||
|
@ -139,8 +139,23 @@
|
|||
- context: test-playbooks/registry/docker
|
||||
repository: downstream/image
|
||||
siblings:
|
||||
- opendev.org/fake-sibling-1
|
||||
- opendev.org/fake-sibling-2
|
||||
- opendev.org/project/fake-sibling
|
||||
- openstack.org/project/fake-sibling
|
||||
|
||||
- name: Check sibling copy 1 worked
|
||||
stat:
|
||||
path: test-playbooks/registry/docker/.zuul-siblings/opendev.org/project/fake-sibling/file
|
||||
register: _sibling_copy_1
|
||||
|
||||
- name: Check sibling copy 2 worked
|
||||
stat:
|
||||
path: test-playbooks/registry/docker/.zuul-siblings/openstack.org/project/fake-sibling/file
|
||||
register: _sibling_copy_2
|
||||
|
||||
- name: Assert copy worked
|
||||
assert:
|
||||
that: _sibling_copy_1.stat.exists and _sibling_copy_2.stat.exists
|
||||
|
||||
|
||||
- hosts: executor
|
||||
name: Test pushing to the intermediate registry
|
||||
|
|
Loading…
Reference in New Issue