Migrate to GitHub Actions with PostgreSQL 13-18 testing and minimal privilege support #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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_HOST_AUTH_METHOD: trust | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| -c shared_preload_libraries=pg_stat_statements | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install PostgreSQL client | |
| run: | | |
| # Install default PostgreSQL client (works for all versions) | |
| sudo apt-get update | |
| sudo apt-get install -y postgresql-client | |
| # Verify installation | |
| psql --version | |
| - name: Prepare test database | |
| run: | | |
| # Wait for PostgreSQL to be ready | |
| until pg_isready -h localhost -p 5432 -U postgres; do | |
| echo "Waiting for postgres..." | |
| sleep 2 | |
| done | |
| # Check PostgreSQL version | |
| psql -h localhost -U postgres -d test -c 'SELECT version();' | |
| # Create extensions | |
| psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' | |
| psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' | |
| # Verify extensions | |
| psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension ORDER BY extname;' | |
| # Create test tables (exactly as in CircleCI) | |
| 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);" | |
| 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 | |
| echo "Testing all SQL files in wide mode..." | |
| for f in sql/*; do | |
| echo " Testing $f..." | |
| if ! psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then | |
| echo "❌ FAILED: $f in wide mode" | |
| echo "Error output:" | |
| psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" | |
| exit 1 | |
| fi | |
| done | |
| echo "✅ All tests passed in wide mode" | |
| - name: Test normal mode | |
| run: | | |
| echo "\set postgres_dba_wide false" > ~/.psqlrc | |
| echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc | |
| echo "Testing all SQL files in normal mode..." | |
| for f in sql/*; do | |
| echo " Testing $f..." | |
| if ! psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then | |
| echo "❌ FAILED: $f in normal mode" | |
| echo "Error output:" | |
| psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" | |
| exit 1 | |
| fi | |
| done | |
| echo "✅ All tests passed in normal mode" | |
| - name: Run regression tests | |
| run: | | |
| echo "\set postgres_dba_wide false" > ~/.psqlrc | |
| echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc | |
| echo "Running regression tests..." | |
| echo " Testing 0_node.sql..." | |
| 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) | |
| echo " Testing p1_alignment_padding.sql..." | |
| 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) | |
| echo " Testing a1_activity.sql..." | |
| 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) | |
| echo "✅ All regression tests passed" | |