Skip to content

Commit 0db8d88

Browse files
NikolaySclaude
andcommitted
Simplify PostgreSQL configuration using environment variables
- Use POSTGRES_HOST_AUTH_METHOD=trust for authentication - Configure shared_preload_libraries via docker options - Remove complex container manipulation steps - Simplify psql commands without PGPASSWORD 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 14f253e commit 0db8d88

File tree

1 file changed

+16
-42
lines changed

1 file changed

+16
-42
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ jobs:
2121
env:
2222
POSTGRES_PASSWORD: postgres
2323
POSTGRES_DB: test
24+
POSTGRES_HOST_AUTH_METHOD: trust
2425
options: >-
2526
--health-cmd pg_isready
2627
--health-interval 10s
2728
--health-timeout 5s
2829
--health-retries 5
30+
-c shared_preload_libraries=pg_stat_statements
2931
ports:
3032
- 5432:5432
3133

@@ -42,55 +44,27 @@ jobs:
4244
# Verify installation
4345
psql --version
4446
45-
- name: Configure PostgreSQL for pg_stat_statements
47+
- name: Prepare test database
4648
run: |
4749
# Wait for PostgreSQL to be ready
4850
until pg_isready -h localhost -p 5432 -U postgres; do
4951
echo "Waiting for postgres..."
5052
sleep 2
5153
done
5254
53-
# Get container ID
54-
CONTAINER_ID=$(docker ps --filter "expose=5432" --format "{{.ID}}")
55-
echo "PostgreSQL container: $CONTAINER_ID"
56-
57-
# Stop PostgreSQL to modify configuration
58-
docker exec --user postgres $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -m fast stop || true
59-
60-
# Configure shared_preload_libraries
61-
docker exec $CONTAINER_ID bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /var/lib/postgresql/data/postgresql.conf"
62-
63-
# Configure trust authentication for easier testing
64-
docker exec $CONTAINER_ID bash -c "echo 'host all all all trust' > /var/lib/postgresql/data/pg_hba.conf"
65-
docker exec $CONTAINER_ID bash -c "echo 'local all all trust' >> /var/lib/postgresql/data/pg_hba.conf"
66-
67-
# Restart PostgreSQL
68-
docker exec --user postgres $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -l /var/lib/postgresql/data/logfile start
69-
70-
# Wait for PostgreSQL to be ready after restart
71-
sleep 5
72-
until pg_isready -h localhost -p 5432 -U postgres; do
73-
echo "Waiting for postgres to restart..."
74-
sleep 2
75-
done
76-
77-
echo "PostgreSQL ${{ matrix.postgres-version }} configured successfully"
78-
79-
- name: Prepare test database
80-
run: |
8155
# Check PostgreSQL version
82-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'SELECT version();'
56+
psql -h localhost -U postgres -d test -c 'SELECT version();'
8357
8458
# Create extensions
85-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
86-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
59+
psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
60+
psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
8761
8862
# Verify extensions
89-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension ORDER BY extname;'
63+
psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension ORDER BY extname;'
9064
9165
# Create test tables (exactly as in CircleCI)
92-
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);"
93-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);"
66+
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);"
67+
psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);"
9468
9569
- name: Test wide mode
9670
run: |
@@ -99,10 +73,10 @@ jobs:
9973
echo "Testing all SQL files in wide mode..."
10074
for f in sql/*; do
10175
echo " Testing $f..."
102-
if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
76+
if ! psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
10377
echo "❌ FAILED: $f in wide mode"
10478
echo "Error output:"
105-
PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f"
79+
psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f"
10680
exit 1
10781
fi
10882
done
@@ -115,10 +89,10 @@ jobs:
11589
echo "Testing all SQL files in normal mode..."
11690
for f in sql/*; do
11791
echo " Testing $f..."
118-
if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
92+
if ! psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
11993
echo "❌ FAILED: $f in normal mode"
12094
echo "Error output:"
121-
PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f"
95+
psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f"
12296
exit 1
12397
fi
12498
done
@@ -132,13 +106,13 @@ jobs:
132106
echo "Running regression tests..."
133107
134108
echo " Testing 0_node.sql..."
135-
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)
109+
diff -b test/regression/0_node.out <(psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f sql/0_node.sql | grep Role)
136110
137111
echo " Testing p1_alignment_padding.sql..."
138-
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)
112+
diff -b test/regression/p1_alignment_padding.out <(psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f sql/p1_alignment_padding.sql | grep align)
139113
140114
echo " Testing a1_activity.sql..."
141-
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)
115+
diff -b test/regression/a1_activity.out <(psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f sql/a1_activity.sql | grep User)
142116
143117
echo "✅ All regression tests passed"
144118

0 commit comments

Comments
 (0)