-
Notifications
You must be signed in to change notification settings - Fork 138
Migrate to GitHub Actions with PostgreSQL 13-18 testing and minimal privilege support #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NikolayS
merged 29 commits into
master
from
cursor/add-postgres-version-tests-to-github-actions-42e4
Sep 29, 2025
Merged
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
1b515b9
Add GitHub Actions workflow for testing PostgreSQL versions 13-17 and…
cursoragent e3be4b2
Improve GitHub Actions workflow for PostgreSQL testing
cursoragent b57de9f
Simplify GitHub Actions workflow for PostgreSQL testing
cursoragent d189092
Improve PostgreSQL configuration and error handling in CI workflow
cursoragent ab11877
Update CI to test multiple PostgreSQL versions with improved configur…
cursoragent be6de78
Update GitHub Actions to test PostgreSQL 13-17 and remove CircleCI
NikolayS 37070d9
Fix GitHub Actions PostgreSQL configuration and test execution
NikolayS 704f6b4
Fix PostgreSQL client installation for all versions
NikolayS e81f250
Simplify PostgreSQL client installation to fix version compatibility
NikolayS 17c73b8
Fix GitHub Actions PostgreSQL client installation and remove beta ver…
NikolayS 14f253e
Fix PostgreSQL configuration by running pg_ctl as postgres user
NikolayS 0db8d88
Simplify PostgreSQL configuration using environment variables
NikolayS 46d4be1
Fix Docker options and PostgreSQL configuration
NikolayS 1717ff9
Fix PostgreSQL version compatibility issues
NikolayS 9a33eeb
Fix PostgreSQL version detection using server_version_num
NikolayS 51b1b7d
Use functions to handle PostgreSQL 17 version differences
NikolayS 0c49aae
Remove final CircleCI reference from workflow
NikolayS 68b1299
Update CHANGELOG for version 18.0 release
NikolayS 59431c6
Remove CHANGELOG.md
NikolayS 79b9a0c
Remove DDL functions and use informational messages for PG17+
NikolayS bea1d00
Test with minimal privileges (pg_monitor) and add PostgreSQL 18 beta
NikolayS 856941a
Add PostgreSQL 18 stable to test matrix
NikolayS 364184a
Fix PostgreSQL 17/18 compatibility using WHERE clauses
NikolayS 7cd6072
Remove checkpoint statistics queries to ensure compatibility
NikolayS 4c3bc28
Implement proper checkpoint statistics for PostgreSQL 17+
NikolayS 1980cef
Fix binary units usage in checkpoint statistics
NikolayS 0bafa64
Add supported PostgreSQL versions section to README
NikolayS ac89209
Update README to reference postgres_ai monitoring platform
NikolayS 1d47ee5
Add backticks formatting for pg_stat_checkpointer in README
NikolayS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| 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', '18'] | ||
| fail-fast: false | ||
|
|
||
| services: | ||
| postgres: | ||
| image: postgres:${{ matrix.postgres-version }} | ||
| env: | ||
| POSTGRES_PASSWORD: postgres | ||
| POSTGRES_DB: test | ||
| POSTGRES_HOST_AUTH_METHOD: trust | ||
| POSTGRES_INITDB_ARGS: --auth-host=trust --auth-local=trust | ||
| 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: | | ||
| # 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 (pg_stat_statements may not work without shared_preload_libraries) | ||
| psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' || echo "Warning: pg_stat_statements extension not available" | ||
| psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' | ||
| # Create minimal privilege user for testing | ||
| psql -h localhost -U postgres -d test -c "CREATE USER dba_user;" | ||
| psql -h localhost -U postgres -d test -c "GRANT pg_monitor TO dba_user;" | ||
| psql -h localhost -U postgres -d test -c "GRANT CONNECT ON DATABASE test TO dba_user;" | ||
| psql -h localhost -U postgres -d test -c "GRANT USAGE ON SCHEMA public TO dba_user;" | ||
| # Verify extensions | ||
| psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension ORDER BY extname;' | ||
| # Create test tables for alignment testing (as superuser) | ||
| 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);" | ||
| # Grant access to test tables for dba_user | ||
| psql -h localhost -U postgres -d test -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO dba_user;" | ||
| # Test connection as dba_user | ||
| psql -h localhost -U dba_user -d test -c 'SELECT current_user, session_user;' | ||
| - 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 with minimal privileges..." | ||
| for f in sql/*; do | ||
| echo " Testing $f..." | ||
| if ! psql -h localhost -U dba_user -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 dba_user -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 with minimal privileges..." | ||
| for f in sql/*; do | ||
| echo " Testing $f..." | ||
| if ! psql -h localhost -U dba_user -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 dba_user -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 with minimal privileges..." | ||
| echo " Testing 0_node.sql..." | ||
| OUTPUT=$(psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/0_node.sql | grep Role) | ||
| if [[ "$OUTPUT" == *"Master"* ]]; then | ||
| echo " ✓ Role test passed" | ||
| else | ||
| echo " ✗ Role test failed: $OUTPUT" | ||
| exit 1 | ||
| fi | ||
| echo " Testing p1_alignment_padding.sql..." | ||
| OUTPUT=$(psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) | ||
| if [[ "$OUTPUT" == *"align1"* && "$OUTPUT" == *"align2"* && "$OUTPUT" == *"int4, more, int8"* ]]; then | ||
| echo " ✓ Alignment padding test passed" | ||
| else | ||
| echo " ✗ Alignment padding test failed: $OUTPUT" | ||
| exit 1 | ||
| fi | ||
| echo " Testing a1_activity.sql..." | ||
| OUTPUT=$(psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/a1_activity.sql | grep User) | ||
| if [[ "$OUTPUT" == *"User"* ]]; then | ||
| echo " ✓ Activity test passed" | ||
| else | ||
| echo " ✗ Activity test failed: $OUTPUT" | ||
| exit 1 | ||
| fi | ||
| echo "✅ All regression tests passed with minimal privileges" | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ For Postgres versions older than 10, run this first: | |
| \set postgres_dba_is_wal_replay_paused pg_is_xlog_replay_paused | ||
| */ | ||
|
|
||
|
|
||
| with data as ( | ||
| select s.* | ||
| from pg_stat_database s | ||
|
|
@@ -50,26 +51,38 @@ select 'Uptime', (now() - pg_postmaster_start_time())::interval(0)::text | |
| union all | ||
| select | ||
| 'Checkpoints', | ||
NikolayS marked this conversation as resolved.
Show resolved
Hide resolved
NikolayS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (select (checkpoints_timed + checkpoints_req)::text from pg_stat_bgwriter) | ||
| case | ||
| when current_setting('server_version_num')::int >= 170000 | ||
| then 'See pg_stat_checkpointer (PG17+)' | ||
NikolayS marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else (select (checkpoints_timed + checkpoints_req)::text from pg_stat_bgwriter) | ||
| end | ||
| union all | ||
| select | ||
| 'Forced Checkpoints', | ||
| ( | ||
| select round(100.0 * checkpoints_req::numeric / | ||
| (nullif(checkpoints_timed + checkpoints_req, 0)), 1)::text || '%' | ||
| from pg_stat_bgwriter | ||
| ) | ||
| case | ||
| when current_setting('server_version_num')::int >= 170000 | ||
| then 'See pg_stat_checkpointer (PG17+)' | ||
|
||
| else ( | ||
| select round(100.0 * checkpoints_req::numeric / | ||
| (nullif(checkpoints_timed + checkpoints_req, 0)), 1)::text || '%' | ||
| from pg_stat_bgwriter | ||
| ) | ||
| end | ||
| union all | ||
| select | ||
| 'Checkpoint MB/sec', | ||
| ( | ||
| select round((nullif(buffers_checkpoint::numeric, 0) / | ||
| ((1024.0 * 1024 / | ||
| (current_setting('block_size')::numeric)) | ||
| * extract('epoch' from now() - stats_reset) | ||
| ))::numeric, 6)::text | ||
| from pg_stat_bgwriter | ||
| ) | ||
| case | ||
| when current_setting('server_version_num')::int >= 170000 | ||
| then 'See pg_stat_checkpointer (PG17+)' | ||
NikolayS marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else ( | ||
| select round((nullif(buffers_checkpoint::numeric, 0) / | ||
| ((1024.0 * 1024 / | ||
| (current_setting('block_size')::numeric)) | ||
| * extract('epoch' from now() - stats_reset) | ||
| ))::numeric, 6)::text | ||
| from pg_stat_bgwriter | ||
| ) | ||
| end | ||
| union all | ||
| select repeat('-', 33), repeat('-', 88) | ||
| union all | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow SQL code style (check .cursor)