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

1663: Mark integrated Pull Requests as properly merged in their repositories #1409

Closed
wants to merge 5 commits into from

Conversation

TheShermanTanker
Copy link
Contributor

@TheShermanTanker TheShermanTanker commented Nov 1, 2022

Skara currently closes integrated Pull Requests, since the actual integration is done internally and then pushed to the repository separately. This makes every integrated request always look like it was closed to an outside observer, forcing the use of a special integrated flag to distinguish between integrated and closed, or rejected and closed. On top of that, it just looks awful in the interface all around (and is also not included in the accepted Pull Request count by GitHub for the committer, which is frustrating for newer contributors to a surprising extent). In the willful absence of a reply from the GitHub team to allow marking a pull request as merged through a flag, and GitLab being unlikely to make a similar change either, we can look at implementing this as an integration feature in Skara itself instead.

Every pull has a corresponding pre-integration branch created at the time it was made, and this special branch is marked for deletion when the pull is integrated, and initially it was thought to merge the Pull Request into these corresponding pr/ branches just before their deletion but that proved to present too many challenges to be viable. Instead a related approach of enhancing the Pull Request bots with their own special integration branches can be taken, as well as providing a flexible utility method for extracting the actual branch the Pull Request was integrated into, to address the concern of losing information on what the actual Pull Request target branch was.

https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/merge_request.rb#L172


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace

Issue

  • SKARA-1663: Mark integrated Pull Requests as properly merged in their repositories

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/skara.git pull/1409/head:pull/1409
$ git checkout pull/1409

Update a local copy of the PR:
$ git checkout pull/1409
$ git pull https://git.openjdk.org/skara.git pull/1409/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1409

View PR using the GUI difftool:
$ git pr show -t 1409

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/skara/pull/1409.diff

Webrev

Link to Webrev Comment

@TheShermanTanker TheShermanTanker marked this pull request as draft November 1, 2022 16:55
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 1, 2022

👋 Welcome back jwaters! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@TheShermanTanker TheShermanTanker force-pushed the integration branch 2 times, most recently from fb67aaf to 078b4f7 Compare November 3, 2022 05:17
@TheShermanTanker TheShermanTanker marked this pull request as ready for review November 3, 2022 05:19
@openjdk openjdk bot added the rfr label Nov 3, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 3, 2022

Webrevs

@TheShermanTanker
Copy link
Contributor Author

I've only just realized that there are tests that require careful change whenever the integration marking code is modified. The existing integration sequence hasn't been touched whatsoever but there is new logic executed before it that I can't figure out whether the corresponding test code needs to be updated. Will add that as a task for now

@erikj79
Copy link
Member

erikj79 commented Nov 3, 2022

First of all, for a change as big as this, a bug is definitely needed. It should really be filed first and explain what and why you intend to change.

This is an interesting idea, but I'm not sure its worth the tradeoff of losing the information about which branch a PR was integrated into. We already have multi branch development happening in some repos and more of that is coming.

At first glance this also looks brittle. You need to understand that the bots are designed to be interruptible at any point in time, restarted and being able to continue. The integration logic and order is carefully crafted to function this way. As an example, assuming that the second to last target targetRef change is the one we actually integrated into could be false if someone else was changing that around the time of integration. There are a lot of corner cases that would need careful testing before this change could be accepted, and once it went live, I would expect at least some fallout.

We are currently blocked from using pr/X branches in GitLab due to SKARA-1173, so this proposed change would be blocked until that is resolved regardless.

@TheShermanTanker TheShermanTanker marked this pull request as draft November 3, 2022 13:35
@openjdk openjdk bot removed the rfr label Nov 3, 2022
@TheShermanTanker TheShermanTanker changed the title Mark integrated Pull Requests as properly merged in GitHub repositories 1663: Mark integrated Pull Requests as properly merged in GitHub repositories Nov 3, 2022
@openjdk-notifier
Copy link

@TheShermanTanker Please do not rebase or force-push to an active PR as it invalidates existing review comments. All changes will be squashed into a single commit automatically when integrating. See OpenJDK Developers’ Guide for more information.

@TheShermanTanker
Copy link
Contributor Author

TheShermanTanker commented Nov 3, 2022

First of all, for a change as big as this, a bug is definitely needed. It should really be filed first and explain what and why you intend to change.

This is an interesting idea, but I'm not sure its worth the tradeoff of losing the information about which branch a PR was integrated into. We already have multi branch development happening in some repos and more of that is coming.

At first glance this also looks brittle. You need to understand that the bots are designed to be interruptible at any point in time, restarted and being able to continue. The integration logic and order is carefully crafted to function this way. As an example, assuming that the second to last target targetRef change is the one we actually integrated into could be false if someone else was changing that around the time of integration. There are a lot of corner cases that would need careful testing before this change could be accepted, and once it went live, I would expect at least some fallout.

My mistake- I forgot to create the issue and enable the test workflows, both have now been done.

I've since reverted the changes to PreIntegrations, which should resolve the problem of concurrent changes to the targetRef in question. The only other solution I can think of though is saving the targetRef before the pr/ branch swap happens, and then immediately resetting it back to the saved instance after the merge in markIntegratedAndMerged (and if really required, also printing the branch the Pull Request was integrated into in the "pushed as commit" message). I unfortunately currently have no way of testing if GitHub even allows doing this however, and documentation doesn't really seem to mention anything about this either

@erikj79
Copy link
Member

erikj79 commented Nov 3, 2022

That's a bit of a bummer, though maybe that can be circumvented with a few instanceof GitHubPullRequests? The change is, after all, only actually implemented for GitHub

I don't understand what you mean by the change only being implemented for GitHub. We strive to keep Skara feature equivalent on GitHub and GitLab.

The pr/X branch feature is optional, so those branches are currently not present in all repositories that the PR bot operates on. This configuration is done in the notifier bot, as that is currently the only bot that needs to know about it, so the PR bot does not know if the feature is active. It would have to check for the presence of such a branch at integration time, and we would have to trust that no other branches with such names ever show up in repos where we haven't activated the pr/X feature.

I don't think the proposed strategy of using the pr/X branches to trick the forge into marking a PR as "merged" is viable for us. To me, the tradeoff between extra complications and the potential gain isn't worth it.

@TheShermanTanker
Copy link
Contributor Author

TheShermanTanker commented Nov 3, 2022

The pr/X branch feature is optional, so those branches are currently not present in all repositories that the PR bot operates on.

My mistake, I misunderstood the original comment; I didn't realize that the PR bot had no way of telling if the feature was active on the main repos

@TheShermanTanker TheShermanTanker marked this pull request as ready for review November 4, 2022 13:09
@openjdk openjdk bot added the rfr label Nov 4, 2022
@TheShermanTanker TheShermanTanker changed the title 1663: Mark integrated Pull Requests as properly merged in GitHub repositories 1663: Mark integrated Pull Requests as properly merged in their repositories Nov 4, 2022
@TheShermanTanker TheShermanTanker marked this pull request as draft November 4, 2022 13:21
@openjdk openjdk bot removed the rfr label Nov 4, 2022
@TheShermanTanker TheShermanTanker marked this pull request as ready for review November 5, 2022 08:03
@openjdk openjdk bot added the rfr label Nov 5, 2022
@TheShermanTanker TheShermanTanker marked this pull request as draft November 6, 2022 12:18
@openjdk openjdk bot removed the rfr label Nov 6, 2022
@TheShermanTanker TheShermanTanker marked this pull request as ready for review November 6, 2022 15:45
@openjdk openjdk bot added the rfr label Nov 6, 2022
@TheShermanTanker TheShermanTanker marked this pull request as draft November 10, 2022 17:09
@openjdk openjdk bot removed the rfr label Nov 10, 2022
@TheShermanTanker TheShermanTanker marked this pull request as ready for review November 10, 2022 19:10
@openjdk openjdk bot added the rfr label Dec 22, 2022
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 22, 2022

@TheShermanTanker This pull request has been inactive for more than 3 weeks and will be automatically closed if another 3 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@TheShermanTanker
Copy link
Contributor Author

An early look at how integrated Pull Requests look like after this change: Elshout/Sandbox#2

I will definitely need more time to work on this to make it run better though, currently it's a bit of a mess

@openjdk openjdk bot added rfr and removed rfr labels Dec 22, 2022
@TheShermanTanker
Copy link
Contributor Author

TheShermanTanker commented Dec 22, 2022

Improved Version: Elshout/Sandbox#1

Elshout/Sandbox#2

@openjdk openjdk bot removed the rfr label Dec 22, 2022
@TheShermanTanker TheShermanTanker marked this pull request as draft December 22, 2022 11:29
@TheShermanTanker TheShermanTanker marked this pull request as ready for review December 22, 2022 11:29
@openjdk openjdk bot added the rfr label Dec 22, 2022
@TheShermanTanker TheShermanTanker marked this pull request as draft December 22, 2022 17:28
@openjdk openjdk bot removed the rfr label Dec 22, 2022
@altrisi
Copy link
Contributor

altrisi commented Jan 5, 2023

Is there any reason why Skara doesn't use (or emulate in a way that is detected if there's no direct way/endpoint) what GitHub does when using the "Rebase and Merge" button?

That marks pull requests as merged unless it's changed recently, without making the rebase directly in the PR branch.

@TheShermanTanker
Copy link
Contributor Author

@altrisi could you elaborate further on this "Rebase and Merge" feature for GitHub? Do you mean the usual rebasing and merging of the PR's actual sequence of commits directly into the repository, or is this part of GitHub's indirect merge logic (where the Pull Request does not need to be actually merged into the target branch for it to be marked as merged, I am aware that there are a few circumstances where GitHub will currently do that) that I haven't heard of? If it's the latter, I am pretty curious and interested

@altrisi
Copy link
Contributor

altrisi commented Jan 5, 2023

I'm talking about the Rebase and merge option on the dropdown when manually merging a PR from the web UI, just wondering if there's a reason not to use that or something similar in Skara. I don't know if it's exposed to apps, or if Skara has more requirements that feature doesn't meet though.

@altrisi
Copy link
Contributor

altrisi commented Jan 5, 2023

Sorry I've said it wrong, I was referring to Squash and merge this entire time, for some reason confused it with rebase.

@erikj79
Copy link
Member

erikj79 commented Jan 5, 2023

Is there any reason why Skara doesn't use (or emulate in a way that is detected if there's no direct way/endpoint) what GitHub does when using the "Rebase and Merge" button?

That marks pull requests as merged unless it's changed recently, without making the rebase directly in the PR branch.
Sorry I've said it wrong, I was referring to Squash and merge this entire time, for some reason confused it with rebase.

An important design choice in Skara was to make sure it was compatible with at least 2 different hosting providers (currently github and gitlab) so that we did not build in a hard dependency on a single provider. This means we can't lean too heavily on functionality specific to any one provider, but rather prefer to implement general solutions that can be used with both/all.

I can't say if there is anything in particular that the GitHub API of today is missing that would hinder us from using it for squash merging PRs, at least not without spending a considerable amount of time investigating. I'm pretty sure the original implementors of Skara found that the current strategy was necessary to support the OpenJDK process on both GitLab and GitHub at the time it was implemented, and I trust their judgement.

@TheShermanTanker
Copy link
Contributor Author

I can't say if there is anything in particular that the GitHub API of today is missing that would hinder us from using it for squash merging PRs, at least not without spending a considerable amount of time investigating.

From my time experimenting with the APIs of both hosts, the only thing really missing is the ability to set the committer and author of the actual Pull Request, like we currently do in CheckablePullRequest. Otherwise quite a lot of the existing logic could (with substantial effort) be migrated to use the Pull Request API instead of the current strategy of creating a commit on our own local repositories before pushing to remote ("commit_title" and "commit_message" can already be set from the API for instance, same with GitLab). A rather extreme option to circumvent this issue if we really wanted to utilize the host's merging abilities as altrisi suggests would be giving Skara the ability to force the Pull Request itself (the branch that contains its commits in essence) to allow edits from the pr bot (both GitHub and GitLab support doing so) and pushing the commit from our own local repo into the PR instead, before then merging it through the API as if from the UI as per normal

(Side note: Doing it this way would also result in having to make messy decisions on what to do with the existing prepush comment system and the handling for the "Pushed as commit" comments, since those would no longer be accurate in such a scenario)

@openjdk
Copy link

openjdk bot commented Jan 9, 2023

⚠️ @TheShermanTanker This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@openjdk
Copy link

openjdk bot commented Feb 9, 2023

@TheShermanTanker this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout integration
git fetch https://git.openjdk.org/skara master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 23, 2023

@TheShermanTanker This pull request has been inactive for more than 6 weeks and will be automatically closed if another 6 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented May 4, 2023

@TheShermanTanker This pull request has been inactive for more than 12 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants