From d72c5c3bf7c3cd1108a90970d02e176a94909f07 Mon Sep 17 00:00:00 2001 From: Andrea Donetti Date: Thu, 26 Mar 2026 13:01:45 -0600 Subject: [PATCH] feat(postgresql): add configurable PostgreSQL version for build and CI Make the Docker image PostgreSQL version configurable via POSTGRES_TAG build arg, and run CI tests against both PG 17 and PG 15. Print the PostgreSQL server version in test output for easier debugging. --- .github/workflows/main.yml | 8 ++++++-- docker/postgresql/Dockerfile | 8 +++++--- docker/postgresql/docker-compose.yml | 2 ++ test/postgresql/01_unittest.sql | 3 ++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 39f0517..6176a99 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -240,8 +240,12 @@ jobs: postgres-test: runs-on: ubuntu-22.04 - name: postgresql build + test + name: postgresql ${{ matrix.postgres_tag }} build + test timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + postgres_tag: ['17', '15'] steps: @@ -250,7 +254,7 @@ jobs: submodules: true - name: build and start postgresql container - run: make postgres-docker-rebuild + run: POSTGRES_TAG=${{ matrix.postgres_tag }} make postgres-docker-rebuild - name: wait for postgresql to be ready run: | diff --git a/docker/postgresql/Dockerfile b/docker/postgresql/Dockerfile index ec3d30c..b86e6dc 100644 --- a/docker/postgresql/Dockerfile +++ b/docker/postgresql/Dockerfile @@ -1,10 +1,12 @@ # PostgreSQL Docker image with CloudSync extension pre-installed -FROM postgres:17 +ARG POSTGRES_TAG=17 +FROM postgres:${POSTGRES_TAG} -# Install build dependencies +# Derive the major version from PG_MAJOR (set by the official postgres image) +# and install the matching server-dev package RUN apt-get update && apt-get install -y \ build-essential \ - postgresql-server-dev-17 \ + postgresql-server-dev-${PG_MAJOR} \ git \ make \ && rm -rf /var/lib/apt/lists/* diff --git a/docker/postgresql/docker-compose.yml b/docker/postgresql/docker-compose.yml index 34010b3..5a3257d 100644 --- a/docker/postgresql/docker-compose.yml +++ b/docker/postgresql/docker-compose.yml @@ -3,6 +3,8 @@ services: build: context: ../.. dockerfile: docker/postgresql/Dockerfile + args: + POSTGRES_TAG: ${POSTGRES_TAG:-17} container_name: cloudsync-postgres environment: POSTGRES_USER: postgres diff --git a/test/postgresql/01_unittest.sql b/test/postgresql/01_unittest.sql index 59ba93f..e340ebc 100644 --- a/test/postgresql/01_unittest.sql +++ b/test/postgresql/01_unittest.sql @@ -17,7 +17,8 @@ CREATE EXTENSION IF NOT EXISTS cloudsync; -- 'Test version visibility' SELECT cloudsync_version() AS version \gset -\echo [PASS] (:testid) Test cloudsync_version: :version +SELECT current_setting('server_version') AS pg_version \gset +\echo [PASS] (:testid) Test cloudsync_version: :version (PostgreSQL :pg_version) -- Test uuid generation SELECT cloudsync_uuid() AS uuid1 \gset