diff --git a/mergify_cli/ci/junit.py b/mergify_cli/ci/junit.py index f3c0b61f..589d1b8c 100644 --- a/mergify_cli/ci/junit.py +++ b/mergify_cli/ci/junit.py @@ -34,7 +34,6 @@ class InvalidJunitXMLError(Exception): async def junit_to_spans( - trace_id: int, xml_content: bytes, test_language: str | None = None, test_framework: str | None = None, @@ -82,6 +81,8 @@ async def junit_to_spans( resource = resources.Resource.create(resource_attributes) + trace_id = ID_GENERATOR.generate_trace_id() + for testsuite in testsuites: min_start_time = now suite_name = testsuite.get("name", "unnamed testsuite") diff --git a/mergify_cli/ci/upload.py b/mergify_cli/ci/upload.py index 17f0a9de..2c93e73c 100644 --- a/mergify_cli/ci/upload.py +++ b/mergify_cli/ci/upload.py @@ -57,9 +57,9 @@ def upload_spans( def connect_traces(spans: list[ReadableSpan]) -> None: if detector.get_ci_provider() == "github_actions" and spans: - trace_id = spans[0].context.trace_id + root_span_id = spans[0].context.span_id console.print( - f"::notice title=Mergify CI::MERGIFY_TRACE_ID={trace_id}", + f"::notice title=Mergify CI::MERGIFY_TEST_ROOT_SPAN_ID={root_span_id}", soft_wrap=True, ) @@ -74,13 +74,10 @@ async def upload( # noqa: PLR0913, PLR0917 ) -> None: spans = [] - trace_id = junit.ID_GENERATOR.generate_trace_id() - for filename in files: try: spans.extend( await junit.junit_to_spans( - trace_id, pathlib.Path(filename).read_bytes(), test_language=test_language, test_framework=test_framework, diff --git a/mergify_cli/tests/ci/test_junit.py b/mergify_cli/tests/ci/test_junit.py index 2ab0c130..d0b10759 100644 --- a/mergify_cli/tests/ci/test_junit.py +++ b/mergify_cli/tests/ci/test_junit.py @@ -23,7 +23,6 @@ async def test_parse( ) -> None: filename = pathlib.Path(__file__).parent / "junit_example.xml" spans = await junit.junit_to_spans( - 123, filename.read_bytes(), "python", "unittest", diff --git a/mergify_cli/tests/ci/test_upload.py b/mergify_cli/tests/ci/test_upload.py index d8dc989f..70a2f9c4 100644 --- a/mergify_cli/tests/ci/test_upload.py +++ b/mergify_cli/tests/ci/test_upload.py @@ -63,11 +63,13 @@ async def test_junit_upload( captured = capsys.readouterr() if env["GITHUB_ACTIONS"] == "true": - assert re.search( - r"^::notice title=Mergify CI::MERGIFY_TRACE_ID=\d+", + matched = re.search( + r"^::notice title=Mergify CI::MERGIFY_TEST_ROOT_SPAN_ID=(\d+)", captured.out, re.MULTILINE, ) + assert matched is not None + assert int(matched.group(1)) > 0 assert "🎉 File(s) uploaded" in captured.out