Skip to content

Add postgres version tests to github actions #2

Add postgres version tests to github actions

Add postgres version tests to github actions #2

Workflow file for this run

name: Test PostgreSQL Versions
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
postgres-version: ['13', '14', '15', '16', '17']
fail-fast: false
services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
- name: Wait for PostgreSQL to be ready
run: |
until pg_isready -h localhost -p 5432 -U postgres; do
echo "Waiting for postgres..."
sleep 2
done
- name: Prepare test database
run: |
# Create extensions (they need to be created by superuser)
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
# Create test tables
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);"
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);"
- name: Test wide mode
run: |
echo "\set postgres_dba_wide true" > ~/.psqlrc
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
for f in sql/*; do
echo "Testing $f in wide mode..."
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
done
- name: Test normal mode
run: |
echo "\set postgres_dba_wide false" > ~/.psqlrc
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
for f in sql/*; do
echo "Testing $f in normal mode..."
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
done
- name: Run regression tests
run: |
echo "\set postgres_dba_wide false" > ~/.psqlrc
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
echo "Running regression test for 0_node.sql..."
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)
echo "Running regression test for p1_alignment_padding.sql..."
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)
echo "Running regression test for a1_activity.sql..."
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)
test-beta:
runs-on: ubuntu-latest
continue-on-error: true # Allow beta tests to fail without breaking CI
strategy:
matrix:
postgres-version: ['18-beta']
services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PostgreSQL client (beta)
run: |
sudo apt-get update
# Install latest PostgreSQL client for beta testing
sudo apt-get install -y postgresql-client
- name: Wait for PostgreSQL to be ready
run: |
until pg_isready -h localhost -p 5432 -U postgres; do
echo "Waiting for postgres..."
sleep 2
done
- name: Prepare test database
run: |
# Create extensions (they need to be created by superuser)
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;'
PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
# Create test tables
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);"
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);"
- name: Test wide mode (beta)
run: |
echo "\set postgres_dba_wide true" > ~/.psqlrc
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
for f in sql/*; do
echo "Testing $f in wide mode (PostgreSQL 18 beta)..."
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
done
- name: Test normal mode (beta)
run: |
echo "\set postgres_dba_wide false" > ~/.psqlrc
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
for f in sql/*; do
echo "Testing $f in normal mode (PostgreSQL 18 beta)..."
PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null
done