diff --git a/.github/workflows/test-containers-build.yml b/.github/workflows/test-containers-build.yml index 87aa5a4b..e5ebb128 100644 --- a/.github/workflows/test-containers-build.yml +++ b/.github/workflows/test-containers-build.yml @@ -60,6 +60,8 @@ jobs: - should-build-test-containers if: needs.should-build-test-containers.outputs.build-image == 'true' || contains(github.event.pull_request.labels.*.name, 'rebuild-test-container') + env: + FACT_QA_TAG: ${{ needs.determine-qa-tag.outputs.qa-tag }} steps: - uses: actions/checkout@v7 @@ -77,9 +79,48 @@ jobs: username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }} password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }} + - name: Check images already exist + id: images-exist + run: | + manifest_exists() { + local image=$1 output + if output=$(docker manifest inspect "${image}" 2>&1); then + return 0 + elif echo "${output}" | grep -Eiq 'no such manifest:|manifest unknown'; then + return 1 + else + printf '%s: %s\n' "${image}" "${output}" >&2 + return 2 + fi + } + + image_names=$(make --no-print-directory -s \ + -C "${GITHUB_WORKSPACE}/tests/containers" image-names) || exit $? + + EXIST=true + while IFS= read -r image_name; do + [[ -z "${image_name}" ]] && continue + if manifest_exists "${image_name}"; then + continue + else + status=$? + fi + + if [[ "${status}" -eq 1 ]]; then + EXIST=false + else + exit "${status}" + fi + done <<< "${image_names}" + + if [[ "${EXIST}" == false ]]; then + echo "::notice::At least one test container manifest is absent" + fi + echo "exist=${EXIST}" >> "${GITHUB_OUTPUT}" + - name: Build and Push containers + if: steps.images-exist.outputs.exist == 'false' || contains(github.event.pull_request.labels.*.name, 'rebuild-test-container') env: - FACT_QA_TAG: ${{ needs.determine-qa-tag.outputs.qa-tag }} PLATFORM: linux/amd64,linux/arm64 run: | make -C "${GITHUB_WORKSPACE}/tests/containers" build-and-push diff --git a/tests/containers/Makefile b/tests/containers/Makefile index 4eb28d59..3998bc20 100644 --- a/tests/containers/Makefile +++ b/tests/containers/Makefile @@ -1,6 +1,6 @@ include constants.mk -TARGETS := build build-and-push +TARGETS := build build-and-push image-names DIRS := $(wildcard ./*/) $(TARGETS): $(DIRS) diff --git a/tests/containers/base/Makefile b/tests/containers/base/Makefile index f29828ed..9065f26a 100644 --- a/tests/containers/base/Makefile +++ b/tests/containers/base/Makefile @@ -16,4 +16,7 @@ build: run build-and-push: BUILD_ARGS = --push build-and-push: run -.PHONY: build build-and-push all run +image-names: + @echo quay.io/rhacs-eng/qa-multi-arch:$(FACT_QA_BASE_TAG) + +.PHONY: build build-and-push all run image-names diff --git a/tests/containers/editors/Makefile b/tests/containers/editors/Makefile index df1f655e..384d30d6 100644 --- a/tests/containers/editors/Makefile +++ b/tests/containers/editors/Makefile @@ -16,4 +16,7 @@ build: run build-and-push: BUILD_ARGS = --push build-and-push: run -.PHONY: build build-and-push all run +image-names: + @echo quay.io/rhacs-eng/qa-multi-arch:$(FACT_QA_EDITORS_TAG) + +.PHONY: build build-and-push all run image-names diff --git a/tests/containers/self-deleter/Makefile b/tests/containers/self-deleter/Makefile index 74ed5009..0a0fd6c7 100644 --- a/tests/containers/self-deleter/Makefile +++ b/tests/containers/self-deleter/Makefile @@ -16,4 +16,7 @@ build: run build-and-push: BUILD_ARGS = --push build-and-push: run -.PHONY: build build-and-push all run +image-names: + @echo quay.io/rhacs-eng/qa-multi-arch:$(FACT_QA_SELF_DELETER_TAG) + +.PHONY: build build-and-push all run image-names