Skip to content

Commit 546322e

Browse files
mkarleskyclaude
andcommitted
Scope push CI to integration branches; skip the matrix for draft PRs
A feature/topic branch's own push event used to also trigger this workflow, so a push immediately followed by opening a PR from it fired two runs for the identical commit. Push and pull_request are independent, asynchronously-fired events with no ordering guarantee between them, so no point-in-time check on either side -- including the SHA-scoped concurrency cancellation just added -- can prevent the redundant run from being created in the first place, only clean it up after the fact. push: is now scoped to master and next_version only. A feature branch gets CI exactly once, via the PR opened from it, removing the duplicate trigger at its source rather than deduping it afterward. The concurrency fix stays in place as a backstop for the narrower cases this doesn't cover (e.g. a PR opened from master/next_version itself). Also skips the full matrix for a still-draft PR until it's marked ready, via a guard on every downstream job -- pull_request fires for draft PRs the same as ready ones, and this team doesn't have a reason to spend the whole matrix on a PR its author hasn't asked for review on yet. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 04060e9 commit 546322e

1 file changed

Lines changed: 34 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
# and release.yml, which trigger only on intentional Git tags.
1515
#
1616
# Triggers:
17-
# - Push to any branch
17+
# - Push to a long-lived integration branch (master, next_version) only —
18+
# a feature/topic branch gets checks exclusively through the pull_request
19+
# event once a PR exists (see the push: trigger below for why)
1820
# - Pull request targeting any branch (a PR can be opened against any
1921
# integration branch, not just master, as the project matures multiple
20-
# branches at once)
22+
# branches at once); skipped for a still-draft PR until marked ready
2123
# - Manual dispatch (workflow_dispatch)
2224
#
2325
# Skip-CI:
@@ -33,13 +35,22 @@
3335
---
3436
name: CI
3537

36-
# Triggers the workflow on push to any branch (tag pushes excluded — handled by
37-
# prerelease.yml and release.yml), pull requests targeting any branch, or manual dispatch
38+
# Triggers the workflow on push to a long-lived integration branch (tag pushes
39+
# excluded — handled by prerelease.yml and release.yml), pull requests targeting
40+
# any branch, or manual dispatch
3841
on:
3942
push:
40-
branches:
41-
- '**' # All branches; branches: ['**'] scopes push to refs/heads/ only,
42-
# excluding refs/tags/ pushes — see Skip-CI above
43+
# Deliberately narrow, not '**': a feature/topic branch's own push event used
44+
# to also trigger this workflow, so a push immediately followed by opening a
45+
# PR from it fired two runs for the identical commit -- push and pull_request
46+
# are independent, asynchronously-fired events with no ordering guarantee
47+
# between them, so no point-in-time check on either side can reliably catch
48+
# this before the fact (see the concurrency: block below for the backstop
49+
# that still exists for whatever this doesn't prevent). Scoping push: to only
50+
# the branches that are never themselves the source of a PR removes the
51+
# redundant trigger at its source instead: a feature branch now gets CI
52+
# exactly once, via the PR opened from it.
53+
branches: [master, next_version]
4354
pull_request:
4455
# No branch restriction: a PR merging into any branch gets checks. The one
4556
# exclusion is gh-pages, which only ever receives generated site output and
@@ -74,13 +85,24 @@ jobs:
7485
# Job: Build MkDocs HTML documentation bundle for gem inclusion
7586
generate-docs:
7687
name: "Generate Local Docs Bundle for Gem Inclusion"
88+
# pull_request fires for a draft PR the same as a ready one; github.event.pull_request
89+
# is only ever populated on that event type, so this has no effect on push or
90+
# workflow_dispatch runs. Holds off the full matrix's cost until a PR is actually
91+
# ready for review -- a draft's own incremental commits get this workflow's checks
92+
# for free the moment it's marked ready, no separate action needed.
93+
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
7794
uses: ./.github/workflows/_generate-docs.yml
7895

7996

8097
# Job: Linux test suite
8198
tests-linux:
8299
name: "Linux Test Suite"
83100
needs: generate-docs
101+
# success() is spelled out explicitly here (not left implicit) because a custom
102+
# if: replaces GitHub's default success()-on-needs: check entirely rather than
103+
# being ANDed with it -- every job below with a needs: dependency carries this
104+
# same explicit success() alongside its own draft-PR guard for that reason.
105+
if: success() && (github.event_name != 'pull_request' || github.event.pull_request.draft == false)
84106
runs-on: ubuntu-latest
85107
strategy:
86108
fail-fast: false
@@ -238,6 +260,7 @@ jobs:
238260
tests-windows:
239261
name: "Windows Test Suite"
240262
needs: generate-docs
263+
if: success() && (github.event_name != 'pull_request' || github.event.pull_request.draft == false)
241264
runs-on: windows-latest
242265
strategy:
243266
fail-fast: false
@@ -321,6 +344,7 @@ jobs:
321344
tests-macos:
322345
name: "macOS Test Suite"
323346
needs: generate-docs
347+
if: success() && (github.event_name != 'pull_request' || github.event.pull_request.draft == false)
324348
runs-on: macos-latest
325349
strategy:
326350
fail-fast: false
@@ -408,6 +432,7 @@ jobs:
408432
# a path-based Bundler deployment (deploy_gem) that does not require a gem build.
409433
tests-linux-locale:
410434
name: "Linux Test Suite (ja_JP.UTF-8 Locale)"
435+
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
411436
runs-on: ubuntu-latest
412437
steps:
413438
- uses: actions/cache@v6
@@ -479,6 +504,7 @@ jobs:
479504
# deployment (deploy_gem) that does not require a gem build.
480505
tests-linux-encoding-stress:
481506
name: "Linux Encoding Stress Test (C/POSIX)"
507+
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
482508
runs-on: ubuntu-latest
483509
steps:
484510
- uses: actions/cache@v6
@@ -553,6 +579,7 @@ jobs:
553579
- tests-macos
554580
- tests-linux-locale
555581
- tests-linux-encoding-stress
582+
if: success() && (github.event_name != 'pull_request' || github.event.pull_request.draft == false)
556583
runs-on: ubuntu-latest
557584

558585
steps:

0 commit comments

Comments
 (0)