From 2d3131a634993420610177cd8ff16d21a216f48b Mon Sep 17 00:00:00 2001 From: maclane Date: Mon, 27 Jul 2026 15:21:18 -0400 Subject: [PATCH] ci(solidity): run contracts CI on stacked PRs, and filter it by path Both contracts workflows only triggered on `pull_request` targeting `main`, so a PR based on another branch got no solidity CI at all. Every PR in a stack is therefore unverified until the moment it is retargeted, which is the moment it merges -- the least useful time to find out. Opening the trigger alone would run both suites on every PR to the repo, including client-only Go changes, because `contracts-detect-changes` was a stub that echoed `path-filter=true` unconditionally. Worse, nothing consumed the output: none of the four jobs had an `if:` referencing it, so the filter has been decorative for as long as it has existed. So this does three things together, since any one alone is wrong: - drops the `branches: [main]` restriction, - replaces the stub with a real `dorny/paths-filter@v2` scoped to the package the workflow builds, matching the two contracts-*-docs workflows and client.yml, - adds the `if:` that actually consumes the result, in the form client.yml already uses, so `workflow_dispatch` runs continue to be unconditional. Filtering per package is safe: `ecdsa` depends on `@keep-network/random-beacon` through the npm `development` tag, not the local sources, so a random-beacon-only change cannot alter an ecdsa build. Deployment jobs are untouched. They gate on `github.event_name == 'workflow_dispatch'` and need `contracts-build-and-test`, which still runs unconditionally for that event. This PR edits both workflow files, so it exercises both filters. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/contracts-ecdsa.yml | 29 +++++++++++++++---- .github/workflows/contracts-random-beacon.yml | 29 +++++++++++++++---- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/.github/workflows/contracts-ecdsa.yml b/.github/workflows/contracts-ecdsa.yml index b3c4ecd237..9100d1b029 100644 --- a/.github/workflows/contracts-ecdsa.yml +++ b/.github/workflows/contracts-ecdsa.yml @@ -2,8 +2,6 @@ name: Solidity ECDSA on: pull_request: - branches: - - main # We intend to use `workflow dispatch` in two different situations/paths # 1. If a workflow will be manually dispatched from branch named # `dapp-development`, workflow will deploy the contracts on the selected @@ -35,14 +33,24 @@ jobs: contracts-detect-changes: runs-on: ubuntu-latest outputs: - path-filter: ${{ steps.set-output.outputs.path-filter }} + path-filter: ${{ steps.filter.outputs.path-filter }} steps: - - name: Set path-filter output - id: set-output - run: echo "path-filter=true" >> $GITHUB_OUTPUT + - uses: actions/checkout@v3 + if: github.event_name == 'pull_request' + - uses: dorny/paths-filter@v2 + if: github.event_name == 'pull_request' + id: filter + with: + filters: | + path-filter: + - './solidity/ecdsa/**' + - './.github/workflows/contracts-ecdsa.yml' contracts-lint: needs: contracts-detect-changes + if: | + github.event_name != 'pull_request' + || needs.contracts-detect-changes.outputs.path-filter == 'true' runs-on: ubuntu-latest defaults: run: @@ -69,6 +77,9 @@ jobs: contracts-slither: needs: contracts-detect-changes + if: | + github.event_name != 'pull_request' + || needs.contracts-detect-changes.outputs.path-filter == 'true' runs-on: ubuntu-latest defaults: run: @@ -111,6 +122,9 @@ jobs: contracts-build-and-test: needs: contracts-detect-changes + if: | + github.event_name != 'pull_request' + || needs.contracts-detect-changes.outputs.path-filter == 'true' runs-on: ubuntu-latest defaults: run: @@ -138,6 +152,9 @@ jobs: contracts-deployment-dry-run: needs: contracts-detect-changes + if: | + github.event_name != 'pull_request' + || needs.contracts-detect-changes.outputs.path-filter == 'true' runs-on: ubuntu-latest defaults: run: diff --git a/.github/workflows/contracts-random-beacon.yml b/.github/workflows/contracts-random-beacon.yml index a7be8c6eab..4ee7a24c3e 100644 --- a/.github/workflows/contracts-random-beacon.yml +++ b/.github/workflows/contracts-random-beacon.yml @@ -2,8 +2,6 @@ name: Solidity Random Beacon on: pull_request: - branches: - - main # We intend to use `workflow dispatch` in two different situations/paths: # 1. If a workflow will be manually dispatched from branch named # `dapp-development`, workflow will deploy the contracts on the selected @@ -35,14 +33,24 @@ jobs: contracts-detect-changes: runs-on: ubuntu-latest outputs: - path-filter: ${{ steps.set-output.outputs.path-filter }} + path-filter: ${{ steps.filter.outputs.path-filter }} steps: - - name: Set path-filter output - id: set-output - run: echo "path-filter=true" >> $GITHUB_OUTPUT + - uses: actions/checkout@v3 + if: github.event_name == 'pull_request' + - uses: dorny/paths-filter@v2 + if: github.event_name == 'pull_request' + id: filter + with: + filters: | + path-filter: + - './solidity/random-beacon/**' + - './.github/workflows/contracts-random-beacon.yml' contracts-lint: needs: contracts-detect-changes + if: | + github.event_name != 'pull_request' + || needs.contracts-detect-changes.outputs.path-filter == 'true' runs-on: ubuntu-latest defaults: run: @@ -69,6 +77,9 @@ jobs: contracts-slither: needs: contracts-detect-changes + if: | + github.event_name != 'pull_request' + || needs.contracts-detect-changes.outputs.path-filter == 'true' runs-on: ubuntu-latest defaults: run: @@ -109,6 +120,9 @@ jobs: contracts-build-and-test: needs: contracts-detect-changes + if: | + github.event_name != 'pull_request' + || needs.contracts-detect-changes.outputs.path-filter == 'true' runs-on: ubuntu-latest defaults: run: @@ -136,6 +150,9 @@ jobs: contracts-deployment-dry-run: needs: contracts-detect-changes + if: | + github.event_name != 'pull_request' + || needs.contracts-detect-changes.outputs.path-filter == 'true' runs-on: ubuntu-latest defaults: run: