From 965c2ff5cad648514c16f345fa67e16dff3676dc Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Mon, 30 Nov 2026 20:38:01 +0000 Subject: [PATCH] fix(watch): cut an upstream report too long for an issue Signed-off-by: noelmcloughlin --- .github/scripts/report-issue.sh | 26 +++++++++++++++++++++----- CHANGELOG.md | 4 ++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/scripts/report-issue.sh b/.github/scripts/report-issue.sh index fd90659..df905e0 100755 --- a/.github/scripts/report-issue.sh +++ b/.github/scripts/report-issue.sh @@ -4,6 +4,9 @@ # # The body is the check's Markdown report from "$RUNNER_TEMP/report.md", or # a note that the check stopped before writing one, plus a link to the run. +# The whole report also goes to the run's summary page. GitHub refuses an +# issue or comment body over 65,536 characters, so a longer report is cut at +# a line end below that, and the body says where the rest is. # # Usage (in a workflow step): TITLE=... GH_TOKEN=... .github/scripts/report-issue.sh set -euo pipefail @@ -11,19 +14,32 @@ set -euo pipefail : "${TITLE:?set TITLE to the issue title}" report="${RUNNER_TEMP:?}/report.md" body="${RUNNER_TEMP}/issue-body.md" +run="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" +# Bytes, never fewer than characters, so the cut body is under GitHub's limit. +limit=60000 + +if [ -s "$report" ] && [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then + cat "$report" >> "$GITHUB_STEP_SUMMARY" +fi { - if [ -s "$report" ]; then + if [ ! -s "$report" ]; then + echo "The check stopped before writing a report, for example on a network error." + elif [ "$(wc -c < "$report")" -le "$limit" ]; then cat "$report" else - echo "The check stopped before writing a report, for example on a network error." + # The last line is dropped, since the cut may fall inside it. + head -c "$limit" "$report" | sed '$d' + echo + echo "The report is longer than an issue can hold, so it stops here. The whole report is on the run's summary page." fi echo - echo "Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + echo "Run: $run" } > "$body" -# gh's --search is fuzzy, so match the exact title before reusing an issue. -number="$(gh issue list --repo "$GITHUB_REPOSITORY" --state open \ +# gh's --search is fuzzy, so match the exact title before reusing an issue. Only an issue +# this workflow opened is reused, so anyone who opens one with the same title first is ignored. +number="$(gh issue list --repo "$GITHUB_REPOSITORY" --state open --author app/github-actions \ --search "in:title \"$TITLE\"" --json number,title \ --jq 'map(select(.title == env.TITLE)) | .[0].number // empty')" diff --git a/CHANGELOG.md b/CHANGELOG.md index 15f66c4..f35661b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The `v0.0.0` tag is a baseline, not a release: it marks where versioning starts ## [Unreleased] +### Fixed + +- **An upstream-watch report too long for an issue is cut below GitHub's limit, and the whole report goes on the run's summary page.** + ## [0.2.3] - 2026-11-16 ### Fixed