-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Pin base branch for pull requests #54693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
💊 CI failures summary and remediationsAs of commit 364a7e5 (more details on the Dr. CI page):
🚧 1 fixed upstream failure:These were probably caused by upstream breakages that were already fixed.
Please rebase on the
|
@bigfootjon has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Codecov Report
@@ Coverage Diff @@
## base/9e6877c #54693 +/- ##
=============================================
Coverage 77.45% 77.45%
=============================================
Files 1894 1894
Lines 186403 186403
=============================================
+ Hits 144374 144383 +9
+ Misses 42029 42020 -9 |
Looks good to me for this approach. Have a couple of questions and potential follow ups.
Have we tried this workflow on a ghstack PR. Specifically: Would ghstack PRs have the "base pinned" label added by this workflow? if not do we plan to implement this in ghstack or modify this workflow?
will we advance the current base branch tip to the new master commit or do we create a new base branch? (e.g. do we increase # of branches on the pytorch repo?
I dont think we need to worry about this, because a typical |
The "Pin base branch" workflow only runs when the PR's base branch is already
I don't understand what you mean here; could you clarify?
Agreed. |
in this case, who would be the one that tags
This means base pinned tag needs to be added to trigger another pull_request event right?
For example currently this PR is based off |
The "Pin base branch" workflow adds that label automatically, which is why it requires a special
No, because it is possible that there are other PRs still using that same branch as their base (which is one of the reasons @seemethere suggested using hash prefixes instead of PR numbers for this). |
Perhaps a good follow up to this PR would be to create a workflow to clean up these base branches when there’s no longer pull requests associated with them? |
Hmm. I guess i didn't express my question correctly. let me rephrase. as you mentioned,
and I further assume My question is,
|
yes. but I am not sure if |
Not necessarily, but there's probably a way to check and see whether or the branch is still being used by other PRs (not sure about race conditions though). |
Ah, I see what you're saying. The answer is that the point of the "base pinned" tag is just to kick off CI, so we don't need it for |
Summary: We've been using [pytorch/add-annotations-github-action](https://github.com/pytorch/add-annotations-github-action) to add annotations to PRs when they fail Flake8 or clang-tidy. Up until now, though, that functionality has only worked on PRs in pytorch/pytorch itself, not on PRs from forks. This PR fixes that using a technique from [this GitHub blog post](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) (also linked in a comment in this diff). Pull Request resolved: #54779 Test Plan: janeyx99 and I tested this in the same GitHub repo used to test #54685 and #54693, including with PRs from forks. Reviewed By: walterddr Differential Revision: D27364777 Pulled By: samestep fbshipit-source-id: a830d372d7bb3b2529fc633b707b44f2b6cf9baa
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Closing this for now (in favor of #54967) because it just introduces too many quirks. |
Summary: PRs #53652 and #54693 attempted to increase the consistency of our choice of commit (head vs merge) for CI on PRs, and have so far been unsuccessful. This PR takes a less ambitious approach to the problem by clarifying the choice in one specific way (see the following paragraph) and documenting it in `CONTRIBUTING.md`. In addition to documentation, this PR also removes the current behavior of our GHA jobs that checkout the PR tip instead of the merge commit. At first glance, this behavior seems to increase consistency (by eliminating the special-case for `ghstack` PRs), but in reality, it actually just means that for non-`ghstack` PRs, the question "Which commit is used in CI?" has *two* answers instead of just one; see the description of #53652 for more details. Once merged, this PR will unblock other PRs that add modify our GHA workflows in breaking ways, such as #54737. Pull Request resolved: #54967 Test Plan: None. Reviewed By: walterddr, seemethere Differential Revision: D27435913 Pulled By: samestep fbshipit-source-id: 405fb419cf015cf88107d5eb2498cfb5bcb7ce33
Summary: We've been using [pytorch/add-annotations-github-action](https://github.com/pytorch/add-annotations-github-action) to add annotations to PRs when they fail Flake8 or clang-tidy. Up until now, though, that functionality has only worked on PRs in pytorch/pytorch itself, not on PRs from forks. This PR fixes that using a technique from [this GitHub blog post](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) (also linked in a comment in this diff). Pull Request resolved: #54779 Test Plan: janeyx99 and I tested this in the same GitHub repo used to test #54685 and #54693, including with PRs from forks. Reviewed By: seemethere, xuzhao9 Differential Revision: D27470866 Pulled By: samestep fbshipit-source-id: d165b8e875d412b910592aa897163fb938d23365
Context: As of #53719 (which replaced an equivalent solution from before), we use the
ref
input foractions/checkout
to checkout the PR tip instead of a merge commit.viable/strict
instead ofmaster
, the repo checkout for GHA runs on the PR won't pull in stuff from the latest (often-broken)master
.checkout
comes from the PR tip, the actual workflow YAML files are still pulled from the merge commit of the PR withmaster
. So ifmaster
adds a new workflow and some scripts that that workflow uses, any PR based on a commit behind that will fail in GHA. A couple examples:Instead of breaking atomicity by checking out something besides the merge commit, this PR resolves the problem by forcing the merge commit to be the same as the PR head commit.
Specifically, it adds a workflow which listens for activity on PRs against
master
(such as when they're opened or when new commits are pushed), and updates the PR's base branch to bebase/hhhhhhh
, wherehhhhhhh
is the 7-digit prefix of the SHA1 hash of themerge-base
of the PR head withpytorch:master
. It also adds the "base pinned" label to the PR (if it doesn't have the label already). Because this new workflow is triggered bypull_request_target
rather thanpull_request
, it must be merged before it can take effect. For demonstration purposes, I have manually set the base branch and "base pinned" label for this PR, but those would both be done automatically after it is landed.Important: Before this PR is merged, a GitHub token called
GITHUB_BASE_BRANCH_TOKEN
must be added to thepytorch/pytorch
repo. The new workflow uses said token to add a label in such a way that it will trigger a followuppull_request
workflow run.The timeline for a typical PR will look something like this:
master
pull_request
workflows don't run because we restricted them to only run once they're pinned (or if they'reghstack
PRs, which are always pinned anyway)pull_request
event (this time of typelabeled
)pull_request
workflows now run on that initial commit of the PR, using the PR head as the merge commit since the base branch has been pinnedmaster
commitmaster
historypull_request
workflow runs as normal, with typesynchronize
, because the base branch matchesbase/*
so even if the user rebases onto a more recent commit frommaster
, the PR head and merge commits will still be exactly the sameA few caveats of this implementation:
pull_request
run immediately after that (before the "Pin base branch" workflow has a chance to run again) will use a merge commit different from the PR's head commitif
to check the label that was added and cancel jobs if it's not "base pinned", but that would add more boilerplatethis is a big one: the "Import to Phabricator" button currently doesn't work on this PROther questions for reviewers:
pull_request
workflows are limited to PRs with base branchbase/*
orgh/**
? what about PRs against other branches, such as release branches?Test plan:
@janeyx99 and I tested this in the same GitHub repo used to test #54685, including with PRs from forks.