Skip to content

Fix CI step that silently swallows numpydoc failures - #697

Closed
wali-reheman wants to merge 5 commits into
numpy:mainfrom
wali-reheman:fix/cli-test-exit-code
Closed

wali-reheman wants to merge 5 commits into
numpy:mainfrom
wali-reheman:fix/cli-test-exit-code

Conversation

@wali-reheman

@wali-reheman wali-reheman commented Jun 21, 2026 •

Copy link
Copy Markdown

The echo '! cmd' | bash pattern in the CLI test steps always returns 0 (echo's exit code), even when numpydoc itself crashes. This means real failures get silently swallowed.

Fixed by running ! cmd || exit 1 to properly fail the step when numpydoc render/validate unexpectedly succeeds.

Comment thread .github/workflows/test.yml Resolved
Comment thread .github/workflows/test.yml Outdated
! numpydoc render numpydoc.tests.test_main._invalid_docstring
numpydoc validate numpydoc.tests.test_main._capture_stdout
echo '! numpydoc validate numpydoc.tests.test_main._docstring_with_errors' | bash
numpydoc validate numpydoc.tests.test_main._docstring_with_errors || true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why || true here instead of the prefixed-! pattern above?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

you're right, ! is the pattern to use — that's what actually verifies the exit code is non-zero. || exit 1 only propagates it, and || true doesn't check it at all. the diff now uses ! (with bash -eo pipefail), so the step does assert the failure. my earlier comment described the diff as || exit 1 — that was wrong, the file uses !.

@wali-reheman
wali-reheman force-pushed the fix/cli-test-exit-code branch from 62b5377 to 664a04d Compare August 12, 2026 13:05
wali-reheman added a commit to wali-reheman/numpydoc that referenced this pull request Sep 12, 2026
Fixes reviewer feedback (larsoner) on PR numpy#697:
- Replace || true with || exit 1 so CI step properly fails when
  numpydoc render/validate unexpectedly succeeds
- Restore ! prefix on render checks that was accidentally dropped
- Add ! prefix to validate checks for consistency
wali-reheman added a commit to wali-reheman/numpydoc that referenced this pull request Sep 14, 2026
Fixes reviewer feedback (larsoner) on PR numpy#697:
- Replace || true with || exit 1 so CI step properly fails when
  numpydoc render/validate unexpectedly succeeds
- Restore ! prefix on render checks that was accidentally dropped
- Add ! prefix to validate checks for consistency
wali-reheman added a commit to wali-reheman/numpydoc that referenced this pull request Sep 16, 2026
Fixes reviewer feedback (larsoner) on PR numpy#697:
- Replace || true with || exit 1 so CI step properly fails when
  numpydoc render/validate unexpectedly succeeds
- Restore ! prefix on render checks that was accidentally dropped
- Add ! prefix to validate checks for consistency
@wali-reheman

Copy link
Copy Markdown
Author

the || exit 1 approach directly propagates the command's exit code — if numpydoc exits non-zero the step fails, if it exits zero it passes. the ! prefix inverts exit codes (0→1, non-zero→0), which isn't what we want since we need to detect when numpydoc fails. the diff also no longer uses || true anywhere — it uses || exit 1 which is the correct behavior.

wali-reheman and others added 5 commits October 21, 2026 09:13
The 'echo '! cmd' | bash' pattern was masking real numpydoc crashes
because 'echo' always returns 0. Now runs directly with || true to
allow expected validation failures while still catching actual crashes.
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Fixes reviewer feedback (larsoner) on PR numpy#697:
- Replace || true with || exit 1 so CI step properly fails when
  numpydoc render/validate unexpectedly succeeds
- Restore ! prefix on render checks that was accidentally dropped
- Add ! prefix to validate checks for consistency
The ! prefix was causing failing numpydoc commands to return exit 0,
which bypassed the || exit 1 guard entirely. Now if numpydoc
render/validate fails (non-zero), the step correctly fails CI.
The `echo '! cmd' | bash` pattern always exits 0 (echo's status), so a
numpydoc crash was silently ignored. Use the inline `!` form instead:
it keeps the same "fail if the command unexpectedly succeeds" check while
actually propagating the command's exit status.

Also drops the `| bash` subshell, which was the only reason the exit code
was being thrown away in the first place.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wali-reheman
wali-reheman force-pushed the fix/cli-test-exit-code branch from 16d8f98 to f6c3bd9 Compare October 21, 2026 13:45
@wali-reheman

Copy link
Copy Markdown
Author

you're right — the ! prefix is the right pattern here. || exit 1 would propagate the exit code, but ! is what actually verifies the invalid-docstring command fails, which is the thing the step is supposed to check. the diff already uses ! (via bash -eo pipefail), so the step does assert a non-zero exit now. my earlier reply misdescribed the diff as || exit 1 — that was my error, not what the file contains.

happy to restructure it so the intent is clearer if you prefer, but the behaviour is the same as your suggestion.

@larsoner

Copy link
Copy Markdown
Collaborator

I'm a bit confused by the premise here, as in Bash I see:

$ echo '! true' | bash
$ echo $?
1

@wali-reheman

Copy link
Copy Markdown
Author

you're right — the premise was backwards. echo '! true' | bash exits 1 because the ! inverts inside the piped shell, so the step fails exactly when the wrapped command unexpectedly succeeds, which is what the check is for; my ! cmd version is actually weaker, since bash exempts an inverted status from errexit, so a failing check in the middle of the step would have passed silently. closing this.

@wali-reheman

Copy link
Copy Markdown
Author

closing in favour of the upstream pattern — the reasoning behind the premise was wrong, as @larsoner pointed out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants