Skip to content

Commit 04452a1

Browse files
committed
ci: split build and test into separate jobs, upgrade actions to Node 24
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
1 parent 2a15d6d commit 04452a1

2 files changed

Lines changed: 66 additions & 7 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
container: citus/stylechecker:no-py
1818
steps:
1919
- name: Checkout repository
20-
uses: actions/checkout@v4.2.2
20+
uses: actions/checkout@v7.0.0
2121

2222
- name: Set safe directory for git
2323
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
@@ -28,9 +28,38 @@ jobs:
2828
- name: Check banned functions
2929
run: ci/banned.h.sh
3030

31+
build_images:
32+
name: Build test image (PG${{ matrix.PGVERSION }})
33+
runs-on: ubuntu-latest
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
PGVERSION:
38+
- 14
39+
- 15
40+
- 16
41+
- 17
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v7.0.0
45+
46+
- name: Build Docker test image
47+
run: PGVERSION=${{ matrix.PGVERSION }} make build-test-image
48+
49+
- name: Save Docker image to archive
50+
run: PGVERSION=${{ matrix.PGVERSION }} make save-test-image
51+
52+
- name: Upload image archive
53+
uses: actions/upload-artifact@v7.0.1
54+
with:
55+
name: pg-test-image-${{ matrix.PGVERSION }}
56+
path: pg_auto_failover_test-pg${{ matrix.PGVERSION }}.tar.zst
57+
retention-days: 1
58+
3159
run_tests:
32-
name: Run test
60+
name: Run test (${{ matrix.PGVERSION }}, ${{ matrix.TEST }})
3361
runs-on: ubuntu-latest
62+
needs: build_images
3463
strategy:
3564
fail-fast: false
3665
matrix:
@@ -50,17 +79,22 @@ jobs:
5079
TEST: tablespaces
5180
steps:
5281
- name: Checkout repository
53-
uses: actions/checkout@v4.2.2
82+
uses: actions/checkout@v7.0.0
83+
84+
- name: Download image archive
85+
uses: actions/download-artifact@v8.0.1
86+
with:
87+
name: pg-test-image-${{ matrix.PGVERSION }}
88+
89+
- name: Load Docker test image
90+
run: PGVERSION=${{ matrix.PGVERSION }} make load-test-image
5491

5592
- name: Set environment variables
5693
run: |
5794
echo "PGVERSION=${{ matrix.PGVERSION }}" >> $GITHUB_ENV
5895
echo "TEST=${{ matrix.TEST }}" >> $GITHUB_ENV
5996
echo "TRAVIS_BUILD_DIR=$(pwd)" >> $GITHUB_ENV
6097
61-
- name: Build Docker Test Image
62-
run: make build-test-image
63-
6498
- name: Run Test
6599
timeout-minutes: 15
66-
run: make ci-test
100+
run: make run-test-prebuilt

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,31 @@ run-test: build-test-pg$(PGVERSION)
350350
make -C /usr/src/pg_auto_failover test \
351351
PGVERSION=$(PGVERSION) TEST='${TEST}'
352352

353+
# make run-test-prebuilt; like run-test but skips the build step.
354+
# Used in CI after images have been built and loaded by a prior job.
355+
.PHONY: run-test-prebuilt
356+
run-test-prebuilt:
357+
docker run \
358+
--name $(TEST_CONTAINER_NAME) \
359+
$(DOCKER_RUN_OPTS) \
360+
$(TEST_CONTAINER_NAME):pg$(PGVERSION) \
361+
make -C /usr/src/pg_auto_failover test \
362+
PGVERSION=$(PGVERSION) TEST='${TEST}'
363+
364+
# make save-test-image; compresses the test image to a .tar.zst archive.
365+
# Used in CI to pass the built image to downstream test jobs as an artifact.
366+
.PHONY: save-test-image
367+
save-test-image:
368+
docker save $(TEST_CONTAINER_NAME):pg$(PGVERSION) \
369+
| zstd -T0 -3 > $(TEST_CONTAINER_NAME)-pg$(PGVERSION).tar.zst
370+
371+
# make load-test-image; decompresses and loads a .tar.zst image archive.
372+
# Used in CI test jobs that download the image from a prior build job.
373+
.PHONY: load-test-image
374+
load-test-image:
375+
zstd -d --stdout $(TEST_CONTAINER_NAME)-pg$(PGVERSION).tar.zst \
376+
| docker load
377+
353378
#
354379
# BE INTERACTIVE
355380
#

0 commit comments

Comments
 (0)