mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #70804 from ClickHouse/backport/24.8/70643
Backport #70643 to 24.8: Fix buddy false alerts
This commit is contained in:
commit
1f7cf41131
@ -1,15 +1,18 @@
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from typing import Union, Dict, List
|
||||
from typing import Dict, List, Union
|
||||
|
||||
import boto3
|
||||
import requests
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
from pr_info import PRInfo
|
||||
from ci_config import CI
|
||||
from ci_utils import WithIter
|
||||
from commit_status_helper import get_commit_filtered_statuses, get_repo
|
||||
from get_robot_token import get_best_robot_token
|
||||
from github_helper import GitHub
|
||||
from pr_info import PRInfo
|
||||
|
||||
|
||||
class Channels(metaclass=WithIter):
|
||||
@ -52,7 +55,8 @@ class CIBuddy:
|
||||
self.pr_number = pr_info.number
|
||||
self.head_ref = pr_info.head_ref
|
||||
self.commit_url = pr_info.commit_html_url
|
||||
self.sha = pr_info.sha[:10]
|
||||
self.sha_full = pr_info.sha
|
||||
self.sha = self.sha_full[:10]
|
||||
|
||||
def check_workflow(self):
|
||||
CI.GH.print_workflow_results()
|
||||
@ -61,13 +65,25 @@ class CIBuddy:
|
||||
self.post_job_error(
|
||||
f"{CI.Envs.GITHUB_WORKFLOW} Workflow Failed", critical=True
|
||||
)
|
||||
else:
|
||||
return
|
||||
|
||||
res = CI.GH.get_workflow_job_result(CI.GH.ActionsNames.RunConfig)
|
||||
if res != CI.GH.ActionStatuses.SUCCESS:
|
||||
print(f"ERROR: RunConfig status is [{res}] - post report to slack")
|
||||
self.post_job_error(
|
||||
f"{CI.Envs.GITHUB_WORKFLOW} Workflow Failed", critical=True
|
||||
if res == CI.GH.ActionStatuses.SUCCESS:
|
||||
# the normal case
|
||||
return
|
||||
|
||||
gh = GitHub(get_best_robot_token())
|
||||
commit = get_repo(gh).get_commit(self.sha_full)
|
||||
statuses = get_commit_filtered_statuses(commit)
|
||||
if any(True for st in statuses if st.context == CI.StatusNames.PR_CHECK):
|
||||
print(
|
||||
f"INFO: RunConfig status is [{res}], but it "
|
||||
f'contains "{CI.StatusNames.PR_CHECK}" status, do not report error'
|
||||
)
|
||||
return
|
||||
|
||||
print(f"ERROR: RunConfig status is [{res}] - post report to slack")
|
||||
self.post_job_error(f"{CI.Envs.GITHUB_WORKFLOW} Workflow Failed", critical=True)
|
||||
|
||||
@staticmethod
|
||||
def _get_webhooks():
|
||||
|
@ -552,7 +552,7 @@ CHECK_DESCRIPTIONS = [
|
||||
CheckDescription(
|
||||
CI.StatusNames.PR_CHECK,
|
||||
"Checks correctness of the PR's body",
|
||||
lambda x: x == "PR Check",
|
||||
lambda x: x == CI.StatusNames.PR_CHECK,
|
||||
),
|
||||
CheckDescription(
|
||||
CI.StatusNames.SYNC,
|
||||
|
@ -4,8 +4,8 @@ import re
|
||||
import sys
|
||||
from typing import Tuple
|
||||
|
||||
from github import Github
|
||||
|
||||
from build_download_helper import APIException
|
||||
from ci_config import CI
|
||||
from commit_status_helper import (
|
||||
create_ci_report,
|
||||
format_description,
|
||||
@ -16,11 +16,10 @@ from commit_status_helper import (
|
||||
)
|
||||
from env_helper import GITHUB_REPOSITORY, GITHUB_SERVER_URL
|
||||
from get_robot_token import get_best_robot_token
|
||||
from ci_config import CI
|
||||
from github_helper import GitHub
|
||||
from pr_info import PRInfo
|
||||
from report import FAILURE, PENDING, SUCCESS, StatusType
|
||||
|
||||
|
||||
TRUSTED_ORG_IDS = {
|
||||
54801242, # clickhouse
|
||||
}
|
||||
@ -47,7 +46,6 @@ TRUSTED_CONTRIBUTORS = {
|
||||
}
|
||||
|
||||
OK_SKIP_LABELS = {CI.Labels.RELEASE, CI.Labels.PR_BACKPORT, CI.Labels.PR_CHERRYPICK}
|
||||
PR_CHECK = "PR Check"
|
||||
|
||||
|
||||
LABEL_CATEGORIES = {
|
||||
@ -207,11 +205,33 @@ def should_run_ci_for_pr(pr_info: PRInfo) -> Tuple[bool, str]:
|
||||
def main():
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
pr_info = PRInfo(need_orgs=True, pr_event_from_api=True, need_changed_files=True)
|
||||
fail_early = False
|
||||
try:
|
||||
pr_info = PRInfo(
|
||||
need_orgs=True, pr_event_from_api=True, need_changed_files=True
|
||||
)
|
||||
except APIException as e:
|
||||
logging.exception(
|
||||
"Failed to receive the PRInfo, backport to a simple case and exit with error",
|
||||
exc_info=e,
|
||||
)
|
||||
pr_info = PRInfo()
|
||||
fail_early = True
|
||||
|
||||
# The case for special branches like backports and releases without created
|
||||
# PRs, like merged backport branches that are reset immediately after merge
|
||||
if pr_info.number == 0:
|
||||
if pr_info.number == 0 or fail_early:
|
||||
print("::notice ::Cannot run, no PR exists for the commit")
|
||||
gh = GitHub(get_best_robot_token(), per_page=100)
|
||||
commit = get_commit(gh, pr_info.sha)
|
||||
post_commit_status(
|
||||
commit,
|
||||
FAILURE,
|
||||
"",
|
||||
"No PRs found for the commit, finished early",
|
||||
CI.StatusNames.PR_CHECK,
|
||||
pr_info,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
can_run, description = should_run_ci_for_pr(pr_info)
|
||||
@ -220,7 +240,7 @@ def main():
|
||||
sys.exit(0)
|
||||
|
||||
description = format_description(description)
|
||||
gh = Github(get_best_robot_token(), per_page=100)
|
||||
gh = GitHub(get_best_robot_token(), per_page=100)
|
||||
commit = get_commit(gh, pr_info.sha)
|
||||
status = SUCCESS # type: StatusType
|
||||
|
||||
@ -285,7 +305,7 @@ def main():
|
||||
status,
|
||||
url,
|
||||
format_description(description_error),
|
||||
PR_CHECK,
|
||||
CI.StatusNames.PR_CHECK,
|
||||
pr_info,
|
||||
)
|
||||
sys.exit(1)
|
||||
@ -310,7 +330,7 @@ def main():
|
||||
status,
|
||||
"",
|
||||
description,
|
||||
PR_CHECK,
|
||||
CI.StatusNames.PR_CHECK,
|
||||
pr_info,
|
||||
)
|
||||
print("::error ::Cannot run")
|
||||
@ -322,7 +342,7 @@ def main():
|
||||
status,
|
||||
"",
|
||||
description,
|
||||
PR_CHECK,
|
||||
CI.StatusNames.PR_CHECK,
|
||||
pr_info,
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user