Skip to content

Fix: Keep gh stderr out of the release JSON - #137

Merged
ModeSevenIndustrialSolutions merged 1 commit into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-136
Nov 5, 2026
Merged

ModeSevenIndustrialSolutions merged 1 commit into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-136

Conversation

@lf-releng-code-monkey-bot

@lf-releng-code-monkey-bot lf-releng-code-monkey-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #136

Authored by an AI agent; human review required
Command Exit
bash tests/test-release-check-promoted.sh 0
prek run --all-files 0
aislop scan --changes --base 1297261cdcc5a9fb3cef683a45fd1f7944d36bb2 --json 0
prek run --hook-stage commit-msg --commit-msg-filename <HEAD message> (fails only on replay-added bot Signed-off-by length) 1
prek run --hook-stage commit-msg --commit-msg-filename <HEAD message without bot trailer> 0
git log --raw --format=%h 1297261cdcc5a9fb3cef683a45fd1f7944d36bb2..HEAD 0

The github-code-monkey-bot workflow opened this pull request.
Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds; a maintainer must act on any finding that remains after that, and reviews every round before merge.

Round 3 of revision, on its base.


What this pull request does

Fixes #136. The check-promoted step in .github/workflows/release.yaml captured gh release view with stderr merged into stdout, so a warning gh printed on success broke the jq parse. Under bash -eo pipefail the step failed, even on an idempotent re-run. Without -e it fell through to promoting a release that was already published.

  • The step now captures stdout only. It sends stderr to a temporary file and reports that file's contents when gh fails.
  • jq failures, such as a missing jq or a response that is not JSON, exit 1 with jq's own error.
  • isDraft must be exactly true or false. Any other value is an ::error:: that names it, followed by exit 1. The already_promoted output is unchanged.
  • No other reusable workflow in this repository parses a $(… 2>&1) capture on its success path.
  • New tests/test-release-check-promoted.sh extracts the step's run: block and runs it under bash -eo pipefail against a stub gh, with 11 cases. It runs as the release-check-promoted-fixtures prek hook. That hook is listed under ci.skip because pre-commit.ci has no jq. The Linting (self, ci.skip) job runs it on GitHub's runners instead.

This round (3)

Following the maintainer's decision on Copilot's two mktemp threads, each mktemp call this change adds now uses an explicit template under ${TMPDIR:-/tmp}:

  • release.yaml: stderr_file=$(mktemp "${TMPDIR:-/tmp}/check-promoted.XXXXXX")
  • tests/test-release-check-promoted.sh: work="$(mktemp -d "${TMPDIR:-/tmp}/test-release-check-promoted.XXXXXX")"

mktemp is still in the no-jq case's tool list, and the other tests/test-*.sh scripts are unchanged. I amended the single commit and left the title as it was. I did not rebase, because the PR is mergeable and nobody asked for a rebase.

What I ran

  • bash tests/test-release-check-promoted.sh: 11 passed, exit 0
  • prek run --all-files: exit 0
  • aislop scan --changes against the base: no diagnostics
  • gitlint (commit-msg stage): it passes, apart from the replay-added bot Signed-off-by trailer, which is longer than 80 characters. The workflow replaces that trailer.

For the reviewer

Please confirm that Linting (self, ci.skip) / Lint: release-check-promoted-fixtures ran and passed on the new head. This session cannot see checks.

This comment was marked as outdated.

@ModeSevenIndustrialSolutions

Copy link
Copy Markdown
Member

Maintainer instruction for the next revision round. pre-commit.ci fails this pull request on Release already-promoted check fixtures; every other hook passes, including basedpyright.

Cause, reproduced. The step under test pipes through jq, and pre-commit.ci's runner image has no jq. With jq on PATH tests/test-release-check-promoted.sh passes 10 of 10; with it hidden it gives 6 passed, 4 failed with the same four cases and the same Unexpected isDraft for release v1.2.3: '' lines as the pre-commit.ci log. The fixtures and the workflow are correct. GitHub's ubuntu-latest images ship jq 1.7.1.

Required change (nothing else):

  1. In .pre-commit-config.yaml, add release-check-promoted-fixtures to ci.skip, and update the comment above skip so it names the reason for each hook: gha-workflow-linter needs the network, lint-plan-interpreter-fixtures needs uv, and release-check-promoted-fixtures needs jq, which pre-commit.ci's runner lacks. Keep the hook defined, so prek run still runs it locally.
  2. The Linting (self, ci.skip) job in .github/workflows/linting-action.yaml runs every ci.skip hook automatically (it already runs lint-plan-interpreter-fixtures that way), so no workflow edit is needed for enforcement. Update only the stale comment there, "One hook today: gha-workflow-linter", which is already wrong (two hooks are listed under ci.skip today). Say it runs every hook listed under ci.skip, without counting them. Do not touch anything else in that file, and do not touch .github/zizmor.yml: its line-scoped ignores do not cover this file, and an edit elsewhere in it would not be safe.
  3. On the pull request, confirm in the checks that Linting (self, ci.skip) / Lint: release-check-promoted-fixtures ran and passed, and say so in the description. A hook that does not appear there is unenforced.
  4. Run prek run --all-files (the new hook must pass locally) and amend the existing commit: the pull request stays one commit, and its title must keep matching the commit subject.

Do not change release.yaml or the fixtures. A separate documentation change on when to skip a hook is tracked in #146 and is not part of this pull request.

This comment was marked as resolved.

ModeSevenIndustrialSolutions

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the release-workflow changes.

2 open issues

Review effort: Balanced

The release workflow's check-promoted step captured 'gh release view'
with stderr merged into stdout and parsed the result with jq. Any
text gh printed to stderr on success, such as an update notice or a
deprecation warning, preceded the JSON: under 'bash -eo pipefail' jq
failed and the step exited 5, failing even an idempotent re-run of a
promoted release; without -e, an empty value fell through to
promotion.

Capture stdout only and send stderr to a temporary file reported when
gh fails. Accept only an explicit boolean isDraft and fail with an
error naming any other value, rather than promoting on an unknown
one. The step's already_promoted output is unchanged.

No other reusable workflow parses a '$(... 2>&1)' capture on its
success path.

Add tests/test-release-check-promoted.sh, which runs the step's
extracted run: block against a stub gh, and run it as a prek hook.

Review round 1 (maintainer instruction): pre-commit.ci's runner has
no jq, so the new hook failed there. List
release-check-promoted-fixtures under ci.skip, with the reason for
each skipped hook in the comment above it; the 'Linting (self,
ci.skip)' job in linting-action.yaml runs every ci.skip hook, so it
enforces the fixtures on GitHub's runners, which ship jq. Correct
that job's stale comment, which counted one hook.

Review round 2 (Copilot): report jq's own error and exit 1 when jq
fails, so a missing jq or a response that is not JSON names its
cause instead of an empty isDraft; add fixtures for both. Accept a
quoted or unquoted step id when the fixtures extract the step.

Review round 3 (maintainer decision on Copilot's two mktemp findings):
give both mktemp calls this change adds an explicit template under
${TMPDIR:-/tmp}, in the check-promoted step and in the fixture
script, so they behave the same on GNU, macOS and the BSDs. The
other tests/test-*.sh scripts are out of scope and unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues require changes to the release-status check update.

No open issues 🎉

Review effort: Balanced

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit d448f10 into lfreleng-actions:main Nov 5, 2026
71 of 72 checks passed
@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions deleted the code-monkey/issue-136 branch November 5, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Keep gh stderr out of the release JSON

2 participants