Skip to content

Commit d72c5c3

Browse files
committed
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.
1 parent b0f245f commit d72c5c3

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@ jobs:
240240

241241
postgres-test:
242242
runs-on: ubuntu-22.04
243-
name: postgresql build + test
243+
name: postgresql ${{ matrix.postgres_tag }} build + test
244244
timeout-minutes: 10
245+
strategy:
246+
fail-fast: false
247+
matrix:
248+
postgres_tag: ['17', '15']
245249

246250
steps:
247251

@@ -250,7 +254,7 @@ jobs:
250254
submodules: true
251255

252256
- name: build and start postgresql container
253-
run: make postgres-docker-rebuild
257+
run: POSTGRES_TAG=${{ matrix.postgres_tag }} make postgres-docker-rebuild
254258

255259
- name: wait for postgresql to be ready
256260
run: |

docker/postgresql/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# PostgreSQL Docker image with CloudSync extension pre-installed
2-
FROM postgres:17
2+
ARG POSTGRES_TAG=17
3+
FROM postgres:${POSTGRES_TAG}
34

4-
# Install build dependencies
5+
# Derive the major version from PG_MAJOR (set by the official postgres image)
6+
# and install the matching server-dev package
57
RUN apt-get update && apt-get install -y \
68
build-essential \
7-
postgresql-server-dev-17 \
9+
postgresql-server-dev-${PG_MAJOR} \
810
git \
911
make \
1012
&& rm -rf /var/lib/apt/lists/*

docker/postgresql/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ services:
33
build:
44
context: ../..
55
dockerfile: docker/postgresql/Dockerfile
6+
args:
7+
POSTGRES_TAG: ${POSTGRES_TAG:-17}
68
container_name: cloudsync-postgres
79
environment:
810
POSTGRES_USER: postgres

test/postgresql/01_unittest.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ CREATE EXTENSION IF NOT EXISTS cloudsync;
1717

1818
-- 'Test version visibility'
1919
SELECT cloudsync_version() AS version \gset
20-
\echo [PASS] (:testid) Test cloudsync_version: :version
20+
SELECT current_setting('server_version') AS pg_version \gset
21+
\echo [PASS] (:testid) Test cloudsync_version: :version (PostgreSQL :pg_version)
2122

2223
-- Test uuid generation
2324
SELECT cloudsync_uuid() AS uuid1 \gset

0 commit comments

Comments
 (0)