Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #47760 to 23.2: Add a fuse for backport branches w/o a created PR #47781

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/backport_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,22 @@ on: # yamllint disable-line rule:truthy
branches:
- 'backport/**'
jobs:
CheckLabels:
runs-on: [self-hosted, style-checker]
# Run the first check always, even if the CI is cancelled
if: ${{ always() }}
steps:
- name: Check out repository code
uses: ClickHouse/checkout@v1
with:
clear-repository: true
- name: Labels check
run: |
cd "$GITHUB_WORKSPACE/tests/ci"
python3 run_check.py
PythonUnitTests:
runs-on: [self-hosted, style-checker]
needs: CheckLabels
steps:
- name: Check out repository code
uses: ClickHouse/checkout@v1
Expand All @@ -22,6 +36,7 @@ jobs:
python3 -m unittest discover -s . -p '*_test.py'
DockerHubPushAarch64:
runs-on: [self-hosted, style-checker-aarch64]
needs: CheckLabels
steps:
- name: Check out repository code
uses: ClickHouse/checkout@v1
Expand All @@ -38,6 +53,7 @@ jobs:
path: ${{ runner.temp }}/docker_images_check/changed_images_aarch64.json
DockerHubPushAmd64:
runs-on: [self-hosted, style-checker]
needs: CheckLabels
steps:
- name: Check out repository code
uses: ClickHouse/checkout@v1
Expand Down
24 changes: 17 additions & 7 deletions tests/ci/run_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ def should_run_checks_for_pr(pr_info: PRInfo) -> Tuple[bool, str, str]:
print(f"Label '{DO_NOT_TEST_LABEL}' set, skipping remaining checks")
return False, f"Labeled '{DO_NOT_TEST_LABEL}'", "success"

if OK_SKIP_LABELS.intersection(pr_info.labels):
return (
True,
"Don't try new checks for release/backports/cherry-picks",
"success",
)

if CAN_BE_TESTED_LABEL not in pr_info.labels and not pr_is_by_trusted_user(
pr_info.user_login, pr_info.user_orgs
):
Expand All @@ -103,13 +110,6 @@ def should_run_checks_for_pr(pr_info: PRInfo) -> Tuple[bool, str, str]:
)
return False, "Needs 'can be tested' label", "failure"

if OK_SKIP_LABELS.intersection(pr_info.labels):
return (
False,
"Don't try new checks for release/backports/cherry-picks",
"success",
)

return True, "No special conditions apply", "pending"


Expand Down Expand Up @@ -199,7 +199,17 @@ def check_pr_description(pr_info: PRInfo) -> Tuple[str, str]:
logging.basicConfig(level=logging.INFO)

pr_info = PRInfo(need_orgs=True, pr_event_from_api=True, need_changed_files=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:
print("::notice ::Cannot run, no PR exists for the commit")
sys.exit(1)

can_run, description, labels_state = should_run_checks_for_pr(pr_info)
if can_run and OK_SKIP_LABELS.intersection(pr_info.labels):
print("::notice :: Early finish the check, running in a special PR")
sys.exit(0)

description = format_description(description)
gh = Github(get_best_robot_token(), per_page=100)
commit = get_commit(gh, pr_info.sha)
Expand Down