From 6ff7322408b1ea40d14a35e828df77ee7c8236e9 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Thu, 6 Jun 2024 15:58:19 +0200 Subject: [PATCH] feat(tests): update_fixtures.py: github run_id [no changelog] --- tests/github.py | 3 ++- tests/update_fixtures.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/github.py b/tests/github.py index 4353d45a5..359c37432 100644 --- a/tests/github.py +++ b/tests/github.py @@ -27,6 +27,7 @@ def get_branch_ui_fixtures_results( branch_name: str, only_jobs: Iterable[str] | None, exclude_jobs: Iterable[str] | None, + run_id: int | None, ) -> dict[str, AnyDict]: print(f"Checking branch {branch_name}") @@ -34,7 +35,7 @@ def get_branch_ui_fixtures_results( LIST_RUNS_TEMPLATE.format(branch=branch_name, workflow="core.yml") ) response.raise_for_status() - run_id = response.json()["workflow_runs"][0]["id"] + run_id = run_id or response.json()["workflow_runs"][0]["id"] def yield_key_value() -> Iterator[tuple[str, AnyDict]]: for model in MODELS: diff --git a/tests/update_fixtures.py b/tests/update_fixtures.py index 2e78773d5..61bff3eb5 100755 --- a/tests/update_fixtures.py +++ b/tests/update_fixtures.py @@ -42,6 +42,7 @@ def _get_current_git_branch() -> str: help="Fetch from GitHub Actions instead of GitLab CI", ) @click.option("-b", "--branch", help="Branch name") +@click.option("-r", "--run-id", help="GitHub Actions run id", type=int) @click.option( "-o", "--only-jobs", @@ -58,6 +59,7 @@ def _get_current_git_branch() -> str: def ci( github: bool, branch: str | None, + run_id: int | None, only_jobs: Iterable[str] | None, exclude_jobs: Iterable[str] | None, remove_missing: bool, @@ -80,7 +82,9 @@ def ci( if github: from github import get_branch_ui_fixtures_results - ui_results = get_branch_ui_fixtures_results(branch, only_jobs, exclude_jobs) + ui_results = get_branch_ui_fixtures_results( + branch, only_jobs, exclude_jobs, run_id + ) else: from gitlab import get_branch_ui_fixtures_results, get_jobs_of_interest