Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 41 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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:
Expand All @@ -50,17 +79,22 @@ 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: |
echo "PGVERSION=${{ matrix.PGVERSION }}" >> $GITHUB_ENV
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
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down