Skip to content

Commit 18ea280

Browse files
authored
fix: use console print instead of log for annotation (#565)
`console.log` may wrap or add some whitespaces at end of the annotation.
1 parent a2a7e2d commit 18ea280

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

mergify_cli/ci/junit_upload.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,8 @@ async def upload( # noqa: PLR0913, PLR0917
7878
)
7979

8080
gigid = response.json()["gigid"]
81-
console.log(f"::notice title=CI Issues report::CI_ISSUE_GIGID={gigid}")
81+
console.print(
82+
f"::notice title=CI Issues report::CI_ISSUE_GIGID={gigid}",
83+
soft_wrap=True,
84+
)
8285
console.log("[green]:tada: File(s) uploaded[/]")

mergify_cli/tests/ci_issues/test_junit_upload.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,16 @@ def test_get_files_to_upload() -> None:
131131
assert files_to_upload[0][1][1].closed
132132

133133

134-
async def test_junit_upload(respx_mock: respx.MockRouter) -> None:
134+
async def test_junit_upload(
135+
respx_mock: respx.MockRouter,
136+
capsys: pytest.CaptureFixture[str],
137+
) -> None:
138+
gigid = "eyJjaV9qb2JfaWQiOjcwNzQyLCJzaWduYXR1cmUiOiI2NjcxN2QwZDdiZjZkMzAxMmFmNGE4NWQ1YTFlZDhmYjNkNDBjYmM4MmZjZjgxZTVmNzEzNzEyZjRlZjIxOTFmIn0="
135139
respx_mock.post(
136140
"/v1/repos/user/repo/ci_issues_upload",
137141
).respond(
138142
200,
139-
json={"gigid": "1234azertyuiop"},
143+
json={"gigid": gigid},
140144
)
141145

142146
await junit_upload_mod.upload(
@@ -149,6 +153,12 @@ async def test_junit_upload(respx_mock: respx.MockRouter) -> None:
149153
(str(REPORT_XML),),
150154
)
151155

156+
captured = capsys.readouterr()
157+
assert (
158+
captured.out.split("\n")[0]
159+
== f"::notice title=CI Issues report::CI_ISSUE_GIGID={gigid}"
160+
)
161+
152162

153163
async def test_junit_upload_http_error(respx_mock: respx.MockRouter) -> None:
154164
respx_mock.post("/v1/repos/user/repo/ci_issues_upload").respond(

0 commit comments

Comments
 (0)