From 2d500afa93f8aebda1c82b25baeeaf8a94950d85 Mon Sep 17 00:00:00 2001 From: Alex Lopez Date: Mon, 10 Aug 2026 15:11:04 +0200 Subject: [PATCH 1/9] Drop flavor concerns from junit test collection --- .gitlab/build/bazel/test.yml | 5 ++--- tasks/bazel.py | 11 +++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.gitlab/build/bazel/test.yml b/.gitlab/build/bazel/test.yml index 1a0400842b1d..39f16f558961 100644 --- a/.gitlab/build/bazel/test.yml +++ b/.gitlab/build/bazel/test.yml @@ -14,10 +14,9 @@ aud: ci-identities variables: EXTERNAL_LINKS_PATH: external_links_$CI_JOB_ID.json - FLAVOR: base - BEP_FILE: $CI_PROJECT_DIR/bazel-bep-$FLAVOR.json + BEP_FILE: $CI_PROJECT_DIR/bazel-bep.json after_script: - - dda inv -- -e bazel.collect-junit --flavor=$FLAVOR --output-tgz=junit-${CI_JOB_NAME}.tgz --bep-file=$BEP_FILE || true + - dda inv -- -e bazel.collect-junit --output-tgz=junit-${CI_JOB_NAME}.tgz --bep-file=$BEP_FILE - !reference [.upload_junit_source] artifacts: expire_in: 2 weeks diff --git a/tasks/bazel.py b/tasks/bazel.py index d733d43b2718..a52d110cf9d2 100644 --- a/tasks/bazel.py +++ b/tasks/bazel.py @@ -399,12 +399,11 @@ def _annotate_junit_cache_status(xml_path: Path, cache_status: dict[str, bool]) @task( help={ - "flavor": f"Agent flavor ({', '.join(f.name for f in AgentFlavor)}). Embedded in each JUnit XML.", "output_tgz": "Destination path for the output tgz (e.g. junit-bazel-base.tgz).", "bep_file": "Path to a Bazel BEP JSON file (--build_event_json_file); drives test.xml discovery and annotates each testsuite with bazel.cached.", }, ) -def collect_junit(ctx, flavor, output_tgz, bep_file): +def collect_junit(ctx, output_tgz, bep_file): """Collect Bazel test results and package them for junit_upload. Merges the test.xml files produced by the rules_go test runner (one per @@ -412,7 +411,7 @@ def collect_junit(ctx, flavor, output_tgz, bep_file): with the existing junit_upload machinery (same format as --junit-tar from dda inv test). """ - from tasks.libs.common.junit_upload_core import enrich_junitxml, produce_junit_tar + from tasks.libs.common.junit_upload_core import produce_junit_tar # BEP is the authoritative source: it lists exactly the test.xml files # produced by this invocation, avoiding stale results from previous runs @@ -423,8 +422,6 @@ def collect_junit(ctx, flavor, output_tgz, bep_file): print("error: no test.xml files found in BEP output", file=sys.stderr) sys.exit(1) - agent_flavor = AgentFlavor[flavor] - with tempfile.TemporaryDirectory() as tmpdir: merged = ET.Element("testsuites") collected = 0 @@ -455,11 +452,9 @@ def collect_junit(ctx, flavor, output_tgz, bep_file): ) sys.exit(1) - merged_path = Path(tmpdir) / f"junit-bazel-{flavor}.xml" + merged_path = Path(tmpdir) / "junit-bazel.xml" ET.ElementTree(merged).write(str(merged_path), encoding="unicode") - enrich_junitxml(str(merged_path), agent_flavor) - if cache_status: _annotate_junit_cache_status(merged_path, cache_status) From dda9f27682a71d6c90831c7eea200a6e0810a117 Mon Sep 17 00:00:00 2001 From: Alex Lopez Date: Mon, 10 Aug 2026 16:16:18 +0200 Subject: [PATCH 2/9] Find logs too --- tasks/bazel.py | 97 ++++++++++++++++++++++----------- tasks/unit_tests/bazel_tests.py | 76 +++++++++++++++++++++----- 2 files changed, 127 insertions(+), 46 deletions(-) diff --git a/tasks/bazel.py b/tasks/bazel.py index a52d110cf9d2..2a7849b81dcf 100644 --- a/tasks/bazel.py +++ b/tasks/bazel.py @@ -9,6 +9,7 @@ import xml.etree.ElementTree as ET from datetime import datetime from pathlib import Path +from typing import TypedDict from invoke import task @@ -100,27 +101,28 @@ def _label_to_import_path(label: str) -> str: return _IMPORT_PREFIX if not pkg_part else f"{_IMPORT_PREFIX}/{pkg_part}" -def _test_xml_candidates( +def _test_output_candidates( label: str, uri: str, cfg_id: str, local_exec_root: str | None, config_testlogs: dict[str, Path], + output_name: str, ) -> list[Path]: - """Candidate paths for test.xml, in priority order. + """Candidate paths for a Bazel test output, in priority order. BEP URIs are file:// for local actions and bytestream:// for remote-cache - hits; for the latter Bazel still materializes test.xml on disk at - //