Add test-build-container-image-release job

Add a job that tests the build-container-image role as it would be
used in a tag-based release pipeline (as opposed to check or
gate+promote).

Also, correct an issue in the role where we assumed zuul.change
existed.

Change-Id: If2566764a52726ce45fff9b5e96ce9a42d513d8d
This commit is contained in:
James E. Blair 2020-06-11 13:59:43 -07:00
parent bf43f5bb8c
commit c713ed7a55
5 changed files with 61 additions and 1 deletions

View File

@ -22,7 +22,9 @@
{% for label in zj_image.labels | default([]) -%}
--label "{{ label }}"
{% endfor %}
--label "org.zuul-ci.change={{ zuul.change }}"
{% if zuul.change | default(false) -%}
--label "org.zuul-ci.change={{ zuul.change }}"
{% endif -%}
--label "org.zuul-ci.change_url={{ zuul.change_url }}"
args:
chdir: "{{ zuul_work_dir }}/{{ zj_image.context }}"

View File

@ -0,0 +1,3 @@
FROM docker.io/library/debian:testing
RUN touch "/test-nonce"
CMD echo "Zuul container test"; sleep infinity

View File

@ -0,0 +1,5 @@
- hosts: all
tasks:
- name: Install container system
include_role:
name: "ensure-{{ container_command }}"

View File

@ -0,0 +1,25 @@
- hosts: all
tasks:
- name: Save zuul variables
set_fact:
old_zuul: "{{ zuul }}"
- name: Set simulated zuul variables
set_fact:
new_zuul:
change_url: "{{ old_zuul.change_url }}"
executor: "{{ old_zuul.executor }}"
newrev: c12f3fe1defe8b61d59061363c9c04fb520dae18
project: "{{ old_zuul.project }}"
ref: refs/tags/3.19.0
tag: 3.19.0
- name: "Build a container image"
include_role:
name: "build-{{ (container_command == 'docker') | ternary('docker', 'container') }}-image"
vars:
docker_images:
- context: test-playbooks/container/docker
repository: "testrepo"
# This is what the Zuul repo uses to tag its releases:
tags: "{{ zuul.tag is defined | ternary([zuul.get('tag', '').split('.')[0], '.'.join(zuul.get('tag', '').split('.')[:2]), zuul.get('tag', '')], ['latest']) }}"
container_images: "{{ docker_images }}"
zuul: "{{ new_zuul }}"

View File

@ -62,6 +62,30 @@
- name: ubuntu-xenial
label: ubuntu-xenial
- job:
name: zuul-jobs-test-build-docker-image-release
description: |
Test building a docker image in a release pipeline.
This job tests changes to the build-docker-image role,
simulating its use within a tag-based release pipeline. It is
not meant to be used directly but rather run on changes to roles
in the zuul-jobs repo.
files:
- roles/ensure-docker/.*
- roles/ensure-package-repositories/.*
- roles/build-docker-image/.*
- test-playbooks/container/.*
pre-run: test-playbooks/container/test-build-container-image-release-pre.yaml
run: test-playbooks/container/test-build-container-image-release.yaml
vars:
container_command: docker
multiarch: false
nodeset:
nodes:
- name: builder
label: ubuntu-bionic
- job:
name: zuul-jobs-test-registry-docker
description: |
@ -353,6 +377,7 @@
- zuul-jobs-test-ensure-docker-fedora-31
- zuul-jobs-test-ensure-docker-ubuntu-bionic
- zuul-jobs-test-ensure-docker-ubuntu-xenial
- zuul-jobs-test-build-docker-image-release
- zuul-jobs-test-registry-docker
- zuul-jobs-test-registry-docker-multiarch
- zuul-jobs-test-registry-podman