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

Automatically merge green backport PRs and green approved PRs #41110

Merged
merged 6 commits into from
Jan 13, 2023

Conversation

Felixoid
Copy link
Member

@Felixoid Felixoid commented Sep 8, 2022

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Automatically merge green backport PRs and green approved PRs, fixes #40325

@Felixoid Felixoid added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 8, 2022
@robot-clickhouse robot-clickhouse added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 8, 2022
@Felixoid
Copy link
Member Author

Felixoid commented Sep 8, 2022

> python merge_pr.py --check-approved --pr 41110
2022-09-08 20:36:48,885 Going to process PR #41110 in repo ClickHouse/ClickHouse
2022-09-08 20:36:48,892 Found credentials in shared credentials file: ~/.aws/credentials
2022-09-08 20:36:52,084 Checking the PR for approvals
2022-09-08 20:36:52,321 There aren't reviews for PR #41110
2022-09-08 20:36:52,321 We don't merge the PR

executing it locally. Would somebody approve it so I can test the script?

tests/ci/merge_pr.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@azat azat left a comment

Choose a reason for hiding this comment

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

Testing approve

@Felixoid Felixoid marked this pull request as draft September 12, 2022 11:03
@Felixoid
Copy link
Member Author

Oh dear, the logic of taking the latest review per user isn't a good idea

@Felixoid
Copy link
Member Author

In [109]: repo.get_pull(41110).head.repo.pushed_at
Out[109]: datetime.datetime(2022, 9, 12, 13, 35, 11)

In [110]: repo.get_pull(41110).head.repo.pushed_at
Out[110]: datetime.datetime(2022, 9, 12, 13, 35, 19)

In [111]: repo.get_pull(41110).head.repo.pushed_at
Out[111]: datetime.datetime(2022, 9, 12, 13, 35, 19)

In [112]: repo.get_pull(41110).head.repo.pushed_at
Out[112]: datetime.datetime(2022, 9, 12, 13, 35, 52)

Hmm, doesn't look like pushed_at works

@Felixoid
Copy link
Member Author

Felixoid commented Sep 12, 2022

I think it's OK to have approval from collaborators as a marker that the PR is generally ok.

update: we discussed internally, and the script will consider only members' reviews

@Felixoid Felixoid marked this pull request as ready for review September 13, 2022 08:43
@Felixoid Felixoid marked this pull request as draft September 13, 2022 14:13
@Felixoid
Copy link
Member Author

Oh no, the PR would be merged on Finish in any case, even if there are failed statuses. It needs another check

@Felixoid Felixoid force-pushed the automerge branch 2 times, most recently from 4de6809 to 55e3d61 Compare September 14, 2022 14:26
@Felixoid Felixoid marked this pull request as ready for review September 14, 2022 14:33
@azat
Copy link
Collaborator

azat commented Sep 15, 2022

Maybe it also worth to check:

  • that the PR is not in a draft state? (just in case)
  • that there are no unresolved comments

Actually right now github provide everything similar:

  • Require approvals
  • Dismiss stale pull request approvals when new commits are pushed
  • Require review from Code Owners
  • Require status checks to pass before merging
  • Require conversation resolution before merging

The only problem is that you have to have write access to merge PR, so this is great, but will not work.

Actually I found auto-merge. So maybe all of this can be simply replaced with configuring proper policies on github?

And AFAIU anybody can select it, and this looks better then simply auto merge, maybe an author will find more problems with the patch.

P.S. llvm uses different policy

Copy link
Member

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

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

We have calculated self.approved_at without distinguishing the author_association. So, someone outside of the organization can approve after commits have been made after another legitimate approval.

@Felixoid Felixoid marked this pull request as draft September 21, 2022 11:50
@Felixoid Felixoid force-pushed the automerge branch 3 times, most recently from 26d2bdd to 9398b7e Compare November 10, 2022 12:06
@alexey-milovidov
Copy link
Member

We can limit the recognized approvals to the core team.

@Felixoid
Copy link
Member Author

Felixoid commented Jan 4, 2023

@azat the GH's approach is pretty dumb (not in a bad way, just simple) and straightforward.

  • First, we don't want to force approvals, and either they are strictly required, or aren't at all
  • The status checks are as well very, very unflexible. Either it completely blocks the merge, or it is just ignored completely.

These two don't allow us to consider the solution, it just won't work for us

@Felixoid Felixoid force-pushed the automerge branch 2 times, most recently from 168ffea to 5a84f9c Compare January 4, 2023 20:05
@Felixoid Felixoid marked this pull request as ready for review January 4, 2023 20:07
@alexey-milovidov alexey-milovidov merged commit e6b3f54 into master Jan 13, 2023
@alexey-milovidov alexey-milovidov deleted the automerge branch January 13, 2023 20:16
robot-clickhouse added a commit that referenced this pull request Jan 13, 2023
robot-clickhouse added a commit that referenced this pull request Jan 13, 2023
robot-clickhouse added a commit that referenced this pull request Jan 13, 2023
robot-clickhouse added a commit that referenced this pull request Jan 13, 2023
robot-clickhouse added a commit that referenced this pull request Jan 13, 2023
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jan 13, 2023
Felixoid added a commit that referenced this pull request Jan 14, 2023
Backport #41110 to 22.12: Automatically merge green backport PRs and green approved PRs
Felixoid added a commit that referenced this pull request Jan 14, 2023
Backport #41110 to 22.10: Automatically merge green backport PRs and green approved PRs
Felixoid added a commit that referenced this pull request Jan 14, 2023
Backport #41110 to 22.8: Automatically merge green backport PRs and green approved PRs
Felixoid added a commit that referenced this pull request Jan 14, 2023
Backport #41110 to 22.3: Automatically merge green backport PRs and green approved PRs
Felixoid added a commit that referenced this pull request Jan 14, 2023
Backport #41110 to 22.11: Automatically merge green backport PRs and green approved PRs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-not-for-changelog This PR should not be mentioned in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically merge the best pull requests
6 participants