Skip to content

Commit ac5167f

Browse files
Enhance CI workflow: add PostgreSQL readiness check after restart and verify pg_stat_statements configuration
1 parent 1fa123c commit ac5167f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
ports:
2727
- 5432:5432
2828
options: >-
29+
--name pgtools-postgres-ci
2930
--health-cmd "pg_isready -U postgres"
3031
--health-interval 10s
3132
--health-timeout 5s
@@ -55,6 +56,26 @@ jobs:
5556
psql -c "CREATE EXTENSION IF NOT EXISTS pg_stat_statements;"
5657
psql -c "SELECT extname FROM pg_extension WHERE extname = 'pg_stat_statements';"
5758
59+
- name: Configure preload and restart PostgreSQL
60+
run: |
61+
psql -c "ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements';"
62+
docker restart pgtools-postgres-ci
63+
64+
for i in {1..30}; do
65+
if pg_isready -h "$PGHOST" -p "$PGPORT" -U "$PGUSER"; then
66+
break
67+
fi
68+
sleep 2
69+
done
70+
71+
if ! pg_isready -h "$PGHOST" -p "$PGPORT" -U "$PGUSER"; then
72+
echo "PostgreSQL did not become ready after restart" >&2
73+
exit 1
74+
fi
75+
76+
psql -tA -c "SHOW shared_preload_libraries;" | grep -q "pg_stat_statements"
77+
psql -c "SELECT extname FROM pg_extension WHERE extname = 'pg_stat_statements';"
78+
5879
- name: ShellCheck all shell scripts
5980
run: |
6081
shellcheck \

0 commit comments

Comments
 (0)