diff --git a/tests/ci/ci.py b/tests/ci/ci.py index be922a306e1..99555b06bbf 100644 --- a/tests/ci/ci.py +++ b/tests/ci/ci.py @@ -45,6 +45,7 @@ from env_helper import ( S3_BUILDS_BUCKET, TEMP_PATH, GITHUB_RUN_ID, + GITHUB_REPOSITORY, ) from get_robot_token import get_best_robot_token from git_helper import GIT_PREFIX, Git @@ -1913,7 +1914,7 @@ def _cancel_pr_wf(s3: S3Helper, pr_number: int) -> None: print(f"ERROR: FIX IT: Run id has not been found PR [{pr_number}]!") else: print(f"Canceling PR workflow run_id: [{run_id}], pr: [{pr_number}]") - GitHub.cancel_wf(run_id) + GitHub.cancel_wf(GITHUB_REPOSITORY, get_best_robot_token(), run_id) def main() -> int: diff --git a/tests/ci/github_helper.py b/tests/ci/github_helper.py index 81603c66bae..eb0f6c24527 100644 --- a/tests/ci/github_helper.py +++ b/tests/ci/github_helper.py @@ -22,9 +22,6 @@ from github.NamedUser import NamedUser as NamedUser from github.PullRequest import PullRequest as PullRequest from github.Repository import Repository as Repository -from env_helper import GITHUB_REPOSITORY -from get_robot_token import get_best_robot_token - # pylint: enable=useless-import-alias CACHE_PATH = p.join(p.dirname(p.realpath(__file__)), "gh_cache") @@ -265,12 +262,11 @@ class GitHub(github.Github): assert isinstance(value, int) self._retries = value - # minimalistic static methods not using pygithub + # static methods not using pygithub @staticmethod - def cancel_wf(run_id, strict=False): - token = get_best_robot_token() + def cancel_wf(repo, run_id, token, strict=False): headers = {"Authorization": f"token {token}"} - url = f"https://api.github.com/repos/{GITHUB_REPOSITORY}/actions/runs/{run_id}/cancel" + url = f"https://api.github.com/repos/{repo}/actions/runs/{run_id}/cancel" try: response = requests.post(url, headers=headers, timeout=10) response.raise_for_status()