Skip to content

Commit 37070d9

Browse files
committed
Fix GitHub Actions PostgreSQL configuration and test execution
- Replace docker restart with proper pg_ctl stop/start for reliability - Add comprehensive pg_hba.conf configuration (host + local trust) - Add --no-psqlrc flag to prevent psqlrc interference - Improve timing and synchronization with sleep buffer - Add better error handling with || true for stop command - Apply consistent approach to both regular and beta tests
1 parent be6de78 commit 37070d9

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

.github/workflows/test.yml

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,25 @@ jobs:
4646
sleep 2
4747
done
4848
49-
# Get container ID and configure shared_preload_libraries
49+
# Get container ID
5050
CONTAINER_ID=$(docker ps --filter "expose=5432" --format "{{.ID}}")
5151
echo "PostgreSQL container: $CONTAINER_ID"
5252
53-
# Configure shared_preload_libraries in postgresql.conf
53+
# Stop PostgreSQL to modify configuration
54+
docker exec $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -m fast stop || true
55+
56+
# Configure shared_preload_libraries
5457
docker exec $CONTAINER_ID bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /var/lib/postgresql/data/postgresql.conf"
5558
56-
# Configure pg_hba.conf for trust authentication
57-
docker exec $CONTAINER_ID bash -c "echo 'local all all trust' > /var/lib/postgresql/data/pg_hba.conf"
59+
# Configure trust authentication for easier testing
60+
docker exec $CONTAINER_ID bash -c "echo 'host all all all trust' > /var/lib/postgresql/data/pg_hba.conf"
61+
docker exec $CONTAINER_ID bash -c "echo 'local all all trust' >> /var/lib/postgresql/data/pg_hba.conf"
5862
59-
# Restart PostgreSQL to load the configuration
60-
docker restart $CONTAINER_ID
63+
# Restart PostgreSQL
64+
docker exec $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -l /var/lib/postgresql/data/logfile start
6165
6266
# Wait for PostgreSQL to be ready after restart
67+
sleep 5
6368
until pg_isready -h localhost -p 5432 -U postgres; do
6469
echo "Waiting for postgres to restart..."
6570
sleep 2
@@ -77,7 +82,7 @@ jobs:
7782
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
7883
7984
# Verify extensions
80-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension;'
85+
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension ORDER BY extname;'
8186
8287
# Create test tables (exactly as in CircleCI)
8388
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);"
@@ -90,10 +95,10 @@ jobs:
9095
echo "Testing all SQL files in wide mode..."
9196
for f in sql/*; do
9297
echo " Testing $f..."
93-
if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then
98+
if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
9499
echo "❌ FAILED: $f in wide mode"
95100
echo "Error output:"
96-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f"
101+
PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f"
97102
exit 1
98103
fi
99104
done
@@ -106,10 +111,10 @@ jobs:
106111
echo "Testing all SQL files in normal mode..."
107112
for f in sql/*; do
108113
echo " Testing $f..."
109-
if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then
114+
if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
110115
echo "❌ FAILED: $f in normal mode"
111116
echo "Error output:"
112-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f"
117+
PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f"
113118
exit 1
114119
fi
115120
done
@@ -123,13 +128,13 @@ jobs:
123128
echo "Running regression tests..."
124129
125130
echo " Testing 0_node.sql..."
126-
diff -b test/regression/0_node.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/0_node.sql | grep Role)
131+
diff -b test/regression/0_node.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f sql/0_node.sql | grep Role)
127132
128133
echo " Testing p1_alignment_padding.sql..."
129-
diff -b test/regression/p1_alignment_padding.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align)
134+
diff -b test/regression/p1_alignment_padding.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f sql/p1_alignment_padding.sql | grep align)
130135
131136
echo " Testing a1_activity.sql..."
132-
diff -b test/regression/a1_activity.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/a1_activity.sql | grep User)
137+
diff -b test/regression/a1_activity.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f sql/a1_activity.sql | grep User)
133138
134139
echo "✅ All regression tests passed"
135140
@@ -173,20 +178,25 @@ jobs:
173178
sleep 2
174179
done
175180
176-
# Get container ID and configure shared_preload_libraries
181+
# Get container ID
177182
CONTAINER_ID=$(docker ps --filter "expose=5432" --format "{{.ID}}")
178183
echo "PostgreSQL container: $CONTAINER_ID"
179184
180-
# Configure shared_preload_libraries in postgresql.conf
185+
# Stop PostgreSQL to modify configuration
186+
docker exec $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -m fast stop || true
187+
188+
# Configure shared_preload_libraries
181189
docker exec $CONTAINER_ID bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /var/lib/postgresql/data/postgresql.conf"
182190
183-
# Configure pg_hba.conf for trust authentication
184-
docker exec $CONTAINER_ID bash -c "echo 'local all all trust' > /var/lib/postgresql/data/pg_hba.conf"
191+
# Configure trust authentication
192+
docker exec $CONTAINER_ID bash -c "echo 'host all all all trust' > /var/lib/postgresql/data/pg_hba.conf"
193+
docker exec $CONTAINER_ID bash -c "echo 'local all all trust' >> /var/lib/postgresql/data/pg_hba.conf"
185194
186-
# Restart PostgreSQL to load the configuration
187-
docker restart $CONTAINER_ID
195+
# Restart PostgreSQL
196+
docker exec $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -l /var/lib/postgresql/data/logfile start
188197
189198
# Wait for PostgreSQL to be ready after restart
199+
sleep 5
190200
until pg_isready -h localhost -p 5432 -U postgres; do
191201
echo "Waiting for postgres to restart..."
192202
sleep 2
@@ -211,21 +221,21 @@ jobs:
211221
run: |
212222
echo "\set postgres_dba_wide true" > ~/.psqlrc
213223
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
214-
echo "Testing all SQL files in wide mode (PostgreSQL 18 beta)..."
224+
echo "Testing all SQL files in wide mode (PostgreSQL ${{ matrix.postgres-version }})..."
215225
for f in sql/*; do
216226
echo " Testing $f..."
217-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in wide mode (beta)"
227+
PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in wide mode (beta)"
218228
done
219229
echo "✅ Wide mode tests completed (beta)"
220230
221231
- name: Test normal mode (beta)
222232
run: |
223233
echo "\set postgres_dba_wide false" > ~/.psqlrc
224234
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
225-
echo "Testing all SQL files in normal mode (PostgreSQL 18 beta)..."
235+
echo "Testing all SQL files in normal mode (PostgreSQL ${{ matrix.postgres-version }})..."
226236
for f in sql/*; do
227237
echo " Testing $f..."
228-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in normal mode (beta)"
238+
PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in normal mode (beta)"
229239
done
230240
echo "✅ Normal mode tests completed (beta)"
231241

0 commit comments

Comments
 (0)