Skip to content

Commit 4e5a9f5

Browse files
committed
ci: use shared postgres service for database tests
Replace spawning individual postgres clusters with a shared postgres service container. This avoids the overhead of initdb and cluster startup for each test session. Changes: - Add postgres:16 service to integration and check-downgrade jobs - Switch TEST_DB_PROVIDER from 'postgres' to 'postgres-system' - Add TEST_DB_PROVIDER_DSN environment variable for the service
1 parent 9bd0dfa commit 4e5a9f5

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,20 @@ jobs:
249249
runs-on: ubuntu-24.04
250250
needs:
251251
- compile
252+
services:
253+
postgres:
254+
image: postgres:16
255+
env:
256+
POSTGRES_USER: postgres
257+
POSTGRES_PASSWORD: postgres
258+
POSTGRES_DB: postgres
259+
ports:
260+
- 5432:5432
261+
options: >-
262+
--health-cmd pg_isready
263+
--health-interval 10s
264+
--health-timeout 5s
265+
--health-retries 5
252266
strategy:
253267
fail-fast: false
254268
matrix:
@@ -258,7 +272,7 @@ jobs:
258272
TEST_NETWORK: regtest
259273
VALGRIND: 1
260274
- CFG: compile-gcc
261-
TEST_DB_PROVIDER: postgres
275+
TEST_DB_PROVIDER: postgres-system
262276
TEST_NETWORK: regtest
263277
- CFG: compile-gcc
264278
TEST_DB_PROVIDER: sqlite3
@@ -315,6 +329,7 @@ jobs:
315329
PYTEST_PAR: 4
316330
TEST_DEBUG: 1
317331
TEST_DB_PROVIDER: ${{ matrix.TEST_DB_PROVIDER }}
332+
TEST_DB_PROVIDER_DSN: postgres://postgres:postgres@localhost:5432/postgres
318333
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
319334
LIGHTNINGD_POSTGRES_NO_VACUUM: 1
320335
VALGRIND: ${{ matrix.VALGRIND }}
@@ -341,6 +356,20 @@ jobs:
341356
PYTEST_OPTS: -vvv --junit-xml=report.xml --timeout=1800 --durations=10
342357
needs:
343358
- compile
359+
services:
360+
postgres:
361+
image: postgres:16
362+
env:
363+
POSTGRES_USER: postgres
364+
POSTGRES_PASSWORD: postgres
365+
POSTGRES_DB: postgres
366+
ports:
367+
- 5432:5432
368+
options: >-
369+
--health-cmd pg_isready
370+
--health-interval 10s
371+
--health-timeout 5s
372+
--health-retries 5
344373
strategy:
345374
fail-fast: false
346375
matrix:
@@ -360,7 +389,7 @@ jobs:
360389
- NAME: postgres
361390
CFG: compile-gcc
362391
COMPILER: gcc
363-
TEST_DB_PROVIDER: postgres
392+
TEST_DB_PROVIDER: postgres-system
364393
TEST_NETWORK: regtest
365394
# And don't forget about elements (like cdecker did when
366395
# reworking the CI...)
@@ -433,6 +462,7 @@ jobs:
433462
PYTEST_PAR: 4
434463
TEST_DEBUG: 1
435464
TEST_DB_PROVIDER: ${{ matrix.TEST_DB_PROVIDER }}
465+
TEST_DB_PROVIDER_DSN: postgres://postgres:postgres@localhost:5432/postgres
436466
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
437467
LIGHTNINGD_POSTGRES_NO_VACUUM: 1
438468
run: |

0 commit comments

Comments
 (0)