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..733e15540 100644 --- a/Makefile +++ b/Makefile @@ -350,6 +350,35 @@ run-test: build-test-pg$(PGVERSION) make -C /usr/src/pg_auto_failover test \ PGVERSION=$(PGVERSION) TEST='${TEST}' +# 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. +.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 #