Skip to content

Commit b57de9f

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

File tree

1 file changed

+19
-102
lines changed

1 file changed

+19
-102
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -12,57 +12,41 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
postgres-version: ['13', '14', '15', '16', '17']
15+
test-name: ['postgres-dba-tests']
1616
fail-fast: false
1717

18-
services:
19-
postgres:
20-
image: postgres:${{ matrix.postgres-version }}
21-
env:
22-
POSTGRES_PASSWORD: postgres
23-
POSTGRES_DB: test
24-
POSTGRES_USER: postgres
25-
options: >-
26-
--health-cmd pg_isready
27-
--health-interval 10s
28-
--health-timeout 5s
29-
--health-retries 5
30-
ports:
31-
- 5432:5432
32-
3318
steps:
3419
- name: Checkout code
3520
uses: actions/checkout@v4
3621

37-
- name: Install PostgreSQL client
38-
run: |
39-
sudo apt-get update
40-
sudo apt-get install -y postgresql-client
41-
42-
- name: Wait for PostgreSQL to be ready
22+
- name: Start PostgreSQL and configure
4323
run: |
44-
until pg_isready -h localhost -p 5432 -U postgres; do
45-
echo "Waiting for postgres..."
46-
sleep 2
47-
done
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
26+
sudo systemctl start postgresql.service
27+
pg_isready
28+
29+
# Create runner user and test database
30+
sudo -u postgres createuser -s runner
31+
sudo -u postgres createdb test
4832
4933
- name: Prepare test database
5034
run: |
5135
# 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;'
36+
sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
37+
sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
5438
5539
# 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);"
40+
psql -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);"
41+
psql -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);"
5842
5943
- name: Test wide mode
6044
run: |
6145
echo "\set postgres_dba_wide true" > ~/.psqlrc
6246
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
6347
for f in sql/*; do
6448
echo "Testing $f in wide mode..."
65-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
49+
psql -d test -f warmup.psql -f "$f" > /dev/null
6650
done
6751
6852
- name: Test normal mode
@@ -71,7 +55,7 @@ jobs:
7155
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
7256
for f in sql/*; do
7357
echo "Testing $f in normal mode..."
74-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
58+
psql -d test -f warmup.psql -f "$f" > /dev/null
7559
done
7660
7761
- name: Run regression tests
@@ -80,78 +64,11 @@ jobs:
8064
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
8165
8266
echo "Running regression test for 0_node.sql..."
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)
67+
diff -b test/regression/0_node.out <(psql -d test -f warmup.psql -f sql/0_node.sql | grep Role)
8468
8569
echo "Running regression test for p1_alignment_padding.sql..."
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)
70+
diff -b test/regression/p1_alignment_padding.out <(psql -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align)
8771
8872
echo "Running regression test for a1_activity.sql..."
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)
73+
diff -b test/regression/a1_activity.out <(psql -d test -f warmup.psql -f sql/a1_activity.sql | grep User)
9074
91-
test-beta:
92-
runs-on: ubuntu-latest
93-
continue-on-error: true # Allow beta tests to fail without breaking CI
94-
95-
strategy:
96-
matrix:
97-
postgres-version: ['18-beta']
98-
99-
services:
100-
postgres:
101-
image: postgres:${{ matrix.postgres-version }}
102-
env:
103-
POSTGRES_PASSWORD: postgres
104-
POSTGRES_DB: test
105-
POSTGRES_USER: postgres
106-
options: >-
107-
--health-cmd pg_isready
108-
--health-interval 10s
109-
--health-timeout 5s
110-
--health-retries 5
111-
ports:
112-
- 5432:5432
113-
114-
steps:
115-
- name: Checkout code
116-
uses: actions/checkout@v4
117-
118-
- name: Install PostgreSQL client (beta)
119-
run: |
120-
sudo apt-get update
121-
# Install latest PostgreSQL client for beta testing
122-
sudo apt-get install -y postgresql-client
123-
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-
131-
- name: Prepare test database
132-
run: |
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);"
140-
141-
- name: Test wide mode (beta)
142-
run: |
143-
echo "\set postgres_dba_wide true" > ~/.psqlrc
144-
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
145-
for f in sql/*; do
146-
echo "Testing $f in wide mode (PostgreSQL 18 beta)..."
147-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
148-
done
149-
150-
- name: Test normal mode (beta)
151-
run: |
152-
echo "\set postgres_dba_wide false" > ~/.psqlrc
153-
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
154-
for f in sql/*; do
155-
echo "Testing $f in normal mode (PostgreSQL 18 beta)..."
156-
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
157-
done

0 commit comments

Comments
 (0)