Skip to content

Commit 082b719

Browse files
authored
fix: update GHA notice to new format (#612)
1 parent 2b04b1c commit 082b719

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

mergify_cli/ci/junit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class InvalidJunitXMLError(Exception):
3434

3535

3636
async def junit_to_spans(
37-
trace_id: int,
3837
xml_content: bytes,
3938
test_language: str | None = None,
4039
test_framework: str | None = None,
@@ -88,6 +87,8 @@ async def junit_to_spans(
8887

8988
resource = resources.Resource.create(resource_attributes)
9089

90+
trace_id = ID_GENERATOR.generate_trace_id()
91+
9192
for testsuite in testsuites:
9293
min_start_time = now
9394
suite_name = testsuite.get("name", "unnamed testsuite")

mergify_cli/ci/upload.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def upload_spans(
5757

5858
def connect_traces(spans: list[ReadableSpan]) -> None:
5959
if detector.get_ci_provider() == "github_actions" and spans:
60-
trace_id = spans[0].context.trace_id
60+
root_span_id = spans[0].context.span_id
6161
console.print(
62-
f"::notice title=Mergify CI::MERGIFY_TRACE_ID={trace_id}",
62+
f"::notice title=Mergify CI::MERGIFY_TEST_ROOT_SPAN_ID={root_span_id}",
6363
soft_wrap=True,
6464
)
6565

@@ -74,13 +74,10 @@ async def upload( # noqa: PLR0913, PLR0917
7474
) -> None:
7575
spans = []
7676

77-
trace_id = junit.ID_GENERATOR.generate_trace_id()
78-
7977
for filename in files:
8078
try:
8179
spans.extend(
8280
await junit.junit_to_spans(
83-
trace_id,
8481
pathlib.Path(filename).read_bytes(),
8582
test_language=test_language,
8683
test_framework=test_framework,

mergify_cli/tests/ci/test_junit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ async def test_parse(
2727
) -> None:
2828
filename = pathlib.Path(__file__).parent / "junit_example.xml"
2929
spans = await junit.junit_to_spans(
30-
123,
3130
filename.read_bytes(),
3231
"python",
3332
"unittest",

mergify_cli/tests/ci/test_upload.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ async def test_junit_upload(
6363

6464
captured = capsys.readouterr()
6565
if env["GITHUB_ACTIONS"] == "true":
66-
assert re.search(
67-
r"^::notice title=Mergify CI::MERGIFY_TRACE_ID=\d+",
66+
matched = re.search(
67+
r"^::notice title=Mergify CI::MERGIFY_TEST_ROOT_SPAN_ID=(\d+)",
6868
captured.out,
6969
re.MULTILINE,
7070
)
71+
assert matched is not None
72+
assert int(matched.group(1)) > 0
7173

7274
assert "🎉 File(s) uploaded" in captured.out
7375

0 commit comments

Comments
 (0)