Skip to content

Skip CI for pull requests in the middle of a stack - #1401

Merged
seongahjo merged 1 commit into
mainfrom
ci/skip-mid-stack-pull-requests
Nov 19, 2026
Merged

seongahjo merged 1 commit into
mainfrom
ci/skip-mid-stack-pull-requests

Conversation

@seongahjo

Copy link
Copy Markdown
Contributor

Summary

With GitHub's stacked pull requests, workflows run for every pull request in a stack, not only the one targeting main. Each push to a stacked branch ran the tests and benchmarks of every pull request above it as well. This PR runs them only for the lowest unmerged pull request of a stack.

(Optional): Description

Why the branch filter did not stop them

  • build.yml, benchmark.yml and doc-examples.yml run on pull_request with branches: [ main, '[0-9]*.[0-9]*.x' ], so a pull request whose base is another feature branch was expected to be skipped.
  • For a stack, GitHub Actions "trigger as if each pull request in the stack targets the base of the stack" (Optimizing CI for stacked pull requests). The filter therefore matches main for every pull request in the stack.
  • Seen on Restore set value type checks and per-element setLazy #1398 and Promote container elements from generator candidates #1399, whose bases are fix/1390-object-immutable-container and fix/restore-set-value-handling:
    • when they were opened, only auto assign ran
    • they were added to the stack at 07:33:21 (added_to_stack in the timeline), and Run tests and Run benchmark started for both at 07:33:24
    • a push to a lower branch started them again for the pull requests above it, so one push to the stack ran them twice for each upper pull request (base_ref_force_pushed and head_ref_force_pushed at 08:18)

Change

  • The jobs static-analysis and test (build.yml), jmh (benchmark.yml) and test (doc-examples.yml) get the condition below. merge-results needs jmh, so it is skipped with it.
    if: >-
      github.event_name != 'pull_request'
      || github.event.pull_request.stack == null
      || github.event.pull_request.stack.base.ref == github.event.pull_request.base.ref
  • github.event.pull_request.stack exists only for a pull request in a stack, so the condition checks it for null first.
  • Pushes, workflow_dispatch and pull requests outside a stack run as before.
  • In a stack, only the pull request whose own base is the stack's base runs them. When it is merged, the next pull request is rebased onto the stack's base and runs them in turn.

How Has This Been Tested?

Is the Document updated?

No documentation change is needed.

- Run tests, benchmarks and doc example tests only for the lowest unmerged pull request of a stack
- Keep running them for pushes and for pull requests outside a stack
@seongahjo
seongahjo merged commit 66aaa72 into main Nov 19, 2026
9 checks passed
@seongahjo
seongahjo deleted the ci/skip-mid-stack-pull-requests branch November 19, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant