Skip to content

Commit d9fc779

Browse files
CI: run tests on all branch pushes, once per same-repo PR
The previous condition (github.event.pull_request == null) did not work: github.event.pull_request is always null on push events regardless of whether a PR exists, so the redundant run was never skipped. Correct condition keeps on: [push, pull_request] and runs tests on every branch push while avoiding the duplicate when a same-repo PR exists: - push event: always runs (push to any branch, PR or not). On a push event github.event.pull_request.head.repo.fork dereferences to an empty string (falsy, no error), so the negation is true. - same-repo PR: skipped, since that push already triggered a run. - fork PR: runs via pull_request, since forks can't trigger a push here. Verified against GitHub docs: dereferencing a missing context property yields an empty string rather than an error. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 1e82061 commit d9fc779

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
# Skip redundant runs: don't run on push if there's an associated PR
8-
if: github.event_name == 'pull_request' || github.event.pull_request == null
7+
# Run on every branch push, but avoid duplicate runs when a same-repo PR
8+
# exists: same-repo changes run via the push event, while fork PRs (which
9+
# can't trigger a push in this repo) run via the pull_request event.
10+
if: >-
11+
(github.event_name == 'push' && !github.event.pull_request.head.repo.fork) ||
12+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork)
913
runs-on: ubuntu-24.04 # noble equivalent
1014

1115
strategy:

0 commit comments

Comments
 (0)