Skip to content
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

CI: Verify commits in beta & stable are in upstream branches. #87604

Merged
merged 3 commits into from
Aug 22, 2021

Conversation

yaymukund
Copy link
Contributor

Closes #74721

I think this does the trick. #87597 is an example of it failing as it should.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pietroalbini (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 29, 2021
@pietroalbini
Copy link
Member

I'll soon go on vacation and I won't have time to review PRs then. r? @Mark-Simulacrum?

src/ci/scripts/verify-backported-commits.sh Outdated Show resolved Hide resolved
src/ci/scripts/verify-backported-commits.sh Outdated Show resolved Hide resolved
src/ci/scripts/verify-backported-commits.sh Outdated Show resolved Hide resolved
src/ci/scripts/verify-backported-commits.sh Outdated Show resolved Hide resolved
@jyn514 jyn514 added T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-release Relevant to the release subteam, which will review and decide on the PR/issue. and removed T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Jul 29, 2021
@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Aug 1, 2021

Could you add some documentation indicating what the outputs are / limitations here etc? For example, it looks like there are a number of commits different between the branches, but it's not quite clear to me what the expectations are for when those need to be updated and such.

We'll also want to be careful to avoid a situation where editing these files to include a commit is "impossible" because that would change the commit hash. At a quick glance, it seems like this could be a problem. Maybe instead of a single file tracking this information, we would prefer to ensure that each commit on the beta and stable branches have a line in them indicating the corresponding hash on the master branch, e.g.,

backport-of: <hash>

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2021
@yaymukund yaymukund force-pushed the verify-backported-commits branch 3 times, most recently from 1317a42 to 3524ac6 Compare August 9, 2021 00:07
@rust-log-analyzer

This comment has been minimized.

@yaymukund
Copy link
Contributor Author

yaymukund commented Aug 9, 2021

@Mark-Simulacrum That all makes sense.

I've implemented your backport-of: <sha> suggestion and added more details in the script & in the output (see a sample failure).

Edit: Thought about it some more...

This works fine if a single commit requires conflict resolution. However, if you merge an entire branch into (e.g.) beta but not master then each commit in the branch will need a backport-of: <sha> commit message. Is that acceptable?

@rust-log-analyzer

This comment has been minimized.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2021
@Mark-Simulacrum
Copy link
Member

This works fine if a single commit requires conflict resolution. However, if you merge an entire branch into (e.g.) beta but not master then each commit in the branch will need a backport-of: commit message. Is that acceptable?

Yeah, this is expected. I usually cherry-pick commits one by one anyway, so it shouldn't really be a big deal.

Can we add a script like src/tools/cherry-pick.sh which is essentially a wrapper around git cherry-pick but additionally edits the commit message after picking to include the backport-of line? I'd suggest using the git cherry-pick -x option, but it looks like that doesn't include the upstream commit hash if the commit has conflicts when cherry picking, so it won't quite work for us...

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 19, 2021
@yaymukund yaymukund force-pushed the verify-backported-commits branch 2 times, most recently from b3544af to 78fc6c7 Compare August 19, 2021 21:00
git cherry-pick $sha
git commit \
--amend \
--file <(commit_message_with_backport_note $sha)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you refactor this to take multiple parameters (and just cherry-pick each in turn, just like the normal cherry pick)?

@yaymukund
Copy link
Contributor Author

yaymukund commented Aug 19, 2021

PLEASE NOTE: DO NOT MERGE: This is producing strange behavior in CI and should not be merged in its current state. I shall update when it's fixed.

(Specifically: I added parentheses to the backport-of annotation and it's failing on correct backports.)

Update: It's fixed, and should be good to review / possibly merge. ✔️

@yaymukund
Copy link
Contributor Author

@Mark-Simulacrum If I understand your comment correctly, I don't think this script works if your cherry-pick has a conflict. You get dumped into the conflict resolution phase and the subsequent git commit --amend doesn't ever happen. I can try to make this atomic if you wish - I think there's an alternate approach where I set GIT_EDITOR=/some/script git cherry-pick -e.

This gets worse if you have a conflict in the middle of a long series of commits, as the first n commits may be successfully applied, but n+1 breaks. I don't see how to fix this easily.

@Mark-Simulacrum
Copy link
Member

Hm. Yes, I see your point. I think it might be possible that we can make it work using --continue as an argument to our wrapper script, but that might be hard -- I guess the goal would be to store some state that we could use to sort of resume the script. It seems like git-cherry-pick itself does this via .git/sequencer based on the manpage:

Continue the operation in progress using the information in .git/sequencer

But I'm not sure whether that file is documented anywhere or if editing it is in anyway feasible.

It's probably not a huge deal for us to manually deal with conflicts and amend commits after the fact; CI will yell at us after all...

@Mark-Simulacrum
Copy link
Member

I think if we can get it to work via GIT_EDITOR somehow, then let's try that, but if not, then no big deal.

@yaymukund
Copy link
Contributor Author

yaymukund commented Aug 19, 2021

Let's stick with the present approach.

I've just tested it and GIT_EDITOR doesn't seem to persist through conflict resolution. We'd need to export GIT_EDITOR, which means we'd also have to unset it. I don't think it's worth it.

@Mark-Simulacrum
Copy link
Member

Oh, one more thought: we will have commits on beta/stable that are specific to those branches, such as 56397e9 -- those will want their own annotation like "backport-of: nothing" or something, still explicitly denoted.

Could you add that support?

I think that's the last thing.

@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

Thanks! Looking forward to seeing this work in practice so we can see how effective/painful it is.

@bors
Copy link
Contributor

bors commented Aug 20, 2021

📌 Commit f19ba35 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 20, 2021
@yaymukund
Copy link
Contributor Author

Thanks for reviewing. Feel free to tag me in followup work if it would be helpful.

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 22, 2021
Rollup of 13 pull requests

Successful merges:

 - rust-lang#87604 (CI: Verify commits in beta & stable are in upstream branches.)
 - rust-lang#88057 (Update RELEASES to clarify attribute macro values.)
 - rust-lang#88072 (Allow the iOS toolchain to be built on Linux)
 - rust-lang#88170 (Update release note for 1.55.0.)
 - rust-lang#88172 (Test that type alias impl trait happens in a submodule)
 - rust-lang#88179 (Mailmap entry for myself)
 - rust-lang#88182 (We meant to use a trait instead of lifetime here)
 - rust-lang#88183 (test TAIT in different positions)
 - rust-lang#88189 (Add TAIT struct test)
 - rust-lang#88192 (Use of impl trait in an impl as the value for an associated type in a dyn)
 - rust-lang#88194 (Test use of impl Trait in an impl as the value for an associated type in an impl trait)
 - rust-lang#88197 (Test tait use in a fn type)
 - rust-lang#88201 (Test that incomplete inference for TAITs fail)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8660e3d into rust-lang:master Aug 22, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 22, 2021
@yaymukund yaymukund deleted the verify-backported-commits branch August 22, 2021 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-release Relevant to the release subteam, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify that backported commits are backports
8 participants