Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

INF-1484/fix: stop swallowing pre-commit hook failures#24

Merged
brtkwr merged 1 commit into
mainfrom
inf-1484-fix-exit-code
Jun 4, 2026
Merged

INF-1484/fix: stop swallowing pre-commit hook failures#24
brtkwr merged 1 commit into
mainfrom
inf-1484-fix-exit-code

Conversation

@brtkwr

@brtkwr brtkwr commented Jun 4, 2026

Copy link
Copy Markdown
Member

Context

Spotted on workflow-portal#120: prettier failed inside the action's log ("files were modified by this hook") but the pre-commit check reported success. The INF-1484 python-modules refactor (#21) replaced the old set +e exit-code capture with:

python -m pre_commit_action.run_hooks ...
echo "EXIT_CODE=$?" >> "$GITHUB_OUTPUT"

Composite shell: bash runs with -e, so a hook failure aborts the step before EXIT_CODE is written; continue-on-error: true masks the step failure; and the report step then runs exit '', which is exit 0. Every consumer's pre-commit check has reported green regardless of hook failures since #21 merged.

Changes

  • Capture the exit code with set +e (as the pre-INF-1484/feat: extract inline shell to Python modules + add pytest #21 shell did), so EXIT_CODE is always written.
  • Drop continue-on-error: true - the step can no longer fail spuriously, and keeping it would mask real infra errors (e.g. uvx unavailable).
  • Report step: exit ${{ steps.pre-commit.outputs.EXIT_CODE || '1' }} - fail loud if the output is ever missing instead of silently succeeding.
  • Sticky comment status now derives from the exit code in render_comment.py (the step outcome is always success now that the exit code is captured) - the PRE_COMMIT_OUTCOME env is gone. Tests updated.

Validation

  • run_hooks.py already propagates the subprocess return code via sys.exit (covered by pytest); the bug was purely in the yaml wiring.
  • After merge, workflow-portal#120's pre-commit re-run should go red on the prettier finding (currently false-green) - that's the expected behaviour change.

Ticket

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request modifies action.yaml to capture the exit code of the pre-commit run by disabling immediate exit on error (set +e) and removing continue-on-error: true. It also ensures the final status reporting step fails loud if the exit code is missing. However, a critical issue was identified: because the last command in the pre-commit step (echo) always succeeds, the step's outcome will always be evaluated as 'success'. This causes the subsequent step to mistakenly post a "Pre-commit success" comment on the PR even when hooks fail. A fix was suggested to determine the outcome using the captured EXIT_CODE instead of the step outcome.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread action.yaml
The python-modules refactor (#21) dropped the set +e exit-code capture:
under the composite shell's bash -e, a hook failure aborted the step
before EXIT_CODE was written, continue-on-error masked the step failure,
and the report step ran exit '' which succeeds. Every hook failure since
has reported green. Restore the capture with -e disabled, drop the
now-pointless continue-on-error, and make the report step fail loud if
the exit code is ever missing.
@brtkwr brtkwr force-pushed the inf-1484-fix-exit-code branch from 6e13cc7 to e5a5ee2 Compare June 4, 2026 12:28
@brtkwr brtkwr merged commit ce7742a into main Jun 4, 2026
1 check passed
@brtkwr brtkwr deleted the inf-1484-fix-exit-code branch June 4, 2026 12:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant