diff --git a/.github/workflows/hk.yml b/.github/workflows/audit.yml similarity index 58% rename from .github/workflows/hk.yml rename to .github/workflows/audit.yml index 18666ef..6e3b4e5 100644 --- a/.github/workflows/hk.yml +++ b/.github/workflows/audit.yml @@ -1,26 +1,22 @@ -name: hk +name: Audit on: - pull_request: - push: - branches: - - main schedule: - cron: "23 7 * * *" - workflow_dispatch: - -permissions: - contents: read concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.run_id }} + cancel-in-progress: false + +permissions: {} jobs: - check: - name: Check + audit-dependencies: + name: Audit dependencies runs-on: ubuntu-latest timeout-minutes: 30 + permissions: + contents: read steps: - name: Check out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -29,11 +25,7 @@ jobs: persist-credentials: false - name: Install tools uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10 - - name: Check and generate the ToolConfig files + - name: Check and generate ToolConfig files uses: mathematic-inc/toolconfig-action@1baf7b021e8bf6f0e20737753c13af0fc93c8570 # v2026.11.0 - name: Audit dependencies - if: github.event_name == 'schedule' run: cargo-deny --locked --workspace check - - name: Run checks - if: github.event_name != 'schedule' - run: hk check --all --slow --skip-step toolconfig diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd9844e..5f1d4f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,21 +7,40 @@ on: workflow_dispatch: concurrency: - group: ci-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} -permissions: - contents: read +permissions: {} jobs: - msrv: - name: Rust 1.94.0 + check: + name: Check runs-on: ubuntu-latest timeout-minutes: 30 permissions: contents: read steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: Install tools + uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10 + - name: Check and generate ToolConfig files + uses: mathematic-inc/toolconfig-action@1baf7b021e8bf6f0e20737753c13af0fc93c8570 # v2026.11.0 + - name: Run checks + run: hk check --all --slow --skip-step toolconfig + + check-msrv: + name: Check MSRV + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + steps: + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -37,6 +56,7 @@ jobs: run: rustup run 1.94.0 cargo test --locked -p sqlc-gen-sqlx --all-features --lib --test codegen test: + name: Test runs-on: ubuntu-latest timeout-minutes: 30 permissions: @@ -57,7 +77,8 @@ jobs: --health-retries 5 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -66,12 +87,12 @@ jobs: with: sqlc-version: "1.31.1" - - name: Install Rust stable + - name: Install Rust uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: targets: wasm32-wasip1 - - name: Snapshot tests + - name: Run snapshot tests run: cargo test --workspace env: INSTA_UPDATE: unseen @@ -79,7 +100,7 @@ jobs: - name: Build WASM plugin run: cargo build --target wasm32-wasip1 - - name: Integration tests + - name: Run integration tests run: cargo test -p basic env: DATABASE_URL: postgres://sqlc:sqlc@localhost:5432/sqlc_test @@ -87,13 +108,15 @@ jobs: - name: Verify package run: cargo package --locked - proto-check: + check-protos: + name: Check protos runs-on: ubuntu-latest timeout-minutes: 15 permissions: contents: read steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -102,7 +125,7 @@ jobs: with: install_args: toolconfig - - name: Check and generate the ToolConfig files + - name: Check and generate ToolConfig files uses: mathematic-inc/toolconfig-action@1baf7b021e8bf6f0e20737753c13af0fc93c8570 # v2026.11.0 - name: Install buf @@ -120,7 +143,29 @@ jobs: git diff --exit-code -- src prebuilt: + name: Verify prebuilt distribution permissions: contents: read - name: Verify prebuilt distribution uses: $/.github/workflows/prebuilt.yml + + required: + name: required + if: always() + needs: + - check + - check-msrv + - test + - check-protos + - prebuilt + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: {} + steps: + - name: Check every other job passed + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + env: + NEEDS: ${{ toJSON(needs) }} + run: | + jq -r 'to_entries[] | "\(.key): \(.value.result)"' <<< "$NEEDS" + echo "::error::A job failed or was cancelled." + exit 1 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 97274c3..43176c0 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -8,13 +8,12 @@ on: - cron: "0 6 * * 1" workflow_dispatch: -permissions: - contents: read - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} +permissions: {} + jobs: analyze: name: Analyze (${{ matrix.language }}) @@ -28,18 +27,18 @@ jobs: matrix: language: [actions, rust] steps: - - name: Checkout + - name: Check out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - name: Install Rust toolchain + - name: Install Rust if: matrix.language == 'rust' uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: toolchain: stable - - name: Cache cargo artifacts + - name: Restore Cargo cache if: matrix.language == 'rust' uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 @@ -50,7 +49,7 @@ jobs: languages: ${{ matrix.language }} queries: security-extended - - name: Perform CodeQL Analysis + - name: Perform CodeQL analysis uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 with: category: /language:${{ matrix.language }} diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-gate.yml similarity index 69% rename from .github/workflows/dependabot-automerge.yml rename to .github/workflows/dependabot-gate.yml index c3f0876..ad40f50 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-gate.yml @@ -1,4 +1,4 @@ -name: Dependabot strict gate +name: Dependabot gate on: pull_request: @@ -6,15 +6,15 @@ on: push: branches: [main] -permissions: {} - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} +permissions: {} + jobs: - strict-gate: - name: Strict Dependabot gate + dependabot-gate: + name: Dependabot gate runs-on: ubuntu-24.04 timeout-minutes: 90 permissions: @@ -27,7 +27,7 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number }} PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} steps: - - name: Require successful checks on the exact Dependabot head + - name: Require successful checks on exact Dependabot head run: | set -euo pipefail if [[ "$GITHUB_EVENT_NAME" != pull_request || "$PR_AUTHOR" != 'dependabot[bot]' ]]; then @@ -44,28 +44,26 @@ jobs: checks=$(gh api "repos/$GITHUB_REPOSITORY/commits/$PR_HEAD_SHA/check-runs?per_page=100") if jq -e ' - .total_count <= 100 and - (.check_runs - | group_by([.name, .app.id]) - | map(max_by([.started_at, .id]))) as $runs - | ([ - ["test", 15368], - ["proto-check", 15368], - ["Check", 15368], + .total_count as $total + | (.check_runs + | group_by([.name, .app.id]) + | map(max_by([.started_at, .id]))) as $runs + | $total <= 100 + and ([ + ["required", 15368], ["CodeQL", 57789], - ["Rust 1.94.0", 15368], ["Analyze (actions)", 15368], ["Analyze (rust)", 15368] ] | all(.[]; . as $required | ($runs | map(select(.name == $required[0] and .app.id == $required[1]))) as $found | ($found | length > 0 and all(.[]; .status == "completed" and .conclusion == "success")) )) - and ($runs | all(.[]; - .name == "Strict Dependabot gate" or - ((.name | startswith("Verify prebuilt distribution / Install without compiling")) and - .status == "completed" and .conclusion == "skipped") or - (.status == "completed" and .conclusion == "success") - )) + and ($runs | all(.[]; + .name == "Dependabot gate" or + ((.name | startswith("Verify prebuilt distribution / Install without compiling")) and + .status == "completed" and .conclusion == "skipped") or + (.status == "completed" and .conclusion == "success") + )) ' <<< "$checks" > /dev/null; then echo "All exact-head checks passed on $PR_HEAD_SHA." exit 0 diff --git a/.github/workflows/prebuilt.yml b/.github/workflows/prebuilt.yml index 0b76195..95e707b 100644 --- a/.github/workflows/prebuilt.yml +++ b/.github/workflows/prebuilt.yml @@ -1,17 +1,13 @@ -name: Prebuilt binaries +name: Prebuilt on: workflow_call: inputs: - ref: - type: string - default: "" verify-install: type: boolean default: false -permissions: - contents: read +permissions: {} defaults: run: @@ -27,9 +23,9 @@ env: jobs: build: if: ${{ !inputs.verify-install }} + name: Build (${{ matrix.target }}) permissions: contents: read - name: Build ${{ matrix.target }} runs-on: ${{ matrix.build_runner }} timeout-minutes: 90 strategy: @@ -61,15 +57,17 @@ jobs: runner: windows-11-arm build_runner: windows-11-arm steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - ref: ${{ inputs.ref || github.sha }} - - uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 + - name: Install tools + uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 with: install_args: rust cache: false - - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 + - name: Restore Cargo cache + uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 with: key: release-${{ matrix.target }} - name: Install Linux build dependencies @@ -112,25 +110,27 @@ jobs: shasum -a 256 "$archive" > "$archive.sha256" fi done - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + - name: Upload binary archive + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: binary-${{ matrix.target }} path: dist/* if-no-files-found: error - smoke: + test-archive: + name: Test archive (${{ matrix.target }}) if: ${{ !inputs.verify-install }} + needs: build permissions: contents: read - needs: build - name: Run archive ${{ matrix.target }} runs-on: ${{ matrix.runner }} timeout-minutes: 15 strategy: fail-fast: false matrix: *targets steps: - - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + - name: Download binary archive + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: binary-${{ matrix.target }} path: dist @@ -166,21 +166,22 @@ jobs: test -s smoke.out install: + name: Install without compiling (${{ matrix.target }}) if: inputs.verify-install permissions: contents: read - name: Install without compiling ${{ matrix.target }} runs-on: ${{ matrix.runner }} timeout-minutes: 15 strategy: fail-fast: false matrix: *targets steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - ref: ${{ inputs.ref || github.sha }} - - uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 + - name: Install tools + uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 with: install_args: cargo-binstall cache: false diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index bc36610..3f2f9fd 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -4,15 +4,15 @@ on: push: branches: [main] -permissions: - contents: read - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: false +permissions: {} + jobs: release-please: + name: Release Please environment: release permissions: contents: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03dbd91..8415c1f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,21 +5,17 @@ on: tags: - v* workflow_dispatch: - inputs: - tag: - description: Existing release tag to publish - required: true - type: string concurrency: - group: release-${{ github.workflow }}-${{ inputs.tag || github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: false -permissions: - contents: read +permissions: {} jobs: - verify: + verify-release: + name: Verify release + if: github.ref_type == 'tag' runs-on: ubuntu-latest timeout-minutes: 30 permissions: @@ -40,17 +36,17 @@ jobs: --health-retries 5 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - ref: ${{ inputs.tag || github.ref }} - name: Install sqlc uses: sqlc-dev/setup-sqlc@bac53b7fb28c039a6c7f5736fd1e89744021bdd6 # v5.0.0 with: sqlc-version: "1.31.1" - - name: Install Rust stable + - name: Install Rust uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: targets: wasm32-wasip1 @@ -61,16 +57,16 @@ jobs: install_args: toolconfig cache: false - - name: Check and generate the ToolConfig files + - name: Check and generate ToolConfig files uses: mathematic-inc/toolconfig-action@1baf7b021e8bf6f0e20737753c13af0fc93c8570 # v2026.11.0 - - name: Format check + - name: Check formatting run: cargo fmt --all --check - - name: Clippy + - name: Run Clippy run: cargo clippy --workspace --all-targets -- -D warnings - - name: Snapshot tests + - name: Run snapshot tests run: cargo test --workspace env: INSTA_UPDATE: unseen @@ -78,22 +74,22 @@ jobs: - name: Build release WASM plugin run: cargo build --release --target wasm32-wasip1 - - name: Integration tests + - name: Run integration tests run: cargo test -p basic env: DATABASE_URL: postgres://sqlc:sqlc@localhost:5432/sqlc_test prebuilt: + name: Build prebuilt binaries + needs: verify-release permissions: contents: read - needs: verify uses: $/.github/workflows/prebuilt.yml - with: - ref: ${{ inputs.tag || github.sha }} publish-release: + name: Publish GitHub release environment: release - needs: [verify, prebuilt] + needs: [verify-release, prebuilt] runs-on: ubuntu-latest timeout-minutes: 15 permissions: @@ -101,14 +97,14 @@ jobs: id-token: write attestations: write env: - RELEASE_TAG: ${{ inputs.tag || github.ref_name }} + RELEASE_TAG: ${{ github.ref_name }} steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - ref: ${{ inputs.tag || github.ref }} - name: Download native archives uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 @@ -117,7 +113,7 @@ jobs: path: dist merge-multiple: true - - name: Install Rust stable + - name: Install Rust uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: targets: wasm32-wasip1 @@ -179,13 +175,12 @@ jobs: id-token: write steps: - - name: Checkout + - name: Check out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - ref: ${{ inputs.tag || github.ref }} - - name: Install Rust toolchain + - name: Install Rust uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: toolchain: stable @@ -200,11 +195,10 @@ jobs: CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }} verify-install: + name: Verify published installations + needs: publish-crate permissions: contents: read - name: Verify published installations - needs: [publish-crate] uses: $/.github/workflows/prebuilt.yml with: verify-install: true - ref: ${{ inputs.tag || github.sha }}