Skip to content

Commit e3be4b2

Browse files
cursoragentNikolayS
andcommitted
Improve GitHub Actions workflow for PostgreSQL testing
Co-authored-by: nik <[email protected]>
1 parent 1b515b9 commit e3be4b2

File tree

1 file changed

+39
-38
lines changed

1 file changed

+39
-38
lines changed

.github/workflows/test.yml

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
env:
2222
POSTGRES_PASSWORD: postgres
2323
POSTGRES_DB: test
24+
POSTGRES_USER: postgres
2425
options: >-
2526
--health-cmd pg_isready
2627
--health-interval 10s
@@ -36,58 +37,56 @@ jobs:
3637
- name: Install PostgreSQL client
3738
run: |
3839
sudo apt-get update
39-
sudo apt-get install -y postgresql-client-${{ matrix.postgres-version }}
40+
sudo apt-get install -y postgresql-client
41+
42+
- name: Wait for PostgreSQL to be ready
43+
run: |
44+
until pg_isready -h localhost -p 5432 -U postgres; do
45+
echo "Waiting for postgres..."
46+
sleep 2
47+
done
4048
4149
- name: Prepare test database
4250
run: |
43-
export PGPASSWORD=postgres
44-
psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
45-
psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
46-
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);"
47-
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);"
48-
env:
49-
PGPASSWORD: postgres
51+
# Create extensions (they need to be created by superuser)
52+
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
53+
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
54+
55+
# Create test tables
56+
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);"
57+
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);"
5058
5159
- name: Test wide mode
5260
run: |
53-
export PGPASSWORD=postgres
5461
echo "\set postgres_dba_wide true" > ~/.psqlrc
5562
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
5663
for f in sql/*; do
5764
echo "Testing $f in wide mode..."
58-
psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
65+
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
5966
done
60-
env:
61-
PGPASSWORD: postgres
6267
6368
- name: Test normal mode
6469
run: |
65-
export PGPASSWORD=postgres
6670
echo "\set postgres_dba_wide false" > ~/.psqlrc
6771
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
6872
for f in sql/*; do
6973
echo "Testing $f in normal mode..."
70-
psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
74+
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
7175
done
72-
env:
73-
PGPASSWORD: postgres
7476
7577
- name: Run regression tests
7678
run: |
77-
export PGPASSWORD=postgres
7879
echo "\set postgres_dba_wide false" > ~/.psqlrc
7980
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
8081
8182
echo "Running regression test for 0_node.sql..."
82-
diff -b test/regression/0_node.out <(psql -h localhost -U postgres -d test -f warmup.psql -f sql/0_node.sql | grep Role)
83+
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)
8384
8485
echo "Running regression test for p1_alignment_padding.sql..."
85-
diff -b test/regression/p1_alignment_padding.out <(psql -h localhost -U postgres -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align)
86+
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)
8687
8788
echo "Running regression test for a1_activity.sql..."
88-
diff -b test/regression/a1_activity.out <(psql -h localhost -U postgres -d test -f warmup.psql -f sql/a1_activity.sql | grep User)
89-
env:
90-
PGPASSWORD: postgres
89+
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)
9190
9291
test-beta:
9392
runs-on: ubuntu-latest
@@ -103,6 +102,7 @@ jobs:
103102
env:
104103
POSTGRES_PASSWORD: postgres
105104
POSTGRES_DB: test
105+
POSTGRES_USER: postgres
106106
options: >-
107107
--health-cmd pg_isready
108108
--health-interval 10s
@@ -121,36 +121,37 @@ jobs:
121121
# Install latest PostgreSQL client for beta testing
122122
sudo apt-get install -y postgresql-client
123123
124+
- name: Wait for PostgreSQL to be ready
125+
run: |
126+
until pg_isready -h localhost -p 5432 -U postgres; do
127+
echo "Waiting for postgres..."
128+
sleep 2
129+
done
130+
124131
- name: Prepare test database
125132
run: |
126-
export PGPASSWORD=postgres
127-
psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
128-
psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
129-
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);"
130-
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);"
131-
env:
132-
PGPASSWORD: postgres
133+
# Create extensions (they need to be created by superuser)
134+
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
135+
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
136+
137+
# Create test tables
138+
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);"
139+
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);"
133140
134141
- name: Test wide mode (beta)
135142
run: |
136-
export PGPASSWORD=postgres
137143
echo "\set postgres_dba_wide true" > ~/.psqlrc
138144
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
139145
for f in sql/*; do
140146
echo "Testing $f in wide mode (PostgreSQL 18 beta)..."
141-
psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
147+
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
142148
done
143-
env:
144-
PGPASSWORD: postgres
145149
146150
- name: Test normal mode (beta)
147151
run: |
148-
export PGPASSWORD=postgres
149152
echo "\set postgres_dba_wide false" > ~/.psqlrc
150153
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
151154
for f in sql/*; do
152155
echo "Testing $f in normal mode (PostgreSQL 18 beta)..."
153-
psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
154-
done
155-
env:
156-
PGPASSWORD: postgres
156+
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
157+
done

0 commit comments

Comments
 (0)