mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Add ci_config.StatusNames class for common statuses
This commit is contained in:
parent
2ba5b7fd23
commit
76911c9fca
@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from copy import deepcopy
|
|
||||||
import logging
|
import logging
|
||||||
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
|
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
|
||||||
|
from copy import deepcopy
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable, Dict, Iterable, List, Literal, Optional, Union
|
from typing import Callable, Dict, Iterable, List, Literal, Optional, Union
|
||||||
@ -181,6 +181,13 @@ class JobNames(metaclass=WithIter):
|
|||||||
BUGFIX_VALIDATE = "Bugfix validation"
|
BUGFIX_VALIDATE = "Bugfix validation"
|
||||||
|
|
||||||
|
|
||||||
|
class StatusNames(metaclass=WithIter):
|
||||||
|
"Class with statuses that aren't related to particular jobs"
|
||||||
|
CI = "CI running"
|
||||||
|
MERGEABLE = "Mergeable Check"
|
||||||
|
SYNC = "A Sync"
|
||||||
|
|
||||||
|
|
||||||
# dynamically update JobName with Build jobs
|
# dynamically update JobName with Build jobs
|
||||||
for attr_name in dir(Build):
|
for attr_name in dir(Build):
|
||||||
if not attr_name.startswith("__") and not callable(getattr(Build, attr_name)):
|
if not attr_name.startswith("__") and not callable(getattr(Build, attr_name)):
|
||||||
@ -1348,7 +1355,7 @@ CI_CONFIG.validate()
|
|||||||
# checks required by Mergeable Check
|
# checks required by Mergeable Check
|
||||||
REQUIRED_CHECKS = [
|
REQUIRED_CHECKS = [
|
||||||
"PR Check",
|
"PR Check",
|
||||||
"A Sync", # Cloud sync
|
StatusNames.SYNC,
|
||||||
JobNames.BUILD_CHECK,
|
JobNames.BUILD_CHECK,
|
||||||
JobNames.BUILD_CHECK_SPECIAL,
|
JobNames.BUILD_CHECK_SPECIAL,
|
||||||
JobNames.DOCS_CHECK,
|
JobNames.DOCS_CHECK,
|
||||||
@ -1461,9 +1468,9 @@ CHECK_DESCRIPTIONS = [
|
|||||||
lambda x: x.startswith("Integration tests ("),
|
lambda x: x.startswith("Integration tests ("),
|
||||||
),
|
),
|
||||||
CheckDescription(
|
CheckDescription(
|
||||||
"Mergeable Check",
|
StatusNames.MERGEABLE,
|
||||||
"Checks if all other necessary checks are successful",
|
"Checks if all other necessary checks are successful",
|
||||||
lambda x: x == "Mergeable Check",
|
lambda x: x == StatusNames.MERGEABLE,
|
||||||
),
|
),
|
||||||
CheckDescription(
|
CheckDescription(
|
||||||
"Performance Comparison",
|
"Performance Comparison",
|
||||||
|
@ -17,7 +17,7 @@ from github.GithubObject import NotSet
|
|||||||
from github.IssueComment import IssueComment
|
from github.IssueComment import IssueComment
|
||||||
from github.Repository import Repository
|
from github.Repository import Repository
|
||||||
|
|
||||||
from ci_config import CHECK_DESCRIPTIONS, REQUIRED_CHECKS, CheckDescription
|
from ci_config import CHECK_DESCRIPTIONS, REQUIRED_CHECKS, CheckDescription, StatusNames
|
||||||
from env_helper import GITHUB_REPOSITORY, GITHUB_RUN_URL, TEMP_PATH
|
from env_helper import GITHUB_REPOSITORY, GITHUB_RUN_URL, TEMP_PATH
|
||||||
from lambda_shared_package.lambda_shared.pr import Labels
|
from lambda_shared_package.lambda_shared.pr import Labels
|
||||||
from pr_info import PRInfo
|
from pr_info import PRInfo
|
||||||
@ -36,9 +36,7 @@ from upload_result_helper import upload_results
|
|||||||
|
|
||||||
RETRY = 5
|
RETRY = 5
|
||||||
CommitStatuses = List[CommitStatus]
|
CommitStatuses = List[CommitStatus]
|
||||||
MERGEABLE_NAME = "Mergeable Check"
|
|
||||||
GH_REPO = None # type: Optional[Repository]
|
GH_REPO = None # type: Optional[Repository]
|
||||||
CI_STATUS_NAME = "CI running"
|
|
||||||
STATUS_FILE_PATH = Path(TEMP_PATH) / "status.json"
|
STATUS_FILE_PATH = Path(TEMP_PATH) / "status.json"
|
||||||
|
|
||||||
|
|
||||||
@ -159,16 +157,16 @@ def set_status_comment(commit: Commit, pr_info: PRInfo) -> None:
|
|||||||
if not statuses:
|
if not statuses:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not [status for status in statuses if status.context == CI_STATUS_NAME]:
|
if not [status for status in statuses if status.context == StatusNames.CI]:
|
||||||
# This is the case, when some statuses already exist for the check,
|
# This is the case, when some statuses already exist for the check,
|
||||||
# but not the CI_STATUS_NAME. We should create it as pending.
|
# but not the StatusNames.CI. We should create it as pending.
|
||||||
# W/o pr_info to avoid recursion, and yes, one extra create_ci_report
|
# W/o pr_info to avoid recursion, and yes, one extra create_ci_report
|
||||||
post_commit_status(
|
post_commit_status(
|
||||||
commit,
|
commit,
|
||||||
PENDING,
|
PENDING,
|
||||||
create_ci_report(pr_info, statuses),
|
create_ci_report(pr_info, statuses),
|
||||||
"The report for running CI",
|
"The report for running CI",
|
||||||
CI_STATUS_NAME,
|
StatusNames.CI,
|
||||||
)
|
)
|
||||||
|
|
||||||
# We update the report in generate_status_comment function, so do it each
|
# We update the report in generate_status_comment function, so do it each
|
||||||
@ -300,7 +298,7 @@ def create_ci_report(pr_info: PRInfo, statuses: CommitStatuses) -> str:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return upload_results(
|
return upload_results(
|
||||||
S3Helper(), pr_info.number, pr_info.sha, test_results, [], CI_STATUS_NAME
|
S3Helper(), pr_info.number, pr_info.sha, test_results, [], StatusNames.CI
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -429,7 +427,7 @@ def set_mergeable_check(
|
|||||||
state: StatusType = SUCCESS,
|
state: StatusType = SUCCESS,
|
||||||
) -> None:
|
) -> None:
|
||||||
commit.create_status(
|
commit.create_status(
|
||||||
context=MERGEABLE_NAME,
|
context=StatusNames.MERGEABLE,
|
||||||
description=format_description(description),
|
description=format_description(description),
|
||||||
state=state,
|
state=state,
|
||||||
target_url=GITHUB_RUN_URL,
|
target_url=GITHUB_RUN_URL,
|
||||||
@ -457,14 +455,14 @@ def update_mergeable_check(commit: Commit, pr_info: PRInfo, check_name: str) ->
|
|||||||
|
|
||||||
|
|
||||||
def trigger_mergeable_check(commit: Commit, statuses: CommitStatuses) -> None:
|
def trigger_mergeable_check(commit: Commit, statuses: CommitStatuses) -> None:
|
||||||
"""calculate and update MERGEABLE_NAME"""
|
"""calculate and update StatusNames.MERGEABLE"""
|
||||||
required_checks = [
|
required_checks = [
|
||||||
status for status in statuses if status.context in REQUIRED_CHECKS
|
status for status in statuses if status.context in REQUIRED_CHECKS
|
||||||
]
|
]
|
||||||
|
|
||||||
mergeable_status = None
|
mergeable_status = None
|
||||||
for status in statuses:
|
for status in statuses:
|
||||||
if status.context == MERGEABLE_NAME:
|
if status.context == StatusNames.MERGEABLE:
|
||||||
mergeable_status = status
|
mergeable_status = status
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ import logging
|
|||||||
|
|
||||||
from github import Github
|
from github import Github
|
||||||
|
|
||||||
|
from ci_config import StatusNames
|
||||||
from commit_status_helper import (
|
from commit_status_helper import (
|
||||||
CI_STATUS_NAME,
|
|
||||||
get_commit,
|
get_commit,
|
||||||
get_commit_filtered_statuses,
|
get_commit_filtered_statuses,
|
||||||
post_commit_status,
|
post_commit_status,
|
||||||
@ -26,7 +26,7 @@ def main():
|
|||||||
trigger_mergeable_check(commit, statuses)
|
trigger_mergeable_check(commit, statuses)
|
||||||
|
|
||||||
if not pr_info.is_merge_queue:
|
if not pr_info.is_merge_queue:
|
||||||
statuses = [s for s in statuses if s.context == CI_STATUS_NAME]
|
statuses = [s for s in statuses if s.context == StatusNames.CI]
|
||||||
if not statuses:
|
if not statuses:
|
||||||
return
|
return
|
||||||
# Take the latest status
|
# Take the latest status
|
||||||
@ -37,7 +37,7 @@ def main():
|
|||||||
SUCCESS,
|
SUCCESS,
|
||||||
status.target_url,
|
status.target_url,
|
||||||
"All checks finished",
|
"All checks finished",
|
||||||
CI_STATUS_NAME,
|
StatusNames.CI,
|
||||||
pr_info,
|
pr_info,
|
||||||
dump_to_file=True,
|
dump_to_file=True,
|
||||||
)
|
)
|
||||||
|
@ -5,9 +5,8 @@ from typing import Tuple
|
|||||||
|
|
||||||
from github import Github
|
from github import Github
|
||||||
|
|
||||||
from cherry_pick import Labels
|
from ci_config import StatusNames
|
||||||
from commit_status_helper import (
|
from commit_status_helper import (
|
||||||
CI_STATUS_NAME,
|
|
||||||
create_ci_report,
|
create_ci_report,
|
||||||
format_description,
|
format_description,
|
||||||
get_commit,
|
get_commit,
|
||||||
@ -206,7 +205,7 @@ def main():
|
|||||||
PENDING,
|
PENDING,
|
||||||
ci_report_url,
|
ci_report_url,
|
||||||
description,
|
description,
|
||||||
CI_STATUS_NAME,
|
StatusNames.CI,
|
||||||
pr_info,
|
pr_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5,10 +5,11 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from get_robot_token import get_best_robot_token
|
from ci_config import StatusNames
|
||||||
from pr_info import PRInfo
|
|
||||||
from github_helper import GitHub
|
|
||||||
from commit_status_helper import get_commit, post_commit_status
|
from commit_status_helper import get_commit, post_commit_status
|
||||||
|
from get_robot_token import get_best_robot_token
|
||||||
|
from github_helper import GitHub
|
||||||
|
from pr_info import PRInfo
|
||||||
from report import SUCCESS
|
from report import SUCCESS
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ def set_sync_status(gh, pr_info, sync_pr):
|
|||||||
# FIXME: uncomment posting red Sync status to prohibit merge in MQ if PR state fetching works good
|
# FIXME: uncomment posting red Sync status to prohibit merge in MQ if PR state fetching works good
|
||||||
if not sync_pr:
|
if not sync_pr:
|
||||||
# post_commit_status(
|
# post_commit_status(
|
||||||
# get_commit(gh, pr_info.sha), FAILURE, "", "Sync PR not found", "A Sync"
|
# get_commit(gh, pr_info.sha), FAILURE, "", "Sync PR not found", StatusNames.SYNC
|
||||||
# )
|
# )
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -73,7 +74,9 @@ def set_sync_status(gh, pr_info, sync_pr):
|
|||||||
|
|
||||||
if sync_pr.mergeable_state == "clean":
|
if sync_pr.mergeable_state == "clean":
|
||||||
print(f"Sync PR [{sync_pr.number}] is clean")
|
print(f"Sync PR [{sync_pr.number}] is clean")
|
||||||
post_commit_status(get_commit(gh, pr_info.sha), SUCCESS, "", "", "A Sync")
|
post_commit_status(
|
||||||
|
get_commit(gh, pr_info.sha), SUCCESS, "", "", StatusNames.SYNC
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
f"Sync PR [{sync_pr}] is not mergeable, state [{sync_pr.mergeable_state}]"
|
f"Sync PR [{sync_pr}] is not mergeable, state [{sync_pr.mergeable_state}]"
|
||||||
@ -83,7 +86,7 @@ def set_sync_status(gh, pr_info, sync_pr):
|
|||||||
# FAILURE,
|
# FAILURE,
|
||||||
# "",
|
# "",
|
||||||
# f"state: {sync_pr.mergeable_state}",
|
# f"state: {sync_pr.mergeable_state}",
|
||||||
# "A Sync",
|
# StatusNames.SYNC,
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user