Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ci: Reduce CI for draft pull requests - #157360

Closed
methane wants to merge 2 commits into
python:mainfrom
methane:ci/minimal-draft-pr
Closed

ci: Reduce CI for draft pull requests#157360
methane wants to merge 2 commits into
python:mainfrom
methane:ci/minimal-draft-pr

Conversation

@methane

@methane methane commented Sep 12, 2026

Copy link
Copy Markdown
Member

Summary

Reduce GitHub Actions load while a pull request is still a draft.

  • The main Tests workflow still computes the changed-file context, but draft PRs suppress the expensive platform/test outputs.
  • Lint remains unchanged and continues to run on draft PRs.
  • The JIT workflow keeps only its Ubuntu interpreter/debug job for draft PRs; Windows, macOS, Linux matrix, and JIT extras wait until the PR is ready for review.
  • mypy and tail-call matrices are skipped for draft PRs.
  • Marking the PR ready for review re-enables the JIT/mypy/tail-call workflows via ready_for_review, and a small dispatcher starts the full Tests workflow on the PR branch.

Motivation

Large experimental changes often get many incremental pushes while they are still under development. Running the complete CPython CI matrix for each of those pushes consumes substantial runner capacity while providing relatively little additional signal. Draft PRs already communicate that the change is not ready for full review, so they are a useful boundary for lightweight vs. full CI.

This keeps early feedback (lint plus a representative JIT build/test when JIT-related files change) while deferring the expensive cross-platform matrices until the author explicitly marks the PR ready.

Behavior

Draft PR push:

  • change detection
  • lint
  • JIT interpreter/debug build+test when relevant
  • full Tests/JIT/mypy/tail-call matrices skipped

Ready for review:

  • full Tests workflow is dispatched on the PR branch
  • JIT/mypy/tail-call workflows run normally when their path filters match

Pushes to main, manual workflow dispatches, and non-draft PRs keep the existing behavior.

@StanFromIreland

StanFromIreland commented Sep 12, 2026

Copy link
Copy Markdown
Member

I'm -1 on this. I fear it may lead to surprises, since we're skipping jobs, and it also complicates our workflows quite a bit.

I also don't see much benefit. The JIT workflows only run in very specific scenarios (that is, when you're working on the JIT) and I presume that in those cases you'd want all of them to run. The mypy jobs only take a few seconds, so I'm not sure we're saving much there either. And finally, cutting most of the tests seems counterproductive as draft PRs will no longer be particularly useful.

Also, do we really have that many draft PRs? I suppose Hugo can probably get some stats from Datadog on their CI usage.

@methane

methane commented Sep 12, 2026

Copy link
Copy Markdown
Member Author

For branches that are still under development, I create PRs against my own fork rather than against python/cpython. That is probably why there are relatively few draft PRs in python/cpython.

The problem is that a large number of Actions are triggered for branches that are still under development. This is a PR within my fork, and many Actions are being triggered by both push and pull_request events.

To suppress them, I manually disabled the workflows. However, the option to disable a workflow is buried in a very unintuitive place, so I suspect many people are running a large number of unnecessary Actions simply because they do not know how to suppress them.

image

With the rapid development of AI, computing resources are becoming increasingly constrained worldwide. Microsoft currently provides everyone with a generous free allowance, but it would still be a good idea to start conserving resources now.

For example, what about running tests on pull_request only when the repository is python/cpython? For branches that are still under development, running tests on push alone should be sufficient. That would cut the number of Actions runs roughly in half.

@StanFromIreland

Copy link
Copy Markdown
Member

Ok, so if I understand correctly, this is targeted at people running CI on their forks, rather than on python/cpython.

I'm still not convinced this would be desirable for users. I know some people run CI on their fork before opening a PR, to ensure there are no failures. That would no longer be reliable.

The problem is that a large number of Actions are triggered for branches that are still under development. This is a PR within my fork, and many Actions are being triggered by both push and pull_request events.

Indeed, in that case you'll get duplicate runs. We could add skips for one when both are true to avoid the duplicates, but that's also a little messy. It would cut the number of runs for a PR opened in a fork down by half. You can, however, also make such changes only in your fork.

To suppress them, I manually disabled the workflows. However, the option to disable a workflow is buried in a very unintuitive place, so I suspect many people are running a large number of unnecessary Actions simply because they do not know how to suppress them.

That seems like a better solution to me, as users who are concerned about their usage can selectively disable workflows they don't need. I think that's far better than making that decision for them. We could perhaps document this in the devguide?

With the rapid development of AI, computing resources are becoming increasingly constrained worldwide. Microsoft currently provides everyone with a generous free allowance, but it would still be a good idea to start conserving resources now.

Currently, we're provided with an unlimited number of Actions minutes (at least for python/cpython). I also presume Python brings Microsoft more financial benefit than it costs them to pay for our CI. But since this isn't currently an issue, I don't think there's much need to get into that discussion.

For example, what about running tests on pull_request only when the repository is python/cpython? For branches that are still under development, running tests on push alone should be sufficient. That would cut the number of Actions runs roughly in half.

In python/cpython, that's already the case. See the CI runs on this PR, for example, they're all triggered only by pull_request. push requires the branch to be in the same repository.

@methane

methane commented Sep 13, 2026

Copy link
Copy Markdown
Member Author

After checking, I found that only the lint workflow was triggered by both push and pull_request; the tests were triggered only by pull_request.

https://github.com/methane/cpython/actions/runs/34736727947/job/103669363596

I do get the impression that GitHub Actions has become less reliable, but let's leave things as they are until Microsoft reduces the free allowance.

@methane methane closed this Sep 13, 2026
@methane
methane deleted the ci/minimal-draft-pr branch September 13, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review infra CI, GitHub Actions, buildbots, Dependabot, etc. skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants