mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Merge 59d56668e9
into f4e8ac81d6
This commit is contained in:
commit
e3588afff1
4
.github/workflows/master.yml
vendored
4
.github/workflows/master.yml
vendored
@ -23,10 +23,10 @@ jobs:
|
||||
clear-repository: true # to ensure correct digests
|
||||
fetch-depth: 0 # to get version
|
||||
filter: tree:0
|
||||
- name: Check sync PR
|
||||
- name: Merge sync PR
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||
python3 sync_pr.py || :
|
||||
python3 sync_pr.py --merge || :
|
||||
- name: Python unit tests
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||
|
13
.github/workflows/pull_request.yml
vendored
13
.github/workflows/pull_request.yml
vendored
@ -157,16 +157,25 @@ jobs:
|
||||
################################# Stage Final #################################
|
||||
#
|
||||
FinishCheck:
|
||||
if: ${{ !failure() && !cancelled() && github.event_name != 'merge_group' }}
|
||||
needs: [Tests_1, Tests_2]
|
||||
if: ${{ !failure() && !cancelled() }}
|
||||
needs: [Tests_1, Tests_2, Builds_1_Report, Builds_2_Report]
|
||||
runs-on: [self-hosted, style-checker]
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: ClickHouse/checkout@v1
|
||||
- name: Check sync status
|
||||
if: ${{ github.event_name == 'merge_group' }}
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||
python3 sync_pr.py --status
|
||||
- name: Finish label
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||
python3 finish_check.py
|
||||
- name: Auto merge if approved
|
||||
if: ${{ github.event_name != 'merge_group' }}
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||
python3 merge_pr.py --check-approved
|
||||
|
||||
|
||||
|
@ -2121,6 +2121,8 @@ def main() -> int:
|
||||
pr_info,
|
||||
dump_to_file=True,
|
||||
)
|
||||
if not pr_info.is_merge_queue():
|
||||
# in the merge queue mergeable status must be set only in FinishCheck (last job in wf)
|
||||
update_mergeable_check(
|
||||
commit,
|
||||
pr_info,
|
||||
|
@ -28,6 +28,7 @@ def main():
|
||||
statuses = get_commit_filtered_statuses(commit)
|
||||
trigger_mergeable_check(commit, statuses)
|
||||
|
||||
if not pr_info.is_merge_queue():
|
||||
statuses = [s for s in statuses if s.context == CI_STATUS_NAME]
|
||||
if not statuses:
|
||||
return
|
||||
|
@ -2,14 +2,68 @@
|
||||
|
||||
"""Script for automatic sync PRs handling in private repos"""
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from get_robot_token import get_best_robot_token
|
||||
from pr_info import PRInfo
|
||||
from github_helper import GitHub
|
||||
from commit_status_helper import get_commit, post_commit_status
|
||||
from report import FAILURE, SUCCESS
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
description="Script for handling sync PRs",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--merge",
|
||||
action="store_true",
|
||||
help="merge sync pr",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--status",
|
||||
action="store_true",
|
||||
help="check and set sync pr status",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
def merge_sync_pr(gh, sync_pr):
|
||||
if not sync_pr:
|
||||
print("Sync PR not found - exiting")
|
||||
return
|
||||
|
||||
if sync_pr.state == "closed":
|
||||
print(f"Sync PR [{sync_pr.number}] already closed - exiting")
|
||||
sys.exit(0)
|
||||
|
||||
if sync_pr.state != "open":
|
||||
print(
|
||||
f"WARNING: Unknown Sync PR [{sync_pr.number}] state [{sync_pr.state}] - exiting"
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
print(f"Trying to merge Sync PR [{sync_pr.number}]")
|
||||
if sync_pr.draft:
|
||||
gh.toggle_pr_draft(sync_pr)
|
||||
sync_pr.merge()
|
||||
|
||||
|
||||
def set_sync_status(gh, pr_info, sync_pr):
|
||||
if not sync_pr or sync_pr.mergeable:
|
||||
post_commit_status(get_commit(gh, pr_info.sha), FAILURE, "", "Sync PR failure", "A Sync")
|
||||
else:
|
||||
post_commit_status(get_commit(gh, pr_info.sha), SUCCESS, "", "", "A Sync")
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
assert args.merge ^ args.status
|
||||
|
||||
gh = GitHub(get_best_robot_token())
|
||||
|
||||
pr_info = PRInfo()
|
||||
@ -19,27 +73,20 @@ def main():
|
||||
query=f"head:sync-upstream/pr/{pr_info.merged_pr} org:ClickHouse type:pr",
|
||||
repo="ClickHouse/clickhouse-private",
|
||||
)
|
||||
|
||||
sync_pr = None
|
||||
|
||||
if len(prs) > 1:
|
||||
print(f"WARNING: More than one PR found [{prs}] - exiting")
|
||||
sys.exit(0)
|
||||
if len(prs) == 0:
|
||||
elif len(prs) == 0:
|
||||
print("WARNING: No Sync PR found")
|
||||
sys.exit(0)
|
||||
else:
|
||||
sync_pr = prs[0]
|
||||
|
||||
pr = prs[0]
|
||||
|
||||
if pr.state == "closed":
|
||||
print(f"Sync PR [{pr.number}] already closed - exiting")
|
||||
sys.exit(0)
|
||||
|
||||
if pr.state != "open":
|
||||
print(f"WARNING: Unknown Sync PR [{pr.number}] state [{pr.state}] - exiting")
|
||||
sys.exit(0)
|
||||
|
||||
print(f"Trying to merge Sync PR [{pr.number}]")
|
||||
if pr.draft:
|
||||
gh.toggle_pr_draft(pr)
|
||||
pr.merge()
|
||||
if args.merge:
|
||||
merge_sync_pr(gh, sync_pr)
|
||||
elif args.status:
|
||||
set_sync_status(gh, pr_info, sync_pr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user