chore(ci): unblock CI by gating bash tests on tree-sitter; sort review prompt glob#617
Open
elfensky wants to merge 1 commit into
Open
Conversation
…w prompt glob
## The problem
CI has been red on `main` since 2026-04-06, and on every PR opened
since, because of 5 pre-existing test failures that are unrelated to
any feature work. Because they live on `main`, every PR inherits them
and cannot go green without bundling a workaround. Two distinct root
causes:
1. Three bash tests in
`desloppify/tests/lang/common/test_bash_unused_imports.py` call
`detect_unused_imports`, which parses via tree-sitter. tree-sitter
is an *optional* dependency (`[project.optional-dependencies]`),
so the `tests-core` job (which installs no extras) does not have
it; there the function returns `[]` and the tests, asserting
specific findings, fail. In `tests-full` (installs `.[full]`)
tree-sitter is present and the tests pass.
2. Two review tests in
`desloppify/tests/review/test_review_commands.py` and its
integration counterpart use
`list(runs_dir.glob("*/prompts/batch-*.md"))` without sorting.
The glob order is filesystem-dependent: on macOS it happens to
return `batch-1.md` (the batch with `historical_issue_focus`)
first, on Linux it returns `batch-2.md` first. The assertion
`"Previously flagged issues" in prompt_text` then fails on Linux
because that string only appears in `batch-1.md`.
## The solution
Two small, behaviour-preserving test fixes:
1. Gate the bash test file on tree-sitter availability with the exact
pattern its sibling tree-sitter tests already use
(`test_treesitter.py`, `test_treesitter_complexity_and_integration.py`):
```python
pytestmark = pytest.mark.skipif(
not is_available(),
reason="tree-sitter-language-pack not installed",
)
```
This is a consistency fix — the bash file was the only
tree-sitter-dependent test file missing the guard. Coverage is
preserved: with tree-sitter installed (`tests-full`) the tests
run and assert real findings as before; without it (`tests-core`)
they skip cleanly, because the feature genuinely cannot run.
2. Wrap the review test's glob in `sorted(...)`:
```python
prompt_files = sorted(runs_dir.glob("*/prompts/batch-*.md"))
```
This makes the test deterministic across operating systems —
`batch-1.md` always sorts first — and removes a latent flake that
only passed on macOS by luck. The assertion still verifies exactly
what it intends (batch-1's content).
## Scope
This is a standalone maintenance PR against `main`: it touches only test
files and changes no product behaviour. Landing it here gives `main` —
and therefore every open and future PR (peteromallet#614, peteromallet#616, …) — a green
baseline, instead of each PR having to carry the same workaround.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CI has been red on
mainsince 2026-04-06, and on every PR opened since, because of 5 pre-existing test failures unrelated to any feature work. Because they live onmain, every PR inherits them and can't go green without bundling a workaround (see #614, #616). This standalone, test-only PR fixes the root cause somaingets a green baseline.Two distinct root causes:
1. Bash tests assume tree-sitter is installed
desloppify/tests/lang/common/test_bash_unused_imports.pycallsdetect_unused_imports, which parses via tree-sitter. tree-sitter is an optional dependency ([project.optional-dependencies]), so thetests-corejob (no extras) doesn't have it — theredetect_unused_importsreturns[]and the tests, asserting specific findings, fail. Intests-full(pip install -e ".[full]") tree-sitter is present and the tests pass.Fix: gate the file with the exact
skipifpattern its sibling tree-sitter tests already use (test_treesitter.py,test_treesitter_complexity_and_integration.py):This is a consistency fix — the bash file was the only tree-sitter-dependent test file missing the guard. Coverage is preserved: with tree-sitter (
tests-full) the tests run and assert real findings; without it (tests-core) they skip cleanly, because the feature genuinely cannot run there.2. Review tests rely on filesystem-dependent glob order
test_review_commands.py(and its integration counterpart) uselist(runs_dir.glob("*/prompts/batch-*.md"))unsorted. macOS happens to returnbatch-1.mdfirst; Linux returnsbatch-2.mdfirst. The assertion"Previously flagged issues" in prompt_textonly holds forbatch-1.md, so it fails on Linux.Fix:
sorted(...)the glob. Deterministic across OSes, removes a latent flake that only passed on macOS by luck, and the assertion still verifies exactly what it intends (batch-1's content).Why this is safe
tests-fulland only skips where the optional feature is absent; the graceful-degradation path is itself covered bytest_treesitter.py::test_is_available_false_when_uninstalled. Fix 2 strengthens (de-flakes) its test.Verification
Reproduced both CI environments locally:
tests-full): the 3 bash tests run and pass, both review tests pass.tests-core): the bash tests skip with reasontree-sitter-language-pack not installed; review fix is OS-independent.🤖 Generated with Claude Code