diff --git a/.github/workflows/integration-pg-matrix.yml b/.github/workflows/integration-pg-matrix.yml index 638fc89..f059514 100644 --- a/.github/workflows/integration-pg-matrix.yml +++ b/.github/workflows/integration-pg-matrix.yml @@ -2,7 +2,7 @@ name: Python + pgTAP Integration (PG15-PG18) on: workflow_dispatch: - pull_request: + pull_request_target: types: [opened, synchronize] paths: - pgFirstAid.sql @@ -18,7 +18,6 @@ concurrency: jobs: integration: - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false runs-on: [self-hosted, nix, nixos, x86_64-linux] permissions: contents: read @@ -49,6 +48,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 1 + ref: ${{ github.event.pull_request.head.sha || github.ref }} - name: Add Nix profile paths run: | diff --git a/.github/workflows/neon-before-after-validate.yml b/.github/workflows/neon-before-after-validate.yml index 6544d13..adbd875 100644 --- a/.github/workflows/neon-before-after-validate.yml +++ b/.github/workflows/neon-before-after-validate.yml @@ -32,7 +32,7 @@ # NEON_PROJECT_ID -- from your Neon project's Settings page # # Change files: -# When triggered on pull_request, the workflow auto-discovers .sql files +# When triggered on pull_request_target, the workflow auto-discovers .sql files # under migrations/ and applies them as the change. For app or infra # changes, use workflow_dispatch and either: # (a) pass your SQL files via the `change_files` input, or @@ -42,7 +42,7 @@ name: Neon Before/After Validation on: - pull_request: + pull_request_target: paths: - 'migrations/**' - 'pgFirstAid.sql' @@ -81,6 +81,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 + ref: ${{ github.event.pull_request.head.sha }} - name: Install PostgreSQL client run: | @@ -154,7 +155,7 @@ jobs: echo " Pre-change baseline captured above." echo "" echo " The change being tested:" - echo " ${{ github.event_name == 'pull_request' && format('PR #{0}', github.event.number) || 'manual dispatch' }}" + echo " ${{ github.event_name == 'pull_request_target' && format('PR #{0}', github.event.number) || 'manual dispatch' }}" echo "" echo " Now applying SQL changes..." echo "" @@ -231,7 +232,7 @@ jobs: fi - name: Post PR comment - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request_target' }} uses: actions/github-script@v7 with: script: | diff --git a/pgFirstAid.sql b/pgFirstAid.sql index fffb023..5d5bc13 100644 --- a/pgFirstAid.sql +++ b/pgFirstAid.sql @@ -571,6 +571,7 @@ from q where bloat_pct > 50.0 + and bloat_size > pg_size_bytes('10 MB') and schemaname not like all(array['information_schema', 'pg_catalog', 'pg_toast', 'pg_temp%']) order by quote_ident(schemaname), diff --git a/view_pgFirstAid.sql b/view_pgFirstAid.sql index 857dc68..c1e3ec5 100644 --- a/view_pgFirstAid.sql +++ b/view_pgFirstAid.sql @@ -545,7 +545,8 @@ from q where bloat_pct > 50.0 -and schemaname not like all(array['information_schema', 'pg_catalog', 'pg_toast', 'pg_temp%']) + and bloat_size > pg_size_bytes('10 MB') + and schemaname not like all(array['information_schema', 'pg_catalog', 'pg_toast', 'pg_temp%']) order by quote_ident(schemaname), quote_ident(tblname)) diff --git a/view_pgFirstAid_managed.sql b/view_pgFirstAid_managed.sql index e01fd93..17c6e88 100644 --- a/view_pgFirstAid_managed.sql +++ b/view_pgFirstAid_managed.sql @@ -549,7 +549,8 @@ from q where bloat_pct > 50.0 -and schemaname not like all(array['information_schema', 'pg_catalog', 'pg_toast', 'pg_temp%']) + and bloat_size > pg_size_bytes('10 MB') + and schemaname not like all(array['information_schema', 'pg_catalog', 'pg_toast', 'pg_temp%']) order by quote_ident(schemaname), quote_ident(tblname)) diff --git a/workflows/neon-before-after-validate.yml b/workflows/neon-before-after-validate.yml index 6544d13..adbd875 100644 --- a/workflows/neon-before-after-validate.yml +++ b/workflows/neon-before-after-validate.yml @@ -32,7 +32,7 @@ # NEON_PROJECT_ID -- from your Neon project's Settings page # # Change files: -# When triggered on pull_request, the workflow auto-discovers .sql files +# When triggered on pull_request_target, the workflow auto-discovers .sql files # under migrations/ and applies them as the change. For app or infra # changes, use workflow_dispatch and either: # (a) pass your SQL files via the `change_files` input, or @@ -42,7 +42,7 @@ name: Neon Before/After Validation on: - pull_request: + pull_request_target: paths: - 'migrations/**' - 'pgFirstAid.sql' @@ -81,6 +81,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 + ref: ${{ github.event.pull_request.head.sha }} - name: Install PostgreSQL client run: | @@ -154,7 +155,7 @@ jobs: echo " Pre-change baseline captured above." echo "" echo " The change being tested:" - echo " ${{ github.event_name == 'pull_request' && format('PR #{0}', github.event.number) || 'manual dispatch' }}" + echo " ${{ github.event_name == 'pull_request_target' && format('PR #{0}', github.event.number) || 'manual dispatch' }}" echo "" echo " Now applying SQL changes..." echo "" @@ -231,7 +232,7 @@ jobs: fi - name: Post PR comment - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request_target' }} uses: actions/github-script@v7 with: script: |