mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
CI: CheckReadyForMerge fixes
This commit is contained in:
parent
3111f0f32f
commit
529f21c6b8
7
.github/workflows/backport_branches.yml
vendored
7
.github/workflows/backport_branches.yml
vendored
@ -260,13 +260,18 @@ jobs:
|
||||
- name: Finish label
|
||||
if: ${{ !failure() }}
|
||||
run: |
|
||||
export WORKFLOW_RESULT_FILE="/tmp/workflow_results.json"
|
||||
cat > "$WORKFLOW_RESULT_FILE" << 'EOF'
|
||||
${{ toJson(needs) }}
|
||||
EOF
|
||||
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||
# update mergeable check
|
||||
python3 merge_pr.py --set-ci-status --wf-status ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
|
||||
python3 merge_pr.py --set-ci-status
|
||||
# update overall ci report
|
||||
python3 finish_check.py --wf-status ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
|
||||
python3 merge_pr.py
|
||||
- name: Check Workflow results
|
||||
if: ${{ !cancelled() }}
|
||||
run: |
|
||||
export WORKFLOW_RESULT_FILE="/tmp/workflow_results.json"
|
||||
cat > "$WORKFLOW_RESULT_FILE" << 'EOF'
|
||||
|
1
.github/workflows/jepsen.yml
vendored
1
.github/workflows/jepsen.yml
vendored
@ -64,6 +64,7 @@ jobs:
|
||||
- name: Check out repository code
|
||||
uses: ClickHouse/checkout@v1
|
||||
- name: Check Workflow results
|
||||
if: ${{ !cancelled() }}
|
||||
run: |
|
||||
export WORKFLOW_RESULT_FILE="/tmp/workflow_results.json"
|
||||
cat >> "$WORKFLOW_RESULT_FILE" << 'EOF'
|
||||
|
7
.github/workflows/merge_queue.yml
vendored
7
.github/workflows/merge_queue.yml
vendored
@ -103,9 +103,14 @@ jobs:
|
||||
- name: Check and set merge status
|
||||
if: ${{ needs.StyleCheck.result == 'success' }}
|
||||
run: |
|
||||
export WORKFLOW_RESULT_FILE="/tmp/workflow_results.json"
|
||||
cat > "$WORKFLOW_RESULT_FILE" << 'EOF'
|
||||
${{ toJson(needs) }}
|
||||
EOF
|
||||
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||
python3 merge_pr.py --set-ci-status --wf-status ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
|
||||
python3 merge_pr.py --set-ci-status
|
||||
- name: Check Workflow results
|
||||
if: ${{ !cancelled() }}
|
||||
run: |
|
||||
export WORKFLOW_RESULT_FILE="/tmp/workflow_results.json"
|
||||
cat > "$WORKFLOW_RESULT_FILE" << 'EOF'
|
||||
|
1
.github/workflows/nightly.yml
vendored
1
.github/workflows/nightly.yml
vendored
@ -52,6 +52,7 @@ jobs:
|
||||
- name: Check out repository code
|
||||
uses: ClickHouse/checkout@v1
|
||||
- name: Check Workflow results
|
||||
if: ${{ !cancelled() }}
|
||||
run: |
|
||||
export WORKFLOW_RESULT_FILE="/tmp/workflow_results.json"
|
||||
cat > "$WORKFLOW_RESULT_FILE" << 'EOF'
|
||||
|
6
.github/workflows/pull_request.yml
vendored
6
.github/workflows/pull_request.yml
vendored
@ -170,7 +170,11 @@ jobs:
|
||||
if: ${{ needs.StyleCheck.result == 'success' }}
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||
python3 merge_pr.py --set-ci-status --wf-status ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
|
||||
export WORKFLOW_RESULT_FILE="/tmp/workflow_results.json"
|
||||
cat > "$WORKFLOW_RESULT_FILE" << 'EOF'
|
||||
${{ toJson(needs) }}
|
||||
EOF
|
||||
python3 merge_pr.py --set-ci-status
|
||||
- name: Check Workflow results
|
||||
uses: ./.github/actions/check_workflow
|
||||
with:
|
||||
|
4
.github/workflows/release_branches.yml
vendored
4
.github/workflows/release_branches.yml
vendored
@ -481,12 +481,10 @@ jobs:
|
||||
- name: Finish label
|
||||
if: ${{ !failure() }}
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||
# update mergeable check
|
||||
python3 merge_pr.py --set-ci-status --wf-status ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
|
||||
# update overall ci report
|
||||
python3 finish_check.py --wf-status ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
|
||||
- name: Check Workflow results
|
||||
if: ${{ !cancelled() }}
|
||||
run: |
|
||||
export WORKFLOW_RESULT_FILE="/tmp/workflow_results.json"
|
||||
cat > "$WORKFLOW_RESULT_FILE" << 'EOF'
|
||||
|
@ -687,6 +687,34 @@ class CI:
|
||||
assert res, f"not a build [{build_name}] or invalid JobConfig"
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def is_workflow_ok(cls) -> bool:
|
||||
# TODO: temporary method to make Mergeable check working
|
||||
res = cls.GH.get_workflow_results()
|
||||
if not res:
|
||||
print("ERROR: no workflow results found")
|
||||
return False
|
||||
for workflow_job, workflow_data in res.items():
|
||||
status = workflow_data["result"]
|
||||
if status in (
|
||||
cls.GH.ActionStatuses.SUCCESS,
|
||||
cls.GH.ActionStatuses.SKIPPED,
|
||||
):
|
||||
print(f"Workflow status for [{workflow_job}] is [{status}] - continue")
|
||||
elif status in (cls.GH.ActionStatuses.FAILURE,):
|
||||
if workflow_job in (
|
||||
WorkflowStages.TESTS_2,
|
||||
WorkflowStages.TESTS_2_WW,
|
||||
):
|
||||
print(
|
||||
f"Failed Workflow status for [{workflow_job}], it's not required - continue"
|
||||
)
|
||||
continue
|
||||
|
||||
print(f"Failed Workflow status for [{workflow_job}]")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser(
|
||||
|
@ -94,9 +94,10 @@ class GH:
|
||||
FAILURE = "failure"
|
||||
PENDING = "pending"
|
||||
SUCCESS = "success"
|
||||
SKIPPED = "skipped"
|
||||
|
||||
@classmethod
|
||||
def _get_workflow_results(cls):
|
||||
def get_workflow_results(cls):
|
||||
if not Path(Envs.WORKFLOW_RESULT_FILE).exists():
|
||||
print(
|
||||
f"ERROR: Failed to get workflow results from file [{Envs.WORKFLOW_RESULT_FILE}]"
|
||||
@ -115,13 +116,13 @@ class GH:
|
||||
|
||||
@classmethod
|
||||
def print_workflow_results(cls):
|
||||
res = cls._get_workflow_results()
|
||||
res = cls.get_workflow_results()
|
||||
results = [f"{job}: {data['result']}" for job, data in res.items()]
|
||||
cls.print_in_group("Workflow results", results)
|
||||
|
||||
@classmethod
|
||||
def is_workflow_ok(cls) -> bool:
|
||||
res = cls._get_workflow_results()
|
||||
res = cls.get_workflow_results()
|
||||
for _job, data in res.items():
|
||||
if data["result"] == "failure":
|
||||
return False
|
||||
@ -129,7 +130,7 @@ class GH:
|
||||
|
||||
@classmethod
|
||||
def get_workflow_job_result(cls, wf_job_name: str) -> Optional[str]:
|
||||
res = cls._get_workflow_results()
|
||||
res = cls.get_workflow_results()
|
||||
if wf_job_name in res:
|
||||
return res[wf_job_name]["result"] # type: ignore
|
||||
else:
|
||||
|
@ -23,7 +23,7 @@ from commit_status_helper import (
|
||||
from get_robot_token import get_best_robot_token
|
||||
from github_helper import GitHub, NamedUser, PullRequest, Repository
|
||||
from pr_info import PRInfo
|
||||
from report import SUCCESS, FAILURE
|
||||
from report import SUCCESS
|
||||
from env_helper import GITHUB_UPSTREAM_REPOSITORY, GITHUB_REPOSITORY
|
||||
from synchronizer_utils import SYNC_BRANCH_PREFIX
|
||||
from ci_config import CI
|
||||
@ -248,23 +248,27 @@ def main():
|
||||
repo = gh.get_repo(args.repo)
|
||||
|
||||
if args.set_ci_status:
|
||||
CI.GH.print_workflow_results()
|
||||
# set Mergeable check status and exit
|
||||
assert args.wf_status in (FAILURE, SUCCESS)
|
||||
commit = get_commit(gh, args.pr_info.sha)
|
||||
statuses = get_commit_filtered_statuses(commit)
|
||||
|
||||
has_failed_statuses = False
|
||||
has_native_failed_status = False
|
||||
for status in statuses:
|
||||
print(f"Check status [{status.context}], [{status.state}]")
|
||||
if CI.is_required(status.context) and status.state != SUCCESS:
|
||||
print(f"WARNING: Failed status [{status.context}], [{status.state}]")
|
||||
if (
|
||||
CI.is_required(status.context)
|
||||
and status.state != SUCCESS
|
||||
and status.context != CI.StatusNames.SYNC
|
||||
):
|
||||
print(
|
||||
f"WARNING: Not success status [{status.context}], [{status.state}]"
|
||||
)
|
||||
has_failed_statuses = True
|
||||
if status.context != CI.StatusNames.SYNC:
|
||||
has_native_failed_status = True
|
||||
|
||||
if args.wf_status == SUCCESS or has_failed_statuses:
|
||||
# set Mergeable check if workflow is successful (green)
|
||||
workflow_ok = CI.is_workflow_ok()
|
||||
if workflow_ok or has_failed_statuses:
|
||||
# set Mergeable Check if workflow is successful (green)
|
||||
# or if we have GH statuses with failures (red)
|
||||
# to avoid false-green on a died runner
|
||||
state = trigger_mergeable_check(
|
||||
@ -283,7 +287,7 @@ def main():
|
||||
print(
|
||||
"Workflow failed but no failed statuses found (died runner?) - cannot set Mergeable Check status"
|
||||
)
|
||||
if args.wf_status == SUCCESS and not has_native_failed_status:
|
||||
if workflow_ok and not has_failed_statuses:
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user