Skip to content

Commit e940260

Browse files
authored
Merge pull request #337 from cipherstash/support-postgres-18
Test multiple versions of postgres
2 parents 2d436e1 + a8abb06 commit e940260

File tree

7 files changed

+130
-13
lines changed

7 files changed

+130
-13
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ env:
1313

1414
jobs:
1515
test:
16-
name: Test
16+
name: Test (PostgreSQL ${{ matrix.pg_version }})
1717
runs-on: blacksmith-16vcpu-ubuntu-2204
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
pg_version: [14, 15, 16, 17] # PG 18 not currently supported
22+
env:
23+
PG_VERSION: ${{ matrix.pg_version }}
1824
steps:
1925
- uses: actions/checkout@v4
2026
- uses: ./.github/actions/setup-test

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ CS_CLIENT_KEY = "your-client-key"
123123
- `5617` - PostgreSQL 17 (TLS)
124124
- `6432` - CipherStash Proxy
125125

126-
Container names: `postgres`, `postgres-17-tls`, `proxy`, `proxy-tls`
126+
Container names: `postgres`, `postgres-tls`, `proxy`, `proxy-tls`
127127

128128
### Logging Configuration
129129
Set granular log levels by target:

DEVELOPMENT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ mise run postgres:up
175175
176176
# Start postgres instances individually in the foreground
177177
mise run postgres:up postgres
178-
mise run postgres:up postgres-17-tls
178+
mise run postgres:up postgres-tls
179179
180180
# Start a postgres instance in the background
181181
mise run postgres:up postgres --extra-args "--detach --wait"
@@ -463,7 +463,7 @@ These are the Postgres instances and names currently provided:
463463

464464
| Name | Description |
465465
|-------------------|--------------------------------|
466-
| `postgres-17-tls` | TLS, PostgreSQL version 17 |
466+
| `postgres-tls` | TLS, (PostgreSQL version 17) |
467467
| `postgres` | non-TLS, Postgres latest |
468468

469469

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# PostgreSQL Version Matrix for CI
2+
3+
## Problem
4+
5+
PostgreSQL 18 was released and the `postgres:latest` Docker image broke volume mounting (commit `3e4fff24`). CI was pinned to PostgreSQL 17. We need to:
6+
1. Support PostgreSQL 18 (assuming upstream fix)
7+
2. Expand test coverage across multiple PostgreSQL versions
8+
3. Catch future breaking changes early
9+
10+
## Decision
11+
12+
Run a full parallel matrix in CI testing PostgreSQL versions 14, 15, 16, 17, and 18.
13+
14+
## Design
15+
16+
### GitHub Actions Matrix Strategy
17+
18+
Update `.github/workflows/test.yml`:
19+
20+
```yaml
21+
jobs:
22+
test:
23+
name: Test (PostgreSQL ${{ matrix.pg_version }})
24+
runs-on: blacksmith-16vcpu-ubuntu-2204
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
pg_version: [14, 15, 16, 17, 18]
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: ./.github/actions/setup-test
32+
- run: |
33+
mise run postgres:up --extra-args "--detach --wait"
34+
env:
35+
PG_VERSION: ${{ matrix.pg_version }}
36+
# ... rest of steps with PG_VERSION in env
37+
```
38+
39+
- `fail-fast: false` ensures all versions complete even if one fails
40+
- Version passed via `PG_VERSION` environment variable
41+
- Job names include version for clear identification in GitHub UI
42+
43+
### Docker Compose Changes
44+
45+
Update `tests/docker-compose.yml`:
46+
47+
```yaml
48+
services:
49+
postgres: &postgres
50+
image: postgres:${PG_VERSION:-17}
51+
pull_policy: always
52+
# ... rest unchanged
53+
54+
postgres-tls: # renamed from postgres-17-tls
55+
<<: *postgres
56+
image: postgres:${PG_VERSION:-17}
57+
container_name: postgres-tls
58+
environment:
59+
PGPORT: 5617
60+
volumes:
61+
- ./pg/pg_hba-tls.conf:/etc/postgresql/pg_hba.conf
62+
- ./tls/localhost-key.pem:/etc/postgresql/localhost-key.pem
63+
- ./tls/localhost.pem:/etc/postgresql/localhost.pem
64+
- ./pg/data-tls:/var/lib/postgresql/data # simplified from data-17
65+
```
66+
67+
- Both containers use `postgres:${PG_VERSION:-17}` - defaults to 17 for local dev
68+
- Rename `postgres-17-tls` → `postgres-tls` (version-agnostic naming)
69+
- Data directory `data-17` → `data-tls` (version-agnostic)
70+
71+
### Mise Configuration Updates
72+
73+
Update `mise.toml` task `postgres:up` default services:
74+
- Change `postgres postgres-17-tls` → `postgres postgres-tls`
75+
76+
Update `tests/mise.tls.toml`:
77+
- Update any `postgres-17-tls` references to `postgres-tls`
78+
79+
No explicit `PG_VERSION` passthrough needed - docker-compose reads from environment.
80+
81+
### CI Test Execution
82+
83+
Each matrix job runs the full integration suite against one PostgreSQL version:
84+
- All jobs use same ports (5532, 5617, 6432) - no conflicts as each runs on separate runner
85+
- Tests run against TLS-enabled PostgreSQL container
86+
- Each version shows as separate check in GitHub PR
87+
88+
## Files to Modify
89+
90+
| File | Change |
91+
|------|--------|
92+
| `.github/workflows/test.yml` | Add matrix strategy with `pg_version: [14, 15, 16, 17, 18]` |
93+
| `tests/docker-compose.yml` | Use `postgres:${PG_VERSION:-17}`, rename `postgres-17-tls` → `postgres-tls` |
94+
| `mise.toml` | Update default services in `postgres:up` task |
95+
| `tests/mise.tls.toml` | Update container name reference if present |
96+
97+
## Local Development
98+
99+
No changes to local development workflow. Defaults to PostgreSQL 17.
100+
101+
## Validation
102+
103+
1. Create branch with changes
104+
2. Push to trigger CI matrix
105+
3. Verify all 5 versions pass (especially v18 to confirm volume issue resolved)
106+
4. If v18 fails, investigate the specific volume issue before merge
107+
108+
## Rollback
109+
110+
- Remove strategy block to revert to single version
111+
- `PG_VERSION` defaults to 17, so removing the env var restores current behavior

mise.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ description = "Run Postgres instances with docker compose"
477477
run = """
478478
set -e
479479
# Start the containers
480-
echo docker compose up --build {{arg(name="service",default="postgres postgres-17-tls")}} {{option(name="extra-args",default="")}} | bash
480+
echo docker compose up --build {{arg(name="service",default="postgres postgres-tls")}} {{option(name="extra-args",default="")}} | bash
481481
"""
482482

483483
[tasks."postgres:psql"]

tests/docker-compose.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
postgres: &postgres
3-
image: postgres:17
3+
image: postgres:${PG_VERSION:-17}
44
pull_policy: always
55
container_name: postgres
66
command: -c 'config_file=/etc/postgresql/postgresql.conf'
@@ -12,7 +12,7 @@ services:
1212
volumes:
1313
- ./pg/postgresql.conf:/etc/postgresql/postgresql.conf
1414
- ./benchmark/sql/:/etc/postgresql/benchmark/sql
15-
- ./pg/data-latest:/var/lib/postgresql/data
15+
- ./pg/data-latest:/var/lib/postgresql
1616
env_file:
1717
- ./pg/common.env
1818
networks:
@@ -30,10 +30,10 @@ services:
3030
timeout: 5s
3131
retries: 10
3232

33-
postgres-17-tls:
33+
postgres-tls:
3434
<<: *postgres
35-
image: postgres:17
36-
container_name: postgres-17-tls
35+
image: postgres:${PG_VERSION:-17}
36+
container_name: postgres-tls
3737
environment:
3838
PGPORT: 5617
3939
ports:
@@ -44,7 +44,7 @@ services:
4444
- ./pg/pg_hba-tls.conf:/etc/postgresql/pg_hba.conf
4545
- ./tls/localhost-key.pem:/etc/postgresql/localhost-key.pem
4646
- ./tls/localhost.pem:/etc/postgresql/localhost.pem
47-
- ./pg/data-17:/var/lib/postgresql/data
47+
- ./pg/data-17:/var/lib/postgresql
4848

4949
proxy:
5050
image: cipherstash/proxy:latest

tests/mise.tls.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[env]
2-
CS_DATABASE__HOST = "postgres-17-tls"
3-
CONTAINER_SUFFIX = "-17-tls"
2+
CS_DATABASE__HOST = "postgres-tls"
3+
CONTAINER_SUFFIX = "-tls"
44
CS_DATABASE__PORT = "5617"
55
CS_TLS__TYPE = "Path"
66
CS_TLS__CERTIFICATE_PATH = "/etc/cipherstash-proxy/server.cert"

0 commit comments

Comments
 (0)