From 30a1de32e8ede41b9b0587c759e8bcd31c9cc1fe Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Sun, 28 Jun 2026 23:46:49 +0200 Subject: [PATCH] Fix PR coverage comment posting in CI. Build the Gitea API payload with json.dumps so multiline coverage output is valid JSON, and fail the step when the API rejects the request. Co-authored-by: Cursor --- .gitea/workflows/test.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index a54db4b..c456ad6 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -40,9 +40,20 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number }} CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }} run: | - COVERAGE=$(cat coverage.txt) - COMMENT_BODY="**Test Coverage Report:**\n\`\`\`\n$COVERAGE\n\`\`\`" - curl -s -X POST "$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" \ + PAYLOAD=$(python3 -c ' + import json + import pathlib + + coverage = pathlib.Path("coverage.txt").read_text() + print( + json.dumps( + { + "body": f"**Test Coverage Report:**\n```\n{coverage}\n```", + } + ) + ) + ') + curl -sf -X POST "$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" \ -H "Authorization: token $CI_RUNNER_TOKEN" \ -H "Content-Type: application/json" \ - -d "{\"body\": \"$COMMENT_BODY\"}" + -d "$PAYLOAD"