-
Notifications
You must be signed in to change notification settings - Fork 56
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
[GitHub] Support using the merge
ref instead of the head
ref
#584
Comments
merge
ref instead of the head
refmerge
ref instead of the head
ref
Hi! So if I understand correctly, you propose two following changes:
It seems to be more relevant for the service, so if you don't have any objections for those 2 points, I will move transfer the issue there. :) (Or in the light of packit/packit-service#245, maybe just keep this for the ogr part) |
Exactly!
In this case it might help checking the
But I suspect it might not be the universal solution for all git forges.
Hah, I completely missed this one when I was trying to find if this was already requested, thanks!
Feel free to keep/transfer/closed this one then, I've subscribed to packit/packit-service#245 since it's basically what I was trying to request. Thanks! |
Let's keep this one to track the ask for ogr and then continue the discussion for the whole change in the packit-service's issues :) I think this is a good suggestion, I'm wondering what happens when the PR cannot be merged to the target branch - this is the reason why I think we should support both workflows: building from contributor's branch and building from a merged result. I'd say both are valid workflows. |
At least for GitHub you get For further discussion:
They have this though: https://docs.gitlab.com/ee/api/merge_requests.html#merge-to-default-merge-ref-path |
This should be a fairly cheap operation, right? Unless we are merging 5y old PR. The main problem I can see from my side is if the merge fails with some obscure error message - though we can check how others are doing this, especially zuul and get inspired. |
@TomasTomecek , @mvollmer: FYI, this is the issue we talked about yesterday. We ran into that in cockpit-project/cockpit#15823 as well -- the packit test failure happens because it takes outdated tests: that PR was posted from a slightly out of date fork, while origin/master got some string changes ("Never lock account" → "Never expire account"). Our code and tests got adjusted, and our IMHO the default should be to test the merge commit, as that's what will actually happen if you merge the PR. At least it should be possible to configure.
Then the test should fail early. The PR has conflicts and needs to be rebased anyway. It is not acceptable to test something outdated with conflicts and then manually merge it with conflict resolution without testing the merged result. At least CI systems should not encourage it. |
There should be nothing magic to it -- see e.g. cockpit CI ( |
... in other words, packit's code doesn't need to do anything explicitly. It should just clone the merge branch as the description says, that one is already rebased. |
I didn't realize it's this simple. It also sounds like it's "the right thing" to do and would also solve some weird behaviour (e.g. a PR is not rebased and contains very outdated packit.yaml or other configs). Bumping the prio here: @lachmanfrantisek shall we plan this one for the next sprint? Sounds like a trivial thing to implement. Martin, sorry for such a late response, GitHub's notifications are my bane lately -_- |
Add merge_commit_sha and mergeable properties to GithubPullRequest class (and PullRequest superclass). OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and mergeable properties to GithubPullRequest class (and PullRequest superclass). OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and mergeable properties to GithubPullRequest class (and PullRequest superclass). OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and merge_commit_status properties to GithubPullRequest class (and PullRequest superclass); merge_commit_status returns a CommitStatus, which is expanded with two new values, mergeable and notmergeable. GitHub's 'mergeable' boolean maps to CommitStatus.mergeable (true) or CommitStatus.notmergeable (false). GitLab's 'merge_status' string values map to CommitStatus.mergeable ("can_be_merged") or CommitStatus.notmergeable (everything else). OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and merge_commit_status properties to GithubPullRequest class (and PullRequest superclass); merge_commit_status returns a CommitStatus, which is expanded with two new values, mergeable and notmergeable. GitHub's 'mergeable' boolean maps to CommitStatus.mergeable (true) or CommitStatus.notmergeable (false). GitLab's 'merge_status' string values map to CommitStatus.mergeable ("can_be_merged") or CommitStatus.notmergeable (everything else). New test_pull_requests.py:test_merge_commit_sha methods for GitHub and GitLab. OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and merge_commit_status properties to GithubPullRequest class (and PullRequest superclass); merge_commit_status returns a CommitStatus, which is expanded with two new values, mergeable and notmergeable. GitHub's 'mergeable' boolean maps to CommitStatus.mergeable (true) or CommitStatus.notmergeable (false). GitLab's 'merge_status' string values map to CommitStatus.mergeable ("can_be_merged") or CommitStatus.notmergeable (everything else). New test_pull_requests.py:test_merge_commit_sha methods for GitHub and GitLab. OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and merge_commit_status properties to GithubPullRequest class (and PullRequest superclass); merge_commit_status returns a MergeCommitStatus. GitHub's 'mergeable' boolean maps to MergeCommitStatus.can_be_merged (true) or MergeCommitStatus.cannot_be_merged (false). GitLab's 'merge_status' string values map to MergeCommitStatus values verbatim. New test_pull_requests.py:test_merge_commit_sha methods for GitHub and GitLab. OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and merge_commit_status properties to GithubPullRequest class (and PullRequest superclass); merge_commit_status returns a MergeCommitStatus. GitHub's 'mergeable' boolean maps to MergeCommitStatus.can_be_merged (true) or MergeCommitStatus.cannot_be_merged (false). GitLab's 'merge_status' string values map to MergeCommitStatus values verbatim. New test_pull_requests.py:test_merge_commit_sha methods for GitHub and GitLab. OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and merge_commit_status properties to GithubPullRequest class (and PullRequest superclass); merge_commit_status returns a MergeCommitStatus. GitHub's 'mergeable' boolean maps to MergeCommitStatus.can_be_merged (true) or MergeCommitStatus.cannot_be_merged (false). GitLab's 'merge_status' string values map to MergeCommitStatus values verbatim. New test_pull_requests.py:test_merge_commit_sha methods for GitHub and GitLab. In Makefile, pass GITHUB_TOKEN, GITLAB_TOKEN in check-in-container OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and merge_commit_status properties to GithubPullRequest class (and PullRequest superclass); merge_commit_status returns a MergeCommitStatus. GitHub's 'mergeable' boolean maps to MergeCommitStatus.can_be_merged (true) or MergeCommitStatus.cannot_be_merged (false). GitLab's 'merge_status' string values map to MergeCommitStatus values verbatim. New test_pull_requests.py:test_merge_commit_sha methods for GitHub and GitLab. In Makefile, pass GITHUB_TOKEN, GITLAB_TOKEN in check-in-container OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Add merge_commit_sha and merge_commit_status properties to GithubPullRequest class (and PullRequest superclass); merge_commit_status returns a MergeCommitStatus. GitHub's 'mergeable' boolean maps to MergeCommitStatus.can_be_merged (true) or MergeCommitStatus.cannot_be_merged (false). GitLab's 'merge_status' string values map to MergeCommitStatus values verbatim. New test_pull_requests.py:test_merge_commit_sha methods for GitHub and GitLab. In Makefile, pass GITHUB_TOKEN, GITLAB_TOKEN in check-in-container OGR issue packit#584. Signed-off-by: Ben Crocker <[email protected]>
Support using the merge ref instead of the head ref in a pull request Add merge_commit_sha and mergeable properties to GithubPullRequest class (and PullRequest superclass). OGR issue #584. Signed-off-by: Ben Crocker [email protected] Reviewed-by: Tomas Tomecek <[email protected]> Reviewed-by: None <None> Reviewed-by: None <None> Reviewed-by: Matej Focko <None>
Yay! Thanks for landing this! ❤️ |
@allisonkarlitskaya just to be clear, we still need to actually use this functionality in packit, this is only the first part where we implemented the plumbing :) please watch packit/packit-service#245 |
Hello!
During our experience with Packit in systemd we've encountered multiple occurrences of a a scenario where a change in a pull request breaks the Packit CI when combined with a commit pushed into the main branch after the PR was created - in other words: had the PR been rebased before running the CI the issue would have been detected.
For this reason, our other CIs use the test/merge ref GitHub provides for each PR (
refs/pull/XXX/merge
instead ofrefs/pull/XXX/head
) which provides a transient merge commit combining the current base branch with the PR changes .In the GH API the SHA of the merge commit is provided via the
merge_commit_sha
field:(taken from https://docs.github.com/en/rest/reference/pulls#get-a-pull-request).
The PyGithub counterpart is
github.PullRequest.merge_commit_sha
(https://pygithub.readthedocs.io/en/latest/github_objects/PullRequest.html#github.PullRequest.PullRequest.merge_commit_sha)GitLab seems to support the
merge_commit_sha
field as well (https://docs.gitlab.com/ee/api/merge_requests.html), but I have a very limited experience with GitLab, so I'm not sure about the details.Would it be possible to implement this in a similar manner as the
GithubPullRequest.head_commit
property (since it's "just"github.PullRequest.merge_commit_sha
instead ofgithub.PullRequest.head.sha)
, and then make it somehow configurable via Packit?Thank you!
The text was updated successfully, but these errors were encountered: