Skip to content

Commit d189092

Browse files
cursoragentNikolayS
andcommitted
Improve PostgreSQL configuration and error handling in CI workflow
Co-authored-by: nik <[email protected]>
1 parent b57de9f commit d189092

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

.github/workflows/test.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,27 @@ jobs:
2121

2222
- name: Start PostgreSQL and configure
2323
run: |
24-
# Configure PostgreSQL for pg_stat_statements
25-
sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'pg_stat_statements'/" /etc/postgresql/*/main/postgresql.conf
24+
# Stop default PostgreSQL if running
25+
sudo systemctl stop postgresql.service || true
26+
27+
# Find PostgreSQL config files
28+
echo "PostgreSQL config files:"
29+
find /etc/postgresql -name "postgresql.conf" -type f
30+
find /etc/postgresql -name "pg_hba.conf" -type f
31+
32+
# Configure PostgreSQL for pg_stat_statements (multiple approaches to ensure it works)
33+
sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'pg_stat_statements'/" /etc/postgresql/*/main/postgresql.conf || true
34+
sudo sed -i "s/^#shared_preload_libraries = ''/shared_preload_libraries = 'pg_stat_statements'/" /etc/postgresql/*/main/postgresql.conf || true
35+
sudo bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /etc/postgresql/*/main/postgresql.conf"
36+
37+
# Show the final configuration
38+
echo "Final postgresql.conf shared_preload_libraries setting:"
39+
grep -n "shared_preload_libraries" /etc/postgresql/*/main/postgresql.conf || echo "Not found"
40+
41+
# Set trust authentication for local connections
42+
sudo bash -c "echo 'local all all trust' > /etc/postgresql/*/main/pg_hba.conf"
43+
44+
# Start PostgreSQL
2645
sudo systemctl start postgresql.service
2746
pg_isready
2847
@@ -32,10 +51,17 @@ jobs:
3251
3352
- name: Prepare test database
3453
run: |
54+
# Check PostgreSQL version and available extensions
55+
sudo -u postgres psql -d test -c 'SELECT version();'
56+
sudo -u postgres psql -d test -c 'SELECT * FROM pg_available_extensions WHERE name IN ('"'"'pg_stat_statements'"'"', '"'"'pgstattuple'"'"');'
57+
3558
# Create extensions (they need to be created by superuser)
3659
sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
3760
sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
3861
62+
# Verify extensions are created
63+
sudo -u postgres psql -d test -c 'SELECT * FROM pg_extension;'
64+
3965
# Create test tables
4066
psql -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);"
4167
psql -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);"
@@ -46,7 +72,11 @@ jobs:
4672
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
4773
for f in sql/*; do
4874
echo "Testing $f in wide mode..."
49-
psql -d test -f warmup.psql -f "$f" > /dev/null
75+
if ! psql -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then
76+
echo "FAILED: $f in wide mode"
77+
psql -d test -f warmup.psql -f "$f"
78+
exit 1
79+
fi
5080
done
5181
5282
- name: Test normal mode
@@ -55,7 +85,11 @@ jobs:
5585
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
5686
for f in sql/*; do
5787
echo "Testing $f in normal mode..."
58-
psql -d test -f warmup.psql -f "$f" > /dev/null
88+
if ! psql -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then
89+
echo "FAILED: $f in normal mode"
90+
psql -d test -f warmup.psql -f "$f"
91+
exit 1
92+
fi
5993
done
6094
6195
- name: Run regression tests

0 commit comments

Comments
 (0)