diff --git a/test-playbooks/container/test-build-container-image-promote.yaml b/test-playbooks/container/test-build-container-image-promote.yaml deleted file mode 100644 index fb18f7e85..000000000 --- a/test-playbooks/container/test-build-container-image-promote.yaml +++ /dev/null @@ -1,7 +0,0 @@ -- hosts: all - vars: - upload_container_image_promote: true - upload_docker_image_promote: true - tasks: - - name: Include build tasks - include_tasks: test-build-container-image-inner.yaml diff --git a/test-playbooks/container/test-build-container-image-release.yaml b/test-playbooks/container/test-build-container-image-release.yaml deleted file mode 100644 index 0da2fa44a..000000000 --- a/test-playbooks/container/test-build-container-image-release.yaml +++ /dev/null @@ -1,7 +0,0 @@ -- hosts: all - vars: - upload_container_image_promote: false - upload_docker_image_promote: false - tasks: - - name: Include build tasks - include_tasks: test-build-container-image-inner.yaml diff --git a/test-playbooks/container/test-build-container-image-inner.yaml b/test-playbooks/container/test-build-container-image.yaml similarity index 50% rename from test-playbooks/container/test-build-container-image-inner.yaml rename to test-playbooks/container/test-build-container-image.yaml index 6b0b91777..c23576f75 100644 --- a/test-playbooks/container/test-build-container-image-inner.yaml +++ b/test-playbooks/container/test-build-container-image.yaml @@ -1,5 +1,5 @@ -- name: Set image variables - set_fact: +- hosts: all + vars: _arch_docker_images: - context: test-playbooks/container/docker repository: "testrepo" @@ -24,50 +24,50 @@ repository: 127.0.0.1:5200/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']) }}" + tasks: + - name: Set docker_images variable + when: "roleset == 'docker'" + set_fact: + docker_images: "{{ multiarch | ternary(_arch_docker_images, _normal_docker_images) }}" -- name: Set docker_images variable - when: "container_command == 'docker'" - set_fact: - docker_images: "{{ multiarch | ternary(_arch_docker_images, _normal_docker_images) }}" + - name: Set container_images variable + when: "roleset == 'container'" + set_fact: + container_images: "{{ multiarch | ternary(_arch_container_images, _normal_container_images) }}" -- name: Set container_images variable - when: "container_command != 'docker'" - set_fact: - container_images: "{{ multiarch | ternary(_arch_container_images, _normal_container_images) }}" + - name: Save zuul variables + set_fact: + old_zuul: "{{ zuul }}" -- name: Save zuul variables - set_fact: - old_zuul: "{{ zuul }}" + - name: Set simulated zuul variables + set_fact: + new_zuul: + pipeline: "{{ old_zuul.pipeline }}" + 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: Set simulated zuul variables - set_fact: - new_zuul: - pipeline: "{{ old_zuul.pipeline }}" - 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-{{ roleset }}-image" + vars: + zuul: "{{ new_zuul }}" -- name: "Build a container image" - include_role: - name: "build-{{ (container_command == 'docker') | ternary('docker', 'container') }}-image" - vars: - zuul: "{{ new_zuul }}" + - name: "Upload container image" + include_role: + name: "upload-{{ roleset }}-image" + vars: + zuul: "{{ new_zuul }}" -- name: "Upload container image" - include_role: - name: "upload-{{ (container_command == 'docker') | ternary('docker', 'container') }}-image" - vars: - zuul: "{{ new_zuul }}" + - name: "Upload container image" + when: "promote" + include_role: + name: "upload-{{ roleset }}-image" + vars: + zuul: "{{ new_zuul }}" -- name: "Upload container image" - when: "upload_container_image_promote or upload_docker_image_promote" - include_role: - name: "upload-{{ (container_command == 'docker') | ternary('docker', 'container') }}-image" - vars: - zuul: "{{ new_zuul }}" - -- name: "Show local container images for debugging" - command: "{{ container_command }} image ls" + - name: "Show local container images for debugging" + command: "{{ container_command }} image ls" diff --git a/zuul-tests.d/container-roles-jobs.yaml b/zuul-tests.d/container-roles-jobs.yaml index d8acbb219..2ee769548 100644 --- a/zuul-tests.d/container-roles-jobs.yaml +++ b/zuul-tests.d/container-roles-jobs.yaml @@ -12,7 +12,6 @@ - centos-platforms - fedora-platforms - - job: name: zuul-jobs-test-ensure-docker-centos-7 description: Tests ensure-docker role on centos-7 @@ -104,95 +103,123 @@ label: ubuntu-jammy - job: - name: zuul-jobs-test-build-container-image-release + name: zuul-jobs-test-build-docker-or-container-image-base + abstract: true description: | - Test building a container image in a release pipeline. - - This job tests changes to the build-container-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. + A parent job for both docker and container image building jobs. files: - - roles/ensure-podman/.* - roles/ensure-package-repositories/.* - - roles/build-container-image/.* - - roles/upload-container-image/.* - test-playbooks/container/.* - pre-run: test-playbooks/container/test-build-container-image-pre.yaml - run: test-playbooks/container/test-build-container-image-release.yaml - vars: - container_command: podman - multiarch: false nodeset: nodes: - name: builder label: ubuntu-jammy + pre-run: test-playbooks/container/test-build-container-image-pre.yaml + run: test-playbooks/container/test-build-container-image.yaml + + +# The following jobs are focused on the "container" roles: - job: - name: zuul-jobs-test-build-container-image-promote + name: zuul-jobs-test-build-container-image-base + parent: zuul-jobs-test-build-docker-or-container-image-base + abstract: true description: | - Test building a container image in gate and promote pipelines. - - This job tests changes to the build-container-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. + A parent for container image building jobs. files: - - roles/ensure-podman/.* - - roles/ensure-skopeo/.* - - roles/ensure-package-repositories/.* - roles/build-container-image/.* - roles/upload-container-image/.* - - roles/promote-container-image/.* - - test-playbooks/container/.* - pre-run: test-playbooks/container/test-build-container-image-pre.yaml - run: test-playbooks/container/test-build-container-image-promote.yaml vars: - container_command: podman + promote: false + roleset: container multiarch: false - nodeset: - nodes: - - name: builder - label: ubuntu-jammy - job: - name: zuul-jobs-test-build-docker-image-release + name: zuul-jobs-test-build-container-image-docker-release + parent: zuul-jobs-test-build-container-image-base 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. + Test building a container image with docker in a release pipeline. + files: + - roles/ensure-docker/.* + vars: + container_command: docker + +- job: + name: zuul-jobs-test-build-container-image-podman-release + parent: zuul-jobs-test-build-container-image-base + description: | + Test building a container image with podman in a release pipeline. + files: + - roles/ensure-podman/.* + vars: + container_command: podman + +- job: + name: zuul-jobs-test-build-container-image-promote-base + parent: zuul-jobs-test-build-container-image-base + abstract: true + description: | + Test building a container image in gate and promote pipelines. + files: + - roles/ensure-skopeo/.* + - roles/promote-container-image/.* + vars: + promote: true + +- job: + name: zuul-jobs-test-build-container-image-docker-promote + parent: zuul-jobs-test-build-container-image-promote-base + description: | + Test building a container image with docker in a promote pipeline. + files: + - roles/ensure-docker/.* + vars: + container_command: docker + +- job: + name: zuul-jobs-test-build-container-image-podman-promote + parent: zuul-jobs-test-build-container-image-promote-base + description: | + Test building a container image with podman in a promote pipeline. + files: + - roles/ensure-podman/.* + vars: + container_command: podman + +# The following jobs are focused on the "docker" roles: + +- job: + name: zuul-jobs-test-build-docker-image-base + parent: zuul-jobs-test-build-docker-or-container-image-base + abstract: true + description: | + A parent for docker image building jobs. files: - roles/ensure-docker/.* - - roles/ensure-package-repositories/.* - roles/build-docker-image/.* - roles/upload-docker-image/.* - - test-playbooks/container/.* - pre-run: test-playbooks/container/test-build-container-image-pre.yaml - run: test-playbooks/container/test-build-container-image-release.yaml vars: container_command: docker multiarch: false - nodeset: - nodes: - - name: builder - label: ubuntu-jammy + promote: false + roleset: docker - job: - name: zuul-jobs-test-build-docker-image-release-multiarch - parent: zuul-jobs-test-build-docker-image-release + name: zuul-jobs-test-build-docker-image-release + parent: zuul-jobs-test-build-docker-image-base description: | Test building a docker image in a release pipeline. - This job tests changes to the build-docker-image role using buildx, - 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. +- job: + name: zuul-jobs-test-build-docker-image-release-multiarch + parent: zuul-jobs-test-build-docker-image-base + description: | + Test building a docker image in a release pipeline. vars: multiarch: true +# End container building job tests + - job: name: zuul-jobs-test-registry-docker description: | @@ -597,8 +624,10 @@ - zuul-jobs-test-ensure-docker-ubuntu-bionic - zuul-jobs-test-ensure-docker-ubuntu-focal - zuul-jobs-test-ensure-docker-ubuntu-jammy - - zuul-jobs-test-build-container-image-release - - zuul-jobs-test-build-container-image-promote + - zuul-jobs-test-build-container-image-docker-release + - zuul-jobs-test-build-container-image-podman-release + - zuul-jobs-test-build-container-image-docker-promote + - zuul-jobs-test-build-container-image-podman-promote - zuul-jobs-test-build-docker-image-release - zuul-jobs-test-build-docker-image-release-multiarch - zuul-jobs-test-registry-docker @@ -631,8 +660,10 @@ - zuul-jobs-test-ensure-docker-ubuntu-bionic - zuul-jobs-test-ensure-docker-ubuntu-focal - zuul-jobs-test-ensure-docker-ubuntu-jammy - - zuul-jobs-test-build-container-image-release - - zuul-jobs-test-build-container-image-promote + - zuul-jobs-test-build-container-image-docker-release + - zuul-jobs-test-build-container-image-podman-release + - zuul-jobs-test-build-container-image-docker-promote + - zuul-jobs-test-build-container-image-podman-promote - zuul-jobs-test-build-docker-image-release - zuul-jobs-test-build-docker-image-release-multiarch - zuul-jobs-test-registry-docker