From 375c069d297f770a3b837571b5ff6f9c43600751 Mon Sep 17 00:00:00 2001 From: Vladimir Milosevic <157983820+vmilosevic@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:11:43 +0200 Subject: [PATCH] Always upload test results (#498) Upload test results always, even if "Run Test" failed Add card_type mapping --- .github/workflows/build-and-test.yml | 2 ++ infra/src/utils.py | 43 +++++----------------------- infra/test/test_generate_data.py | 7 ++++- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2bcbbc673..7d4ada904 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -94,6 +94,7 @@ jobs: - name: Upload Test Log uses: actions/upload-artifact@v4 + if: success() || failure() with: name: test-log-${{ matrix.build.runs-on }} path: pytest.log @@ -106,6 +107,7 @@ jobs: - name: Upload Test Report uses: actions/upload-artifact@v4 + if: success() || failure() with: name: test-reports-${{ matrix.build.runs-on }} path: ${{ steps.strings.outputs.test_report_path }} diff --git a/infra/src/utils.py b/infra/src/utils.py index 72f927874..901ca3691 100644 --- a/infra/src/utils.py +++ b/infra/src/utils.py @@ -144,42 +144,13 @@ def get_job_row_from_github_job(github_job): assert github_job["status"] == "completed", f"{github_job_id} is not completed" - # Best effort card type getting - - get_overlap = lambda labels_a, labels_b: set(labels_a) & set(labels_b) - labels_have_overlap = lambda labels_a, labels_b: bool(get_overlap(labels_a, labels_b)) - - try: - detected_config = return_first_string_starts_with("config-", labels).replace("config-", "") - except Exception as e: - logger.error(e) - logger.info("Seems to have no config- label, so assuming no special config requested") - detected_config = None - - if labels_have_overlap(["E150", "grayskull", "arch-grayskull"], labels): - detected_arch = "grayskull" - elif labels_have_overlap(["N150", "N300", "wormhole_b0", "arch-wormhole_b0"], labels): - detected_arch = "wormhole_b0" - elif labels_have_overlap(["BH", "arch-blackhole"], labels): - detected_arch = "blackhole" - else: - detected_arch = None - - single_cards_list = ("E150", "N150", "N300", "BH") - single_cards_overlap = get_overlap(single_cards_list, labels) - - # In order of preference - if detected_config: - if not detected_arch: - raise Exception(f"There must be an arch detected for config {detected_config}") - card_type = f"{detected_config}-{detected_arch}" - elif single_cards_overlap: - logger.info(f"Detected overlap in single cards: {single_cards_overlap}") - card_type = list(single_cards_overlap)[0] - elif detected_arch: - card_type = detected_arch - else: - card_type = None + # Determine card type based on runner name + runner_name = (github_job.get("runner_name") or "").upper() + card_type = None + for card in ["E150", "N150", "N300", "BH"]: + if card in runner_name: + card_type = card + break job_submission_ts = github_job["created_at"] diff --git a/infra/test/test_generate_data.py b/infra/test/test_generate_data.py index 127a93a63..341e1f327 100644 --- a/infra/test/test_generate_data.py +++ b/infra/test/test_generate_data.py @@ -4,6 +4,7 @@ from generate_data import create_pipeline_json import os +import json def test_create_pipeline_json(): @@ -18,5 +19,9 @@ def test_create_pipeline_json(): workflow_outputs_dir="test/data", ) - assert pipeline is not None assert os.path.exists(filename) + + # assert pipeline json file has the correct + with open(filename, "r") as file: + data = json.load(file) + assert data["jobs"][0]["card_type"] == "N300"