Skip to content

Commit 8c2e03f

Browse files
committed
ci: fail postgres test step on SQL errors and [FAIL] markers
The postgres-test job was reporting success even when test files emitted SQL errors and [FAIL] lines, because psql exits 0 by default and the script's :fail-based RAISE EXCEPTION can be bypassed when an earlier error prevents the counter from being incremented. Run psql with ON_ERROR_STOP=on, enable pipefail around the tee, and grep the captured log for [FAIL] / psql ERROR lines as a final guard so any one of the three signals fails the workflow step.
1 parent c97f7da commit 8c2e03f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

.github/workflows/main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,14 @@ jobs:
273273
274274
- name: run postgresql tests
275275
run: |
276+
set -o pipefail
276277
docker exec cloudsync-postgres mkdir -p /tmp/cloudsync/test
277278
docker cp test/postgresql cloudsync-postgres:/tmp/cloudsync/test/postgresql
278-
docker exec cloudsync-postgres psql -U postgres -d postgres -f /tmp/cloudsync/test/postgresql/full_test.sql
279+
docker exec cloudsync-postgres psql -v ON_ERROR_STOP=on -U postgres -d postgres -f /tmp/cloudsync/test/postgresql/full_test.sql 2>&1 | tee /tmp/pgtest.log
280+
if grep -Eq '^(\[FAIL\]|psql:.*ERROR)' /tmp/pgtest.log; then
281+
echo "::error::PostgreSQL test failures detected"
282+
exit 1
283+
fi
279284
280285
postgres-build:
281286
if: ${{ !contains(github.event.head_commit.message, '[auto-update]') }}

0 commit comments

Comments
 (0)