From 5463ea437545159aae8976f6331a95c1ab8f5668 Mon Sep 17 00:00:00 2001 From: BaaRai <130491490+BaaRai@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:26:24 +0100 Subject: [PATCH] ci: build a dedicated database for the online index scripts The job-level test database has no schema and cached go test results do not guarantee any suffixed test database exists; create one from db/schema.sql and db/migrations, then apply and roll back the scripts. --- .github/workflows/ci.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d28bb4c..28c0030 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,15 +49,18 @@ jobs: # keeps the database state deterministic. run: go test -p 1 ./... - name: online index scripts - # Apply and roll back scripts/sql against a database that holds the - # schema. The job-level artextest database stays empty (every package - # that opens the database uses its own suffixed one); the db package's - # artextest_db has the full schema after the step above. + # Apply and roll back scripts/sql on a database built here from + # db/schema.sql and db/migrations. The job-level artextest database + # never gets the schema (packages use suffixed databases), and cached + # test results mean no test database is guaranteed to exist. env: - ARTEX_PG_DSN: postgres://artex:testpass@localhost:5432/artextest_db?sslmode=disable + SQL_DSN: postgres://artex:testpass@localhost:5432/artextest_sqlscripts?sslmode=disable run: | - psql "$ARTEX_PG_DSN" -X -v ON_ERROR_STOP=1 -f scripts/sql/20261115-task-query-indexes.sql - psql "$ARTEX_PG_DSN" -X -v ON_ERROR_STOP=1 -f scripts/sql/20261115-task-query-indexes.rollback.sql + psql "$ARTEX_PG_DSN" -X -v ON_ERROR_STOP=1 -c 'CREATE DATABASE artextest_sqlscripts' + psql "$SQL_DSN" -X -q -v ON_ERROR_STOP=1 -f db/schema.sql + for f in db/migrations/*.sql; do psql "$SQL_DSN" -X -q -v ON_ERROR_STOP=1 -f "$f"; done + psql "$SQL_DSN" -X -v ON_ERROR_STOP=1 -f scripts/sql/20261115-task-query-indexes.sql + psql "$SQL_DSN" -X -v ON_ERROR_STOP=1 -f scripts/sql/20261115-task-query-indexes.rollback.sql - name: go test -race # Race detector on the packages that pass under -race today. ./server # joined once its suite was checked with -race against postgres and its