From 2551e0f1bd6bf1a517fd3bb6dba56fc2283b173d Mon Sep 17 00:00:00 2001 From: Giles Hutton Date: Wed, 16 Aug 2023 11:49:57 +0100 Subject: [PATCH] Automates integration test container builds --- .../workflows/integration-test-containers.yml | 86 +++++++++++++++++++ .../container/Makefile-constants.mk | 2 + .../container/benchmark/Makefile | 21 +++-- .../container/containerstats/Makefile | 16 +++- .../container/jsonlabel/Makefile | 16 +++- integration-tests/container/perf/Makefile | 52 +++++++++-- .../processes-listening-on-ports/Makefile | 16 +++- .../container/schedule-curls/Makefile | 16 +++- 8 files changed, 201 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/integration-test-containers.yml create mode 100644 integration-tests/container/Makefile-constants.mk diff --git a/.github/workflows/integration-test-containers.yml b/.github/workflows/integration-test-containers.yml new file mode 100644 index 00000000000..7a252c73787 --- /dev/null +++ b/.github/workflows/integration-test-containers.yml @@ -0,0 +1,86 @@ +on: + push: + pull_request: + +jobs: + test-containers: + runs-on: ubuntu-latest + outputs: + changed: ${{ steps.filter.outputs.container }} + changed_files: ${{ steps.filter.outputs.container_files }} + steps: + - uses: actions/checkout@v3 + + - uses: dorny/paths-filter@v2 + id: filter + with: + list-files: shell + filters: | + container: + - integration-tests/container/** + + + rebuild-containers: + needs: test-containers + if: ${{ needs.test-containers.outputs.changed == 'true' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + arch: [amd64, ppc64le, s390x] + + steps: + - uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Get changed containers + run: | + dirs=$(dirname ${{ needs.test-containers.outputs.changed_files }} | sort | uniq ) + + echo "CONTAINER_DIRS=$dirs" >> "$GITHUB_ENV" + + - name: Build containers + run: | + for dir in $CONTAINER_DIRS; do + make -C "integration-tests/container/$dir" build + done + env: + PLATFORM: linux/${{ matrix.arch }} + IMAGE_SUFFIX: ${{ matrix.arch }} + + - name: Push containers + if: github.event_name == 'push' + run: | + for dir in $CONTAINER_DIRS; do + make -C "integration-tests/container/$dir" push + done + env: + PLATFORM: linux/${{ matrix.arch }} + IMAGE_SUFFIX: ${{ matrix.arch }} + + push-manifest: + runs-on: ubuntu-latest + needs: + - rebuild-containers + - test-containers + if: needs.test-containers.outputs.changed == 'true' && github.event_name == 'push' + steps: + - uses: actions/checkout@v3 + + - name: Get changed containers + run: | + dirs=$(dirname ${{ needs.test-containers.outputs.changed_files }} | sort | uniq ) + + echo "CONTAINER_DIRS=$dirs" >> "$GITHUB_ENV" + + - name: Make manifests + run: | + for dir in $CONTAINER_DIRS; do + make -C "integration-tests/container/$dir" manifest + done + diff --git a/integration-tests/container/Makefile-constants.mk b/integration-tests/container/Makefile-constants.mk new file mode 100644 index 00000000000..97494b91fe9 --- /dev/null +++ b/integration-tests/container/Makefile-constants.mk @@ -0,0 +1,2 @@ +PLATFORM ?= linux/amd64 +IMAGE_SUFFIX ?= diff --git a/integration-tests/container/benchmark/Makefile b/integration-tests/container/benchmark/Makefile index f0a6be3982b..2841ea2b483 100644 --- a/integration-tests/container/benchmark/Makefile +++ b/integration-tests/container/benchmark/Makefile @@ -1,20 +1,29 @@ +BASE_PATH = . +include ../Makefile-constants.mk + DEFAULT_GOAL = all COLLECTOR_QA_BENCHMARK_TAG := phoronix ifneq ($(COLLECTOR_QA_TAG),) -COLLECTOR_QA_BENCHMARK_TAG=phoronix-$(COLLECTOR_QA_TAG) +COLLECTOR_QA_BENCHMARK_TAG=phoronix-$(COLLECTOR_QA_TAG)$(IMAGE_SUFFIX) endif -PLATFORM ?= linux/amd64 - - .PHONY: all all: @docker buildx build --load --platform ${PLATFORM} \ - -t quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BENCHMARK_TAG) . + -t quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BENCHMARK_TAG)$(IMAGE_SUFFIX) . .PHONY: push push: @docker buildx build --push --platform ${PLATFORM} \ - -t quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BENCHMARK_TAG) . + -t quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BENCHMARK_TAG)$(IMAGE_SUFFIX) . + +.PHONY: manifest +manifest: + @docker manifest create quay.io/rhacs-eng/collector:performance:$(COLLECTOR_QA_BENCHMARK_TAG) \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BENCHMARK_TAG)-amd64 \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BENCHMARK_TAG)-s390x \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BENCHMARK_TAG)-ppc64le + + @docker manifest push quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BENCHMARK_TAG) diff --git a/integration-tests/container/containerstats/Makefile b/integration-tests/container/containerstats/Makefile index dd3bba38e1d..bb13d32a0b5 100644 --- a/integration-tests/container/containerstats/Makefile +++ b/integration-tests/container/containerstats/Makefile @@ -1,13 +1,14 @@ +BASE_PATH = . +include ../Makefile-constants.mk + .DEFAULT_GOAL = all COLLECTOR_QA_STATS_TAG := stats ifneq ($(COLLECTOR_QA_TAG),) -COLLECTOR_QA_STATS_TAG=stats-$(COLLECTOR_QA_TAG) +COLLECTOR_QA_STATS_TAG=stats-$(COLLECTOR_QA_TAG)$(IMAGE_SUFFIX) endif -PLATFORM ?= linux/amd64 - .PHONY: all all: @docker buildx build --load --platform ${PLATFORM} \ @@ -17,3 +18,12 @@ all: push: @docker buildx build --push --platform ${PLATFORM} \ -t quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_STATS_TAG) . + +.PHONY: manifest +manifest: + @docker manifest create quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_STATS_TAG) \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_STATS_TAG)-amd64 \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_STATS_TAG)-s390x \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_STATS_TAG)-ppc64le + + @docker manifest push quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_STATS_TAG) diff --git a/integration-tests/container/jsonlabel/Makefile b/integration-tests/container/jsonlabel/Makefile index beefd373ff2..426219da372 100644 --- a/integration-tests/container/jsonlabel/Makefile +++ b/integration-tests/container/jsonlabel/Makefile @@ -1,13 +1,14 @@ +BASE_PATH = . +include ../Makefile-constants.mk + .DEFAULT_GOAL = all COLLECTOR_QA_JSON_LABEL_TAG := json-label ifneq ($(COLLECTOR_QA_TAG),) -COLLECTOR_QA_JSON_LABEL_TAG=json-label-$(COLLECTOR_QA_TAG) +COLLECTOR_QA_JSON_LABEL_TAG=json-label-$(COLLECTOR_QA_TAG)$(IMAGE_SUFFIX) endif -PLATFORM ?= linux/amd64 - .PHONY: all all: @docker buildx build --load --platform ${PLATFORM} \ @@ -17,3 +18,12 @@ all: push: @docker buildx build --push --platform ${PLATFORM} \ -t quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_JSON_LABEL_TAG) . + +.PHONY: manifest +manifest: + @docker manifest create quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_JSON_LABEL_TAG) \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_JSON_LABEL_TAG)-amd64 \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_JSON_LABEL_TAG)-s390x \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_JSON_LABEL_TAG)-ppc64le + + @docker manifest push quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_JSON_LABEL_TAG) diff --git a/integration-tests/container/perf/Makefile b/integration-tests/container/perf/Makefile index 25f55794791..4c2decfd5f9 100644 --- a/integration-tests/container/perf/Makefile +++ b/integration-tests/container/perf/Makefile @@ -1,3 +1,6 @@ +BASE_PATH = . +include ../Makefile-constants.mk + .DEFAULT_GOAL = all COLLECTOR_QA_INIT_TAG := init @@ -6,14 +9,12 @@ COLLECTOR_QA_BCC_TAG := bcc COLLECTOR_QA_BPFTRACE_TAG := bpftrace ifneq ($(COLLECTOR_QA_TAG),) -COLLECTOR_QA_INIT_TAG=init-$(COLLECTOR_QA_TAG) -COLLECTOR_QA_PERF_TAG=perf-$(COLLECTOR_QA_TAG) -COLLECTOR_QA_BCC_TAG=bcc-$(COLLECTOR_QA_TAG) -COLLECTOR_QA_BPFTRACE_TAG=bpftrace-$(COLLECTOR_QA_TAG) +COLLECTOR_QA_INIT_TAG=init-$(COLLECTOR_QA_TAG)$(IMAGE_SUFFIX) +COLLECTOR_QA_PERF_TAG=perf-$(COLLECTOR_QA_TAG)$(IMAGE_SUFFIX) +COLLECTOR_QA_BCC_TAG=bcc-$(COLLECTOR_QA_TAG)$(IMAGE_SUFFIX) +COLLECTOR_QA_BPFTRACE_TAG=bpftrace-$(COLLECTOR_QA_TAG)$(IMAGE_SUFFIX) endif -PLATFORM ?= linux/amd64 - .PHONY: all all: @docker buildx build --load --platform ${PLATFORM} \ @@ -35,3 +36,42 @@ push: -t quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BCC_TAG) --target bcc -f Dockerfile . @docker buildx build --push --platform ${PLATFORM} \ -t quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BPFTRACE_TAG) -f Dockerfile.bpftrace . + +.PHONY: manifest +manifest: manifest-bcc manifest-bpftrace manifest-perf manifest-init + +.PHONY: manifest-bcc +manifest-bcc: + @docker manifest create quay.io/rhacs-eng/collector:performance:$(COLLECTOR_QA_BCC_TAG) \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BCC_TAG)-amd64 \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BCC_TAG)-s390x \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BCC_TAG)-ppc64le + + @docker manifest push quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BCC_TAG) + +.PHONY: manifest-perf +manifest-perf: + @docker manifest create quay.io/rhacs-eng/collector:performance:$(COLLECTOR_QA_PERF_TAG) \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_PERF_TAG)-amd64 \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_PERF_TAG)-s390x \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_PERF_TAG)-ppc64le + + @docker manifest push quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_PERF_TAG) + +.PHONY: manifest-init +manifest-init: + @docker manifest create quay.io/rhacs-eng/collector:performance:$(COLLECTOR_QA_INIT_TAG) \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_INIT_TAG)-amd64 \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_INIT_TAG)-s390x \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_INIT_TAG)-ppc64le + + @docker manifest push quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_INIT_TAG) + +.PHONY: manifest-bpftrace +manifest-bpftrace: + @docker manifest create quay.io/rhacs-eng/collector:performance:$(COLLECTOR_QA_BPFTRACE_TAG) \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BPFTRACE_TAG)-amd64 \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BPFTRACE_TAG)-s390x \ + quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BPFTRACE_TAG)-ppc64le + + @docker manifest push quay.io/rhacs-eng/collector-performance:$(COLLECTOR_QA_BPFTRACE_TAG) diff --git a/integration-tests/container/processes-listening-on-ports/Makefile b/integration-tests/container/processes-listening-on-ports/Makefile index 368da7b7a42..d8e75a5569f 100644 --- a/integration-tests/container/processes-listening-on-ports/Makefile +++ b/integration-tests/container/processes-listening-on-ports/Makefile @@ -1,13 +1,14 @@ +BASE_PAT = . +include ../Makefile-constants.mk + .DEFAULT_GOAL = all COLLECTOR_QA_PROCESSES_LISTENING_ON_PORTS_TAG := collector-processes-listening-on-ports ifneq ($(COLLECTOR_QA_TAG),) -COLLECTOR_QA_PROCESSES_LISTENING_ON_PORTS_TAG=collector-processes-listening-on-ports-$(COLLECTOR_QA_TAG) +COLLECTOR_QA_PROCESSES_LISTENING_ON_PORTS_TAG=collector-processes-listening-on-ports-$(COLLECTOR_QA_TAG)$(IMAGE_SUFFIX) endif -PLATFORM ?= linux/amd64 - .PHONY: all all: @docker buildx build --load --platform ${PLATFORM} \ @@ -17,3 +18,12 @@ all: push: @docker buildx build --push --platform ${PLATFORM} \ -t quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_PROCESSES_LISTENING_ON_PORTS_TAG) . + +.PHONY: manifest +manifest: + @docker manifest create quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_PROCESSES_LISTENING_ON_PORTS_TAG) \ + quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_PROCESSES_LISTENING_ON_PORTS_TAG)-amd64 \ + quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_PROCESSES_LISTENING_ON_PORTS_TAG)-s390x \ + quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_PROCESSES_LISTENING_ON_PORTS_TAG)-ppc64le + + @docker manifest push quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_PROCESSES_LISTENING_ON_PORTS_TAG) diff --git a/integration-tests/container/schedule-curls/Makefile b/integration-tests/container/schedule-curls/Makefile index 42f8fd70067..ccf479015f1 100644 --- a/integration-tests/container/schedule-curls/Makefile +++ b/integration-tests/container/schedule-curls/Makefile @@ -1,13 +1,14 @@ +BASE_PATH = . +include ../Makefile-constants.mk + .DEFAULT_GOAL = all COLLECTOR_QA_SCHEDULE_CURLS_TAG := collector-schedule-curls ifneq ($(COLLECTOR_QA_TAG),) -COLLECTOR_QA_SCHEDULE_CURLS_TAG=collector-schedule-curls-$(COLLECTOR_QA_TAG) +COLLECTOR_QA_SCHEDULE_CURLS_TAG=collector-schedule-curls-$(COLLECTOR_QA_TAG)$(IMAGE_SUFFIX) endif -PLATFORM ?= linux/amd64 - .PHONY: all all: @docker buildx build --load --platform ${PLATFORM} \ @@ -17,3 +18,12 @@ all: push: @docker buildx build --push --platform ${PLATFORM} \ -t quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_SCHEDULE_CURLS_TAG) . + +.PHONY: manifest +manifest: + @docker manifest create quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_SCHEDULE_CURLS_TAG) \ + quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_SCHEDULE_CURLS_TAG)-amd64 \ + quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_SCHEDULE_CURLS_TAG)-s390x \ + quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_SCHEDULE_CURLS_TAG)-ppc64le + + @docker manifest push quay.io/rhacs-eng/qa-multi-arch:$(COLLECTOR_QA_SCHEDULE_CURLS_TAG)