mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Fix issues with garbage DB events from orphane branches
This commit is contained in:
parent
eeb25267e5
commit
e85a9852e7
@ -1268,6 +1268,7 @@ def main() -> int:
|
|||||||
s3,
|
s3,
|
||||||
pr_info.number,
|
pr_info.number,
|
||||||
pr_info.sha,
|
pr_info.sha,
|
||||||
|
pr_info.head_ref,
|
||||||
job_report.test_results,
|
job_report.test_results,
|
||||||
job_report.additional_files,
|
job_report.additional_files,
|
||||||
job_report.check_name or _get_ext_check_name(args.job_name),
|
job_report.check_name or _get_ext_check_name(args.job_name),
|
||||||
@ -1335,6 +1336,7 @@ def main() -> int:
|
|||||||
s3,
|
s3,
|
||||||
pr_info.number,
|
pr_info.number,
|
||||||
pr_info.sha,
|
pr_info.sha,
|
||||||
|
pr_info.head_ref,
|
||||||
job_report.test_results,
|
job_report.test_results,
|
||||||
job_report.additional_files,
|
job_report.additional_files,
|
||||||
job_report.check_name or _get_ext_check_name(args.job_name),
|
job_report.check_name or _get_ext_check_name(args.job_name),
|
||||||
|
@ -9,6 +9,7 @@ from typing import Any, Dict, List, Optional
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
from env_helper import GITHUB_REPOSITORY
|
||||||
from get_robot_token import get_parameter_from_ssm
|
from get_robot_token import get_parameter_from_ssm
|
||||||
from pr_info import PRInfo
|
from pr_info import PRInfo
|
||||||
from report import TestResults
|
from report import TestResults
|
||||||
@ -211,17 +212,13 @@ def prepare_tests_results_for_clickhouse(
|
|||||||
report_url: str,
|
report_url: str,
|
||||||
check_name: str,
|
check_name: str,
|
||||||
) -> List[dict]:
|
) -> List[dict]:
|
||||||
pull_request_url = "https://github.com/ClickHouse/ClickHouse/commits/master"
|
|
||||||
base_ref = "master"
|
|
||||||
head_ref = "master"
|
|
||||||
base_repo = pr_info.repo_full_name
|
|
||||||
head_repo = pr_info.repo_full_name
|
|
||||||
if pr_info.number != 0:
|
|
||||||
pull_request_url = pr_info.pr_html_url
|
|
||||||
base_ref = pr_info.base_ref
|
base_ref = pr_info.base_ref
|
||||||
base_repo = pr_info.base_name
|
base_repo = pr_info.base_name
|
||||||
head_ref = pr_info.head_ref
|
head_ref = pr_info.head_ref
|
||||||
head_repo = pr_info.head_name
|
head_repo = pr_info.head_name
|
||||||
|
pull_request_url = f"https://github.com/{GITHUB_REPOSITORY}/commits/{head_ref}"
|
||||||
|
if pr_info.number != 0:
|
||||||
|
pull_request_url = pr_info.pr_html_url
|
||||||
|
|
||||||
common_properties = {
|
common_properties = {
|
||||||
"pull_request_number": pr_info.number,
|
"pull_request_number": pr_info.number,
|
||||||
|
@ -315,7 +315,13 @@ 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.StatusNames.CI
|
S3Helper(),
|
||||||
|
pr_info.number,
|
||||||
|
pr_info.sha,
|
||||||
|
pr_info.head_ref,
|
||||||
|
test_results,
|
||||||
|
[],
|
||||||
|
CI.StatusNames.CI,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,7 +250,9 @@ def main():
|
|||||||
s3_helper = S3Helper()
|
s3_helper = S3Helper()
|
||||||
|
|
||||||
pr_info = PRInfo()
|
pr_info = PRInfo()
|
||||||
url = upload_results(s3_helper, pr_info.number, pr_info.sha, test_results, [], NAME)
|
url = upload_results(
|
||||||
|
s3_helper, pr_info.number, pr_info.sha, pr_info.head_ref, test_results, [], NAME
|
||||||
|
)
|
||||||
|
|
||||||
print(f"::notice ::Report url: {url}")
|
print(f"::notice ::Report url: {url}")
|
||||||
|
|
||||||
|
@ -183,7 +183,9 @@ def main():
|
|||||||
pr_info = PRInfo()
|
pr_info = PRInfo()
|
||||||
s3_helper = S3Helper()
|
s3_helper = S3Helper()
|
||||||
|
|
||||||
url = upload_results(s3_helper, pr_info.number, pr_info.sha, test_results, [], NAME)
|
url = upload_results(
|
||||||
|
s3_helper, pr_info.number, pr_info.sha, pr_info.head_ref, test_results, [], NAME
|
||||||
|
)
|
||||||
|
|
||||||
print(f"::notice ::Report url: {url}")
|
print(f"::notice ::Report url: {url}")
|
||||||
|
|
||||||
|
@ -132,6 +132,12 @@ class PRInfo:
|
|||||||
ref = github_event.get("ref", "refs/heads/master")
|
ref = github_event.get("ref", "refs/heads/master")
|
||||||
if ref and ref.startswith("refs/heads/"):
|
if ref and ref.startswith("refs/heads/"):
|
||||||
ref = ref[11:]
|
ref = ref[11:]
|
||||||
|
# Default values
|
||||||
|
self.base_ref = "" # type: str
|
||||||
|
self.base_name = "" # type: str
|
||||||
|
self.head_ref = "" # type: str
|
||||||
|
self.head_name = "" # type: str
|
||||||
|
self.number = 0 # type: int
|
||||||
|
|
||||||
# workflow completed event, used for PRs only
|
# workflow completed event, used for PRs only
|
||||||
if "action" in github_event and github_event["action"] == "completed":
|
if "action" in github_event and github_event["action"] == "completed":
|
||||||
@ -146,7 +152,7 @@ class PRInfo:
|
|||||||
|
|
||||||
if "pull_request" in github_event: # pull request and other similar events
|
if "pull_request" in github_event: # pull request and other similar events
|
||||||
self.event_type = EventType.PULL_REQUEST
|
self.event_type = EventType.PULL_REQUEST
|
||||||
self.number = github_event["pull_request"]["number"] # type: int
|
self.number = github_event["pull_request"]["number"]
|
||||||
if pr_event_from_api:
|
if pr_event_from_api:
|
||||||
try:
|
try:
|
||||||
response = get_gh_api(
|
response = get_gh_api(
|
||||||
@ -172,17 +178,13 @@ class PRInfo:
|
|||||||
self.pr_html_url = f"{repo_prefix}/pull/{self.number}"
|
self.pr_html_url = f"{repo_prefix}/pull/{self.number}"
|
||||||
|
|
||||||
# master or backport/xx.x/xxxxx - where the PR will be merged
|
# master or backport/xx.x/xxxxx - where the PR will be merged
|
||||||
self.base_ref = github_event["pull_request"]["base"]["ref"] # type: str
|
self.base_ref = github_event["pull_request"]["base"]["ref"]
|
||||||
# ClickHouse/ClickHouse
|
# ClickHouse/ClickHouse
|
||||||
self.base_name = github_event["pull_request"]["base"]["repo"][
|
self.base_name = github_event["pull_request"]["base"]["repo"]["full_name"]
|
||||||
"full_name"
|
|
||||||
] # type: str
|
|
||||||
# any_branch-name - the name of working branch name
|
# any_branch-name - the name of working branch name
|
||||||
self.head_ref = github_event["pull_request"]["head"]["ref"] # type: str
|
self.head_ref = github_event["pull_request"]["head"]["ref"]
|
||||||
# UserName/ClickHouse or ClickHouse/ClickHouse
|
# UserName/ClickHouse or ClickHouse/ClickHouse
|
||||||
self.head_name = github_event["pull_request"]["head"]["repo"][
|
self.head_name = github_event["pull_request"]["head"]["repo"]["full_name"]
|
||||||
"full_name"
|
|
||||||
] # type: str
|
|
||||||
self.body = github_event["pull_request"]["body"]
|
self.body = github_event["pull_request"]["body"]
|
||||||
self.labels = {
|
self.labels = {
|
||||||
label["name"] for label in github_event["pull_request"]["labels"]
|
label["name"] for label in github_event["pull_request"]["labels"]
|
||||||
|
@ -64,6 +64,7 @@ def upload_results(
|
|||||||
s3_client: S3Helper,
|
s3_client: S3Helper,
|
||||||
pr_number: int,
|
pr_number: int,
|
||||||
commit_sha: str,
|
commit_sha: str,
|
||||||
|
branch_name: str,
|
||||||
test_results: TestResults,
|
test_results: TestResults,
|
||||||
additional_files: Union[Sequence[Path], Sequence[str]],
|
additional_files: Union[Sequence[Path], Sequence[str]],
|
||||||
check_name: str,
|
check_name: str,
|
||||||
@ -80,8 +81,7 @@ def upload_results(
|
|||||||
process_logs(s3_client, additional_files, s3_path_prefix, test_results)
|
process_logs(s3_client, additional_files, s3_path_prefix, test_results)
|
||||||
)
|
)
|
||||||
|
|
||||||
branch_url = f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}/commits/master"
|
branch_url = f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}/commits/{branch_name}"
|
||||||
branch_name = "master"
|
|
||||||
if pr_number != 0:
|
if pr_number != 0:
|
||||||
branch_name = f"PR #{pr_number}"
|
branch_name = f"PR #{pr_number}"
|
||||||
branch_url = f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}/pull/{pr_number}"
|
branch_url = f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}/pull/{pr_number}"
|
||||||
|
Loading…
Reference in New Issue
Block a user