mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
rename Simple Check to Mergeable Check, refactor processing
This commit is contained in:
parent
6d14d8d366
commit
1a52fa183d
@ -58,7 +58,7 @@ if __name__ == "__main__":
|
||||
|
||||
pr_info = PRInfo()
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, check_name)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
|
@ -4,6 +4,7 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import atexit
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
from github import Github
|
||||
@ -21,7 +22,7 @@ from get_robot_token import get_best_robot_token
|
||||
from pr_info import PRInfo
|
||||
from commit_status_helper import (
|
||||
get_commit,
|
||||
fail_simple_check,
|
||||
update_mergeable_check,
|
||||
)
|
||||
from ci_config import CI_CONFIG
|
||||
from rerun_helper import RerunHelper
|
||||
@ -154,16 +155,19 @@ def main():
|
||||
needs_data = json.load(file_handler)
|
||||
required_builds = len(needs_data)
|
||||
|
||||
# A report might be empty in case of `do not test` label, for example.
|
||||
# We should still be able to merge such PRs.
|
||||
all_skipped = needs_data is not None and all(
|
||||
if needs_data is not None and all(
|
||||
i["result"] == "skipped" for i in needs_data.values()
|
||||
)
|
||||
):
|
||||
logging.info("All builds are skipped, exiting")
|
||||
sys.exit(0)
|
||||
|
||||
logging.info("The next builds are required: %s", ", ".join(needs_data))
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
pr_info = PRInfo()
|
||||
|
||||
atexit.register(update_mergeable_check, gh, pr_info, build_check_name)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, build_check_name)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
logging.info("Check is already finished according to github status, exiting")
|
||||
@ -237,8 +241,6 @@ def main():
|
||||
total_groups = len(build_results)
|
||||
logging.info("Totally got %s artifact groups", total_groups)
|
||||
if total_groups == 0:
|
||||
if not all_skipped:
|
||||
fail_simple_check(gh, pr_info, f"{build_check_name} failed")
|
||||
logging.error("No success builds, failing check")
|
||||
sys.exit(1)
|
||||
|
||||
@ -308,8 +310,6 @@ def main():
|
||||
)
|
||||
|
||||
if summary_status == "error":
|
||||
if not all_skipped:
|
||||
fail_simple_check(gh, pr_info, f"{build_check_name} failed")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
@ -345,3 +345,11 @@ CI_CONFIG = {
|
||||
},
|
||||
},
|
||||
} # type: dict
|
||||
|
||||
# checks required by Mergeable Check
|
||||
REQUIRED_CHECKS = [
|
||||
"Fast test",
|
||||
"Style Check",
|
||||
"ClickHouse build check",
|
||||
"ClickHouse special build check",
|
||||
]
|
||||
|
@ -35,7 +35,7 @@ if __name__ == "__main__":
|
||||
|
||||
temp_path = os.getenv("TEMP_PATH", os.path.abspath("."))
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
if not os.path.exists(temp_path):
|
||||
os.makedirs(temp_path)
|
||||
|
@ -4,12 +4,13 @@ import csv
|
||||
import os
|
||||
import time
|
||||
from typing import Optional
|
||||
import logging
|
||||
|
||||
from ci_config import CI_CONFIG
|
||||
from ci_config import CI_CONFIG, REQUIRED_CHECKS
|
||||
from env_helper import GITHUB_REPOSITORY, GITHUB_RUN_URL
|
||||
from github import Github
|
||||
from github.Commit import Commit
|
||||
from pr_info import SKIP_SIMPLE_CHECK_LABEL
|
||||
from pr_info import SKIP_MERGEABLE_CHECK_LABEL
|
||||
|
||||
RETRY = 5
|
||||
|
||||
@ -82,26 +83,59 @@ def post_labels(gh, pr_info, labels_names):
|
||||
pull_request.add_to_labels(label)
|
||||
|
||||
|
||||
def fail_simple_check(gh, pr_info, description):
|
||||
if SKIP_SIMPLE_CHECK_LABEL in pr_info.labels:
|
||||
return
|
||||
commit = get_commit(gh, pr_info.sha)
|
||||
def fail_mergeable_check(commit, description):
|
||||
commit.create_status(
|
||||
context="Simple Check",
|
||||
context="Mergeable Check",
|
||||
description=description,
|
||||
state="failure",
|
||||
target_url=GITHUB_RUN_URL,
|
||||
)
|
||||
|
||||
|
||||
def create_simple_check(gh, pr_info):
|
||||
commit = get_commit(gh, pr_info.sha)
|
||||
for status in commit.get_statuses():
|
||||
if "Simple Check" in status.context:
|
||||
return
|
||||
def reset_mergeable_check(commit, description=""):
|
||||
commit.create_status(
|
||||
context="Simple Check",
|
||||
description="Skipped",
|
||||
context="Mergeable Check",
|
||||
description=description,
|
||||
state="success",
|
||||
target_url=GITHUB_RUN_URL,
|
||||
)
|
||||
|
||||
|
||||
def update_mergeable_check(gh, pr_info, check_name):
|
||||
if SKIP_MERGEABLE_CHECK_LABEL in pr_info.labels:
|
||||
return
|
||||
|
||||
logging.info("Update Mergeable Check by %s", check_name)
|
||||
|
||||
commit = get_commit(gh, pr_info.sha)
|
||||
checks = {
|
||||
check.context: check.state
|
||||
for check in filter(
|
||||
lambda check: (check.context in REQUIRED_CHECKS),
|
||||
# get_statuses() returns generator, which cannot be reversed - we need comprehension
|
||||
# pylint: disable=unnecessary-comprehension
|
||||
reversed([status for status in commit.get_statuses()]),
|
||||
)
|
||||
}
|
||||
|
||||
success = []
|
||||
fail = []
|
||||
for name, state in checks.items():
|
||||
if state == "success":
|
||||
success.append(name)
|
||||
else:
|
||||
fail.append(name)
|
||||
|
||||
if fail:
|
||||
description = "failed: " + ", ".join(fail)
|
||||
if success:
|
||||
description += "; succeeded: " + ", ".join(success)
|
||||
if len(description) > 140:
|
||||
description = description[:137] + "..."
|
||||
fail_mergeable_check(commit, description)
|
||||
return
|
||||
|
||||
description = ", ".join(success)
|
||||
if len(description) > 140:
|
||||
description = description[:137] + "..."
|
||||
reset_mergeable_check(commit, description)
|
||||
|
@ -119,7 +119,7 @@ if __name__ == "__main__":
|
||||
|
||||
pr_info = PRInfo()
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, CHECK_NAME)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
|
@ -477,7 +477,7 @@ def main():
|
||||
if not args.reports:
|
||||
return
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
post_commit_status(gh, pr_info.sha, NAME, description, status, url)
|
||||
|
||||
prepared_events = prepare_tests_results_for_clickhouse(
|
||||
|
@ -221,7 +221,7 @@ def main():
|
||||
if len(description) >= 140:
|
||||
description = description[:136] + "..."
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
post_commit_status(gh, pr_info.sha, NAME, description, status, url)
|
||||
|
||||
prepared_events = prepare_tests_results_for_clickhouse(
|
||||
|
@ -351,7 +351,7 @@ def main():
|
||||
if len(description) >= 140:
|
||||
description = description[:136] + "..."
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
post_commit_status(gh, pr_info.sha, NAME, description, status, url)
|
||||
|
||||
prepared_events = prepare_tests_results_for_clickhouse(
|
||||
|
@ -47,7 +47,7 @@ if __name__ == "__main__":
|
||||
|
||||
pr_info = PRInfo(need_changed_files=True)
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, NAME)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
|
@ -39,7 +39,7 @@ if __name__ == "__main__":
|
||||
temp_path = TEMP_PATH
|
||||
repo_path = REPO_COPY
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
pr_info = PRInfo()
|
||||
rerun_helper = RerunHelper(gh, pr_info, NAME)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
|
@ -5,6 +5,7 @@ import subprocess
|
||||
import os
|
||||
import csv
|
||||
import sys
|
||||
import atexit
|
||||
|
||||
from github import Github
|
||||
|
||||
@ -16,7 +17,7 @@ from upload_result_helper import upload_results
|
||||
from docker_pull_helper import get_image_with_version
|
||||
from commit_status_helper import (
|
||||
post_commit_status,
|
||||
fail_simple_check,
|
||||
update_mergeable_check,
|
||||
)
|
||||
from clickhouse_helper import (
|
||||
ClickHouseHelper,
|
||||
@ -93,7 +94,9 @@ if __name__ == "__main__":
|
||||
|
||||
pr_info = PRInfo()
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
atexit.register(update_mergeable_check, gh, pr_info, NAME)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, NAME)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
@ -222,5 +225,4 @@ if __name__ == "__main__":
|
||||
if FORCE_TESTS_LABEL in pr_info.labels and state != "error":
|
||||
print(f"'{FORCE_TESTS_LABEL}' enabled, will report success")
|
||||
else:
|
||||
fail_simple_check(gh, pr_info, f"{NAME} failed")
|
||||
sys.exit(1)
|
||||
|
@ -30,7 +30,7 @@ if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
pr_info = PRInfo(need_orgs=True)
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
commit = get_commit(gh, pr_info.sha)
|
||||
|
||||
url = GITHUB_RUN_URL
|
||||
|
@ -205,7 +205,7 @@ if __name__ == "__main__":
|
||||
flaky_check = "flaky" in check_name.lower()
|
||||
|
||||
run_changed_tests = flaky_check or validate_bugix_check
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
pr_info = PRInfo(need_changed_files=run_changed_tests)
|
||||
|
||||
|
@ -15,7 +15,7 @@ def get_best_robot_token(token_prefix_env_name="github_robot_token_", total_toke
|
||||
for i in range(1, total_tokens + 1):
|
||||
token_name = token_prefix_env_name + str(i)
|
||||
token = get_parameter_from_ssm(token_name, True, client)
|
||||
gh = Github(token)
|
||||
gh = Github(token, per_page=100)
|
||||
rest, _ = gh.rate_limiting
|
||||
tokens[token] = rest
|
||||
|
||||
|
@ -180,7 +180,7 @@ if __name__ == "__main__":
|
||||
logging.info("Skipping '%s' (no pr-bugfix)", check_name)
|
||||
sys.exit(0)
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, check_name_with_group)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
|
@ -159,7 +159,7 @@ if __name__ == "__main__":
|
||||
logging.info("Not jepsen test label in labels list, skipping")
|
||||
sys.exit(0)
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, CHECK_NAME)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
|
@ -80,7 +80,7 @@ if __name__ == "__main__":
|
||||
with open(GITHUB_EVENT_PATH, "r", encoding="utf-8") as event_file:
|
||||
event = json.load(event_file)
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
pr_info = PRInfo(event)
|
||||
commit = get_commit(gh, pr_info.sha)
|
||||
|
||||
|
@ -15,7 +15,7 @@ from env_helper import (
|
||||
)
|
||||
|
||||
FORCE_TESTS_LABEL = "force tests"
|
||||
SKIP_SIMPLE_CHECK_LABEL = "skip simple check"
|
||||
SKIP_MERGEABLE_CHECK_LABEL = "skip mergeable check"
|
||||
|
||||
DIFF_IN_DOCUMENTATION_EXT = [
|
||||
".html",
|
||||
|
@ -10,7 +10,7 @@ from commit_status_helper import (
|
||||
get_commit,
|
||||
post_labels,
|
||||
remove_labels,
|
||||
create_simple_check,
|
||||
reset_mergeable_check,
|
||||
)
|
||||
from env_helper import GITHUB_RUN_URL, GITHUB_REPOSITORY, GITHUB_SERVER_URL
|
||||
from get_robot_token import get_best_robot_token
|
||||
@ -196,7 +196,7 @@ if __name__ == "__main__":
|
||||
|
||||
pr_info = PRInfo(need_orgs=True, pr_event_from_api=True, need_changed_files=True)
|
||||
can_run, description, labels_state = should_run_checks_for_pr(pr_info)
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
commit = get_commit(gh, pr_info.sha)
|
||||
|
||||
description_error, category = check_pr_description(pr_info)
|
||||
@ -228,7 +228,7 @@ if __name__ == "__main__":
|
||||
if pr_labels_to_remove:
|
||||
remove_labels(gh, pr_info, pr_labels_to_remove)
|
||||
|
||||
create_simple_check(gh, pr_info)
|
||||
reset_mergeable_check(commit, "skipped")
|
||||
|
||||
if description_error:
|
||||
print(
|
||||
|
@ -76,7 +76,7 @@ if __name__ == "__main__":
|
||||
|
||||
pr_info = PRInfo()
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, CHECK_NAME)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
|
@ -109,7 +109,7 @@ if __name__ == "__main__":
|
||||
|
||||
pr_info = PRInfo()
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, check_name)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
|
@ -5,6 +5,7 @@ import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import atexit
|
||||
|
||||
|
||||
from clickhouse_helper import (
|
||||
@ -12,7 +13,7 @@ from clickhouse_helper import (
|
||||
mark_flaky_tests,
|
||||
prepare_tests_results_for_clickhouse,
|
||||
)
|
||||
from commit_status_helper import fail_simple_check, post_commit_status
|
||||
from commit_status_helper import post_commit_status, update_mergeable_check
|
||||
from docker_pull_helper import get_image_with_version
|
||||
from env_helper import GITHUB_WORKSPACE, RUNNER_TEMP
|
||||
from get_robot_token import get_best_robot_token
|
||||
@ -150,6 +151,8 @@ if __name__ == "__main__":
|
||||
|
||||
gh = GitHub(get_best_robot_token())
|
||||
|
||||
atexit.register(update_mergeable_check, gh, pr_info, NAME)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, NAME)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
logging.info("Check is already finished according to github status, exiting")
|
||||
@ -202,5 +205,4 @@ if __name__ == "__main__":
|
||||
ch_helper.insert_events_into(db="default", table="checks", events=prepared_events)
|
||||
|
||||
if state in ["error", "failure"]:
|
||||
fail_simple_check(gh, pr_info, f"{NAME} failed")
|
||||
sys.exit(1)
|
||||
|
@ -114,7 +114,7 @@ if __name__ == "__main__":
|
||||
|
||||
pr_info = PRInfo()
|
||||
|
||||
gh = Github(get_best_robot_token())
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
|
||||
rerun_helper = RerunHelper(gh, pr_info, check_name)
|
||||
if rerun_helper.is_already_finished_by_status():
|
||||
|
Loading…
Reference in New Issue
Block a user