Merge pull request #39307 from ClickHouse/ci-simple-check-fix-rerun

Simple Check should be updated on rerun
This commit is contained in:
Mikhail f. Shiryaev 2022-07-21 13:01:59 +02:00 committed by GitHub
commit c24800c7d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 40 deletions

View File

@ -3,8 +3,9 @@
import time
import os
import csv
from env_helper import GITHUB_REPOSITORY
from env_helper import GITHUB_REPOSITORY, GITHUB_RUN_URL
from ci_config import CI_CONFIG
from pr_info import SKIP_SIMPLE_CHECK_LABEL
RETRY = 5
@ -73,3 +74,28 @@ def post_labels(gh, pr_info, labels_names):
pull_request = repo.get_pull(pr_info.number)
for label in 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)
commit.create_status(
context="Simple 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
commit.create_status(
context="Simple Check",
description="Skipped",
state="success",
target_url=GITHUB_RUN_URL,
)

View File

@ -8,13 +8,16 @@ import sys
from github import Github
from env_helper import CACHES_PATH, TEMP_PATH, GITHUB_SERVER_URL, GITHUB_REPOSITORY
from pr_info import FORCE_TESTS_LABEL, PRInfo, SKIP_SIMPLE_CHECK_LABEL
from env_helper import CACHES_PATH, TEMP_PATH
from pr_info import FORCE_TESTS_LABEL, PRInfo
from s3_helper import S3Helper
from get_robot_token import get_best_robot_token
from upload_result_helper import upload_results
from docker_pull_helper import get_image_with_version
from commit_status_helper import post_commit_status, get_commit
from commit_status_helper import (
post_commit_status,
fail_simple_check,
)
from clickhouse_helper import (
ClickHouseHelper,
mark_flaky_tests,
@ -219,16 +222,5 @@ if __name__ == "__main__":
if FORCE_TESTS_LABEL in pr_info.labels and state != "error":
print(f"'{FORCE_TESTS_LABEL}' enabled, will report success")
else:
if SKIP_SIMPLE_CHECK_LABEL not in pr_info.labels:
url = (
f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}/"
"blob/master/.github/PULL_REQUEST_TEMPLATE.md?plain=1"
)
commit = get_commit(gh, pr_info.sha)
commit.create_status(
context="Simple Check",
description=f"{NAME} failed",
state="failed",
target_url=url,
)
fail_simple_check(gh, pr_info, f"{NAME} failed")
sys.exit(1)

View File

@ -36,3 +36,9 @@ class RerunHelper:
):
return True
return False
def get_finished_status(self):
for status in self.statuses:
if self.check_name in status.context:
return status
return None

View File

@ -6,7 +6,12 @@ from typing import Tuple
from github import Github
from commit_status_helper import get_commit, post_labels, remove_labels
from commit_status_helper import (
get_commit,
post_labels,
remove_labels,
create_simple_check,
)
from env_helper import GITHUB_RUN_URL, GITHUB_REPOSITORY, GITHUB_SERVER_URL
from get_robot_token import get_best_robot_token
from pr_info import FORCE_TESTS_LABEL, PRInfo
@ -223,12 +228,7 @@ if __name__ == "__main__":
if pr_labels_to_remove:
remove_labels(gh, pr_info, pr_labels_to_remove)
commit.create_status(
context="Simple Check",
description="Skipped",
state="success",
target_url=GITHUB_RUN_URL,
)
create_simple_check(gh, pr_info)
if description_error:
print(

View File

@ -10,15 +10,16 @@ from github import Github
from env_helper import (
RUNNER_TEMP,
GITHUB_WORKSPACE,
GITHUB_REPOSITORY,
GITHUB_SERVER_URL,
)
from s3_helper import S3Helper
from pr_info import PRInfo, SKIP_SIMPLE_CHECK_LABEL
from pr_info import PRInfo
from get_robot_token import get_best_robot_token
from upload_result_helper import upload_results
from docker_pull_helper import get_image_with_version
from commit_status_helper import post_commit_status, get_commit
from commit_status_helper import (
post_commit_status,
fail_simple_check,
)
from clickhouse_helper import (
ClickHouseHelper,
mark_flaky_tests,
@ -124,17 +125,6 @@ if __name__ == "__main__":
)
ch_helper.insert_events_into(db="default", table="checks", events=prepared_events)
if state == "error":
if SKIP_SIMPLE_CHECK_LABEL not in pr_info.labels:
url = (
f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}/"
"blob/master/.github/PULL_REQUEST_TEMPLATE.md?plain=1"
)
commit = get_commit(gh, pr_info.sha)
commit.create_status(
context="Simple Check",
description=f"{NAME} failed",
state="failed",
target_url=url,
)
if state in ["error", "failure"]:
fail_simple_check(gh, pr_info, f"{NAME} failed")
sys.exit(1)