From b093582ef786ace203ec170e5238d0c3ee726338 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 18 Sep 2026 16:39:36 +0000 Subject: [PATCH] ci: cancel superseded pull request runs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The per-job concurrency groups already cancelled a superseded job when its replacement was queued, but they cancelled pushes to the release branches the same way. Those runs publish coverage, and cancelling one also hides a breakage that is already on the branch. Replace them with a single workflow-level group. Only pull request runs share it; every other run gets `github.run_id`, a group of one, because a group holds at most one pending run and GitHub evicts that pending run whenever a newer one enters the group — `cancel-in-progress` protects the running run, not the queued one. Besides fixing that, one workflow-level group cancels the whole superseded run at once rather than job by job as each replacement is queued, it covers jobs that have no group of their own, and a matrix dimension added later cannot be forgotten in a group key. `release.yml` is untouched: its string-form group leaves `cancel-in-progress` false, so releases queue rather than cancel. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_016aGHrb1YaEvaGwNELGEHjF --- .github/workflows/nodejs.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 51ffc32..3bac1ac 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -8,6 +8,18 @@ on: branches: - main +# A new commit supersedes the previous one's jobs, so stop paying for them +# across the whole matrix below. Only pull request runs share a group; every +# other run gets a group of its own (`github.run_id`), because a group holds +# at most one pending run and a later push would otherwise evict the one +# waiting — `cancel-in-progress` protects the running run, not the queued one. +# Runs for the branches this also builds on push publish the coverage later +# comparisons are measured against, and losing one would also hide a breakage +# that is already on the branch. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: lint: name: Lint - ${{ matrix.os }} - Node v${{ matrix.node-version }} @@ -18,9 +30,6 @@ jobs: os: [ubuntu-latest] node-version: [lts/*] runs-on: ${{ matrix.os }} - concurrency: - group: lint-${{ matrix.os }}-v${{ matrix.node-version }}-${{ github.ref }} - cancel-in-progress: true steps: - uses: actions/checkout@v4 with: @@ -47,9 +56,6 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] node-version: [10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x, 26.x] runs-on: ${{ matrix.os }} - concurrency: - group: test-${{ matrix.os }}-v${{ matrix.node-version }}-${{ github.ref }} - cancel-in-progress: true steps: - name: Setup Git if: matrix.os == 'windows-latest'