Do not report critical alarm into slack on failed run_check.py

This commit is contained in:
Mikhail f. Shiryaev 2024-10-14 17:51:26 +02:00
parent 58a249263c
commit 450a1ecf0c
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -9,6 +9,9 @@ from botocore.exceptions import ClientError
from ci_config import CI
from ci_utils import WithIter
from commit_status_helper import get_commit_filtered_statuses, get_repo
from get_robot_token import get_best_robot_token
from github_helper import GitHub
from pr_info import PRInfo
@ -52,7 +55,8 @@ class CIBuddy:
self.pr_number = pr_info.number
self.head_ref = pr_info.head_ref
self.commit_url = pr_info.commit_html_url
self.sha = pr_info.sha[:10]
self.sha_full = pr_info.sha
self.sha = self.sha_full[:10]
def check_workflow(self):
CI.GH.print_workflow_results()
@ -64,11 +68,22 @@ class CIBuddy:
return
res = CI.GH.get_workflow_job_result(CI.GH.ActionsNames.RunConfig)
if res != CI.GH.ActionStatuses.SUCCESS:
print(f"ERROR: RunConfig status is [{res}] - post report to slack")
self.post_job_error(
f"{CI.Envs.GITHUB_WORKFLOW} Workflow Failed", critical=True
if res == CI.GH.ActionStatuses.SUCCESS:
# the normal case
return
gh = GitHub(get_best_robot_token())
commit = get_repo(gh).get_commit(self.sha_full)
statuses = get_commit_filtered_statuses(commit)
if any(True for st in statuses if st.context == CI.StatusNames.PR_CHECK):
print(
f"INFO: RunConfig status is [{res}], but it "
f'contains "{CI.StatusNames.PR_CHECK}" status, do not report error'
)
return
print(f"ERROR: RunConfig status is [{res}] - post report to slack")
self.post_job_error(f"{CI.Envs.GITHUB_WORKFLOW} Workflow Failed", critical=True)
@staticmethod
def _get_webhooks():