From 04452a1b0cd962649589fa45637f747b64274367 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Mon, 6 Jul 2026 18:33:55 +0200 Subject: [PATCH 1/2] ci: split build and test into separate jobs, upgrade actions to Node 24 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously each of the 21 test matrix cells built its own Docker image, totalling 21 redundant builds per CI run. New structure: - build_images: 4 jobs (one per PG version), builds the test image and uploads it as a zstd-compressed artifact (retention: 1 day). - run_tests: 21 jobs (same matrix as before), downloads the pre-built image artifact and runs tests against it via make run-test-prebuilt. This cuts Docker builds from 21 to 4 per CI run. Also upgrades all actions/checkout, actions/upload-artifact, and actions/download-artifact from Node 20 to Node 24 (v7/v7/v8) to silence the runner deprecation warning. New Makefile targets: save-test-image docker save | zstd → .tar.zst archive load-test-image zstd decompress | docker load run-test-prebuilt like run-test but without the build prerequisite --- .github/workflows/run-tests.yml | 48 ++++++++++++++++++++++++++++----- Makefile | 25 +++++++++++++++++ 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 388479e6b..6ca92f83f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,7 +17,7 @@ jobs: container: citus/stylechecker:no-py steps: - name: Checkout repository - uses: actions/checkout@v4.2.2 + uses: actions/checkout@v7.0.0 - name: Set safe directory for git run: git config --global --add safe.directory ${GITHUB_WORKSPACE} @@ -28,9 +28,38 @@ jobs: - name: Check banned functions run: ci/banned.h.sh + build_images: + name: Build test image (PG${{ matrix.PGVERSION }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + PGVERSION: + - 14 + - 15 + - 16 + - 17 + steps: + - name: Checkout repository + uses: actions/checkout@v7.0.0 + + - name: Build Docker test image + run: PGVERSION=${{ matrix.PGVERSION }} make build-test-image + + - name: Save Docker image to archive + run: PGVERSION=${{ matrix.PGVERSION }} make save-test-image + + - name: Upload image archive + uses: actions/upload-artifact@v7.0.1 + with: + name: pg-test-image-${{ matrix.PGVERSION }} + path: pg_auto_failover_test-pg${{ matrix.PGVERSION }}.tar.zst + retention-days: 1 + run_tests: - name: Run test + name: Run test (${{ matrix.PGVERSION }}, ${{ matrix.TEST }}) runs-on: ubuntu-latest + needs: build_images strategy: fail-fast: false matrix: @@ -50,7 +79,15 @@ jobs: TEST: tablespaces steps: - name: Checkout repository - uses: actions/checkout@v4.2.2 + uses: actions/checkout@v7.0.0 + + - name: Download image archive + uses: actions/download-artifact@v8.0.1 + with: + name: pg-test-image-${{ matrix.PGVERSION }} + + - name: Load Docker test image + run: PGVERSION=${{ matrix.PGVERSION }} make load-test-image - name: Set environment variables run: | @@ -58,9 +95,6 @@ jobs: echo "TEST=${{ matrix.TEST }}" >> $GITHUB_ENV echo "TRAVIS_BUILD_DIR=$(pwd)" >> $GITHUB_ENV - - name: Build Docker Test Image - run: make build-test-image - - name: Run Test timeout-minutes: 15 - run: make ci-test + run: make run-test-prebuilt diff --git a/Makefile b/Makefile index 710786410..b6f692ec3 100644 --- a/Makefile +++ b/Makefile @@ -350,6 +350,31 @@ run-test: build-test-pg$(PGVERSION) make -C /usr/src/pg_auto_failover test \ PGVERSION=$(PGVERSION) TEST='${TEST}' +# make run-test-prebuilt; like run-test but skips the build step. +# Used in CI after images have been built and loaded by a prior job. +.PHONY: run-test-prebuilt +run-test-prebuilt: + docker run \ + --name $(TEST_CONTAINER_NAME) \ + $(DOCKER_RUN_OPTS) \ + $(TEST_CONTAINER_NAME):pg$(PGVERSION) \ + make -C /usr/src/pg_auto_failover test \ + PGVERSION=$(PGVERSION) TEST='${TEST}' + +# make save-test-image; compresses the test image to a .tar.zst archive. +# Used in CI to pass the built image to downstream test jobs as an artifact. +.PHONY: save-test-image +save-test-image: + docker save $(TEST_CONTAINER_NAME):pg$(PGVERSION) \ + | zstd -T0 -3 > $(TEST_CONTAINER_NAME)-pg$(PGVERSION).tar.zst + +# make load-test-image; decompresses and loads a .tar.zst image archive. +# Used in CI test jobs that download the image from a prior build job. +.PHONY: load-test-image +load-test-image: + zstd -d --stdout $(TEST_CONTAINER_NAME)-pg$(PGVERSION).tar.zst \ + | docker load + # # BE INTERACTIVE # From 9419742005ebc21d91842a2e71993da412c9a9b4 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Mon, 6 Jul 2026 18:48:06 +0200 Subject: [PATCH 2/2] fix: run-test-prebuilt must delegate tablespaces like ci-test does The tablespaces suite runs via $(MAKE) -C tests/tablespaces run-test on the host, not inside the pg_auto_failover_test container. run-test-prebuilt was always entering the container, causing a 33s failure for (14, tablespaces) in CI. Mirror ci-test's ifeq dispatch so tablespaces takes the host path. --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b6f692ec3..733e15540 100644 --- a/Makefile +++ b/Makefile @@ -350,16 +350,20 @@ run-test: build-test-pg$(PGVERSION) make -C /usr/src/pg_auto_failover test \ PGVERSION=$(PGVERSION) TEST='${TEST}' -# make run-test-prebuilt; like run-test but skips the build step. +# make run-test-prebuilt; like ci-test but skips the Docker build step. # Used in CI after images have been built and loaded by a prior job. .PHONY: run-test-prebuilt run-test-prebuilt: +ifeq ($(TEST),tablespaces) + $(MAKE) -C tests/tablespaces run-test +else docker run \ --name $(TEST_CONTAINER_NAME) \ $(DOCKER_RUN_OPTS) \ $(TEST_CONTAINER_NAME):pg$(PGVERSION) \ make -C /usr/src/pg_auto_failover test \ PGVERSION=$(PGVERSION) TEST='${TEST}' +endif # make save-test-image; compresses the test image to a .tar.zst archive. # Used in CI to pass the built image to downstream test jobs as an artifact.