Skip to content

Commit

Permalink
fix: update GHA notice to new format (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
jd authored Feb 6, 2025
1 parent 2b04b1c commit 082b719
Showing 4 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion mergify_cli/ci/junit.py
Original file line number Diff line number Diff line change
@@ -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,
@@ -88,6 +87,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")
7 changes: 2 additions & 5 deletions mergify_cli/ci/upload.py
Original file line number Diff line number Diff line change
@@ -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,
1 change: 0 additions & 1 deletion mergify_cli/tests/ci/test_junit.py
Original file line number Diff line number Diff line change
@@ -27,7 +27,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",
6 changes: 4 additions & 2 deletions mergify_cli/tests/ci/test_upload.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 082b719

Please sign in to comment.