rustfmt feature: Sync r-l/r milestones to r-l/rustfmt when merging subtree sync PRs - #2499
Conversation
9d37c4d to
f1208d1
Compare
|
Instead of looking at the closed/merged PRs, I think we should be able to use the merge commits created in r-l/rustfmt to our advantage to have an accurate list of the merged PRs. We know they have a title like this: I think we could use that to our advantage, by:
What do you think? An optimization to be done is to only to this when files under |
|
@Urgau thank you for the feedback! Seems like a much more robust approach than what I was originally thinking. Taking the most recent subtree-sync as an example (rust-lang/rust#161964) this is what I think we could do.
|
That seems broadly fine with the caveat that we need to check that the merge commits are in r-l/rustfmt, as the subtree sync could have been in a rollup and we would start milestoning the wrong PRs. Btw, we already have a method to get all the commits of a PR. |
That's amazing!
I was thinking that we'd just look at the commit messages and use a regex to extract the PR number. In that case would we still need to check that the commits are in rustfmt? Maybe I'm misunderstanding something? We typically don't include rustfmt subtree syncs in rollups, but I agree that we shouldn't rely on that here. Is the concern that if it's included in a rollup that we might accidentally assign milestones to PR numbers from other repos that just happen to have the same number as rustfmt? Maybe the My original thought was that this would only get triggered when the subtree-sync PR was closed and that we'd be able to reference that PR and grab all of its commit messages. At that point we'd know that all the PRs referenced in the I'm also wondering if your original suggestion to use |
Yes, that's my concern. Not checking that the commits are indeed in r-l/rustfmt would effectively prevent doing rollups, which is not ideal, in particular since we don't have a way to prevent someone from accidentally rollup-ing future syncs.
I rather avoid gating on labels when we can, they can be forgotten or missed by triagebot (we may miss a webhook); and as you mention it as well the rollup probably won't get tagged with
I think our implementation does not properly gather all the pages (it only does one call), so we would have to fix it first before using it. I will try fixing it this week-end. But the reason I suggested |
|
I just asked a question in #t-rustfmt > Merge queue. I'm wondering if it would simplify things if we could update the merge commit messages from Edit: Not sure how feasible this is, but if we could set something like that up then I think we might be able to take a similar approach for other subtrees. |
That would certainly help, unfortunately it's not possible. GitHub doesn't allow setting a custom merge queue commit title (see https://github.com/orgs/community/discussions/15925). But it's not necessary, we just need to make sure the SHA of the merge commit (the ones with |
|
@Urgau Are the SHAs from the merge commits guaranteed to be the same? I thought they might be different, but I picked out one of the commits from rust-lang/rust#161964 to double check and it looks like the SHAs are consistent. From this message: Which corresponds to this rustfmt PR rust-lang/rustfmt#7066
Another example from rust-lang/rust#161964 that's not a merge commit because it was merged before we started using the merge queue, but it looks like the SHAs are consistent there too: rustfmt PR: rust-lang/rustfmt#6010
|
Good question. Seems like they are the same with However, looking at a Josh sync, I'm not seeing the same SHA, in rust-lang/rust rust-lang/rust@8173a82, in rust-lang/miri rust-lang/miri@8de2ef9. Any hindsight to share @Kobzol? |
|
With Josh, the commit SHAs in r-l/r and the subtree will be different. |
That's a good news, for rustfmt at least, less for Josh subtrees. I guess there isn't an easy way to correlate them without running Josh?
Looking more that those two commits, the one is rust-lang/rust has it's path corrected to So what I think we can do for Josh subtrees, if we ever get one that wants milestones, is to look at which files the commit modifies. If the commit only modifies files inside the subtree and is named This is of course hypothetical since rustfmt is not a Josh subtree, and we can just check the SHA with |
f1208d1 to
832f5c2
Compare
This comment has been minimized.
This comment has been minimized.
832f5c2 to
849f814
Compare
Right, but I think it's more "not yet", I think we'd like to move to become a Josh subtree to make the syncs easier, once the WIP Josh things are settled down. |
849f814 to
d2c206c
Compare
This comment has been minimized.
This comment has been minimized.
|
Pushed a lot of changes. I applied all the feedback and then tried to follow the same structure used by |
d2c206c to
b1f3ce9
Compare
|
Looking at #t-rustfmt > Migrating to Josh, seems like the migration to Josh is pretty imminent. I'm fine merging the PR the meantime, but since it will only be used once (hopefully), it may be better to prepare instead for Josh? Regarding what to do with Josh subtrees, we talked about it at #t-infra > saving the original commit SHAs with Josh subtree and the consensus is to filter all the "Merge pull request" commits and milestone those who only contain |
The transition to a Josh Subtree is likely around the corner, but I'd like to test out this current version for rustfmt it you're okay with it. My hope with the current That said, once we transition rustfmt to a Josh subtree we can also remove the git subtree implementation if you don't want dead code kicking around in triagebot. I'm happy to make those changes once the time comes! |
Clippy is probably also around the corner with regards to using Josh: rust-lang/rust-clippy#17739; but point taken. |
|
😅 Oh I didn't realize that clippy was planning to transition too. Well then maybe one of these other subtrees :) |
|
Hopefully all of them will migrate soon, now that we have the new version of Josh working :) |
…ng subtree syncs This adds a new step to the `milestone_prs::handle` that tries to sync r-l/r milestones to r-l/rustfmt after merging r-l/r subtree sync PRs.
…tfmt` Instead of using the `T-rustfmt` label, check that the PR modified files in `src/tools/rustfmt`.
This is still implemented for rustfmt, but the approach can be used for any rust-lang/rust git subtree that uses a merge queue to to standardize how PRs are merged.
b1f3ce9 to
b6455bb
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This adds a new step to the
milestone_prs::handlethat tries to sync r-l/r milestones to r-l/rustfmt after merging r-l/r subtree sync PRs.For this to work correctly the r-l/r PR needs to have both the
T-rustfmtand thesubtree-synclabel. Then on the r-l/rustfmt side rustbot will only set the milestone on closed r-l/rustfmt PRs that were previously labeled withrelease-notes.It's possible that some r-l/rustfmt PRs get merged into r-l/rustfmt's
mainbranch between the time it takes to start the sync process and open the subtree sync PR in r-l/r. To mitigate issues around incorrectly setting a milestone on r-l/rustfmt PRs that didn't make it into the r-l/r sync PR, there's an additional filter that only sets milestones on r-l/rustfmt PRs that were merged at least one hour before the r-l/r sync PR was opened.cc: @rust-lang/rustfmt @rust-lang/rustfmt-contributors
Note
I didn't know if there was a good way to test this change.
GithubClientandRepositoryare both concrete types so I don't think there's a good way to mock out their behavior to directly test different scenarios.