ci(atlasbot): discover junit/coverage artifacts robustly

This commit is contained in:
jenkins 2026-04-20 11:01:15 -03:00
parent b9970d3847
commit d750f21e80

View File

@ -220,6 +220,22 @@ def main() -> int:
source_root = Path(os.getenv("SOURCE_ROOT", "atlasbot")) source_root = Path(os.getenv("SOURCE_ROOT", "atlasbot"))
build_dir = Path(os.getenv("BUILD_DIR", "build")) build_dir = Path(os.getenv("BUILD_DIR", "build"))
if not junit_path.exists():
junit_candidates = sorted(build_dir.glob("junit*.xml"))
if junit_candidates:
junit_path = junit_candidates[0]
if not coverage_path.exists():
for candidate in (
build_dir / "coverage.json",
build_dir / "coverage-summary.json",
build_dir / "coverage" / "coverage-summary.json",
):
if candidate.exists():
coverage_path = candidate
break
print(f"[metrics] junit_path={junit_path} exists={junit_path.exists()}")
print(f"[metrics] coverage_path={coverage_path} exists={coverage_path.exists()}")
totals = _load_junit(junit_path) totals = _load_junit(junit_path)
test_cases = _load_junit_cases(junit_path) test_cases = _load_junit_cases(junit_path)
coverage_pct = _load_coverage_percent(coverage_path) coverage_pct = _load_coverage_percent(coverage_path)
@ -275,10 +291,6 @@ def main() -> int:
) + "\n" ) + "\n"
else: else:
payload += f'platform_quality_gate_test_case_result{{suite="{suite}",test="__no_test_cases__",status="skipped"}} 1\n' payload += f'platform_quality_gate_test_case_result{{suite="{suite}",test="__no_test_cases__",status="skipped"}} 1\n'
payload += "\n".join(
f'platform_quality_gate_test_case_result{{suite="{suite}",test="{_escape_label(test_name)}",status="{_escape_label(test_status)}"}} 1'
for test_name, test_status in test_cases
) + "\n"
payload += "\n".join( payload += "\n".join(
f'atlasbot_quality_gate_checks_total{{suite="{suite}",check="{check_name}",result="{check_status}"}} 1' f'atlasbot_quality_gate_checks_total{{suite="{suite}",check="{check_name}",result="{check_status}"}} 1'
for check_name, check_status in checks.items() for check_name, check_status in checks.items()