diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 029fb38eb..2f869d99c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -4,9 +4,44 @@ on: push: branches: - "master" +# A new push to a pull request supersedes the run of the push before it. Pushes to master are never grouped, so +# each of those runs to completion. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true env: NODE_VERSION: "22.23.4" jobs: + # The SVM test jobs run their tests only when something they depend on changed. + svm-changes: + name: Detect SVM changes + runs-on: ubuntu-latest + outputs: + svm: ${{ steps.filter.outputs.svm }} + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Check which paths changed + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + svm: + - 'Anchor.toml' + - 'verified-build.json' + - 'Cargo.toml' + - 'Cargo.lock' + - 'package.json' + - 'yarn.lock' + - '.github/actions/setup-solana-anchor/**' + - '.github/workflows/pr.yml' + - 'programs/**' + - 'idls/**' + - 'scripts/svm/**' + - 'src/svm/**' + - 'test/svm/**' + - 'test/svm-gateway/**' + - 'test/svm-production/**' # Multiple jobs depend on having EVM and SVM artifacts available, so we upload them first in separate jobs. upload-svm-artifacts: name: Upload SVM artifacts @@ -121,7 +156,9 @@ jobs: fi test-svm-verified: name: Test verified SVM build - needs: upload-svm-artifacts + needs: + - upload-svm-artifacts + - svm-changes runs-on: ubuntu-latest steps: - name: Checkout repo @@ -137,27 +174,6 @@ jobs: uses: ./.github/actions/setup-solana-anchor with: node_version: ${{ env.NODE_VERSION }} - - name: Check which paths changed - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - svm: - - 'Anchor.toml' - - 'verified-build.json' - - 'Cargo.toml' - - 'Cargo.lock' - - 'package.json' - - 'yarn.lock' - - '.github/actions/setup-solana-anchor/**' - - '.github/workflows/pr.yml' - - 'programs/**' - - 'idls/**' - - 'scripts/svm/**' - - 'src/svm/**' - - 'test/svm/**' - - 'test/svm-gateway/**' - - 'test/svm-production/**' - name: Download SVM artifacts uses: actions/download-artifact@v4 with: @@ -181,18 +197,46 @@ jobs: env: IS_TEST: true run: yarn build-svm-solana-verify - # Docker may create deploy/ as root. The later production build must be able to remove stale test binaries. + # Docker may create deploy/ as root, and the tests below run as the runner's user. - name: Restore verified artifact ownership - if: steps.filter.outputs.svm == 'true' + if: needs.svm-changes.outputs.svm == 'true' run: sudo chown -R "$(id -u):$(id -g)" target/deploy - name: Archive verified test build (for caching) if: steps.verified-test-build-cache.outputs.cache-hit != 'true' run: tar -cf svm-verified-test-binaries.tar target/deploy - name: Test verified SVM build - if: steps.filter.outputs.svm == 'true' + if: needs.svm-changes.outputs.svm == 'true' run: anchor test --skip-build --validator legacy + # A job of its own, so that it runs beside the validator tests above and not after them. It builds the production + # binaries itself, and shares nothing with that job's test-feature build. + test-svm-production: + name: Test production SVM binary + needs: + - upload-svm-artifacts + - svm-changes + # Nothing here has to run when the SVM paths are unchanged, so the whole job is skipped. + if: needs.svm-changes.outputs.svm == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: "Use Node ${{ env.NODE_VERSION }}" + uses: actions/setup-node@v3 + with: + node-version: "${{ env.NODE_VERSION }}" + cache: yarn + - name: Install packages + run: yarn install --frozen-lockfile --ignore-optional + - name: Setup Anchor & Solana + uses: ./.github/actions/setup-solana-anchor + with: + node_version: ${{ env.NODE_VERSION }} + # As in the job above, the generated IDLs and types are in place before the Docker build writes to target/. + - name: Download SVM artifacts + uses: actions/download-artifact@v4 + with: + name: svm-artifacts-${{ runner.os }}-node-${{ env.NODE_VERSION }} - name: Test verified production binary in a fresh ledger - if: steps.filter.outputs.svm == 'true' run: yarn test-svm-production build-ts: name: Build TypeScript