fix(ci): use full git history on PRs and fail loudly on diff errors#3
Merged
Conversation
Two bugs in the workflow from #1 conspired to make path-filtered builds silently skip on every PR. Discovered while opening #2, the first demo PR, where the build job was reported as 'skipping' even though easy-paging-demo/ was clearly the changed directory. Bug 1 — GitHub Actions ternary trap on fetch-depth fetch-depth: ${{ github.event_name == 'pull_request' && 0 || 1 }} The intent was "0 (full history) on PRs, 1 (shallow) otherwise". But in Actions expressions, `0` is falsy, so `0 || 1` short-circuits to `1`. The expression evaluated to `1` on both PRs and main pushes, leaving PR checkouts with no history beyond the merge commit. Bug 2 — silent failure on git diff mapfile -t changed_files < <(git diff --name-only "$base" HEAD) With bug 1 in effect, `git diff` exited with "fatal: bad object" because the base SHA wasn't fetched. But process substitution does not propagate the subshell's exit status under `set -e`, so the script kept going with an empty `changed_files` array — and therefore an empty matrix and a "skipped" build job. CI looked green, but it had built nothing. Fix: - fetch-depth: 0 unconditionally. Cost is negligible for this repo and removes the ternary footgun entirely. - Run git diff in a separate statement so `set -e` actually catches a non-zero exit, with an explicit ::error:: pointer to the likely cause (shallow checkout) so the next person debugging this gets a head start. Verification will happen on the next PR (the rebase of #2) — the matrix should populate with easy-paging-demo and the build job should actually execute ./gradlew build instead of skipping.
This was referenced May 23, 2026
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
Two bugs in the CI workflow from #1 made path-filtered builds silently skip on every PR. Discovered while opening #2 — the matrix went empty and the build job was reported as "skipping" even though `easy-paging-demo/` was clearly the changed directory.
Two bugs, one symptom
Bug 1 — GitHub Actions ternary trap on `fetch-depth`
```yaml
fetch-depth: ${{ github.event_name == 'pull_request' && 0 || 1 }}
```
The intent was "0 (full history) on PRs, 1 (shallow) otherwise". But in Actions expressions, `0` is falsy, so `0 || 1` short-circuits to `1`. The expression evaluates to `1` on both PRs and main pushes. PR checkouts had no history beyond the merge commit.
Bug 2 — silent failure on `git diff`
```bash
mapfile -t changed_files < <(git diff --name-only "$base" HEAD)
```
With bug 1 in effect, `git diff` exited with `fatal: bad object` because the base SHA was never fetched. But process substitution does not propagate the subshell's exit status under `set -e` — so the script kept going with an empty `changed_files` array. The matrix went empty. The build job was marked as "skipping". CI looked green but had built nothing.
Fix
Verification
Will be confirmed when #2 is rebased on top of this fix:
Cannot be verified by this PR's own CI run — this PR doesn't touch any demo directory, so the matrix will (correctly) be empty and `build` will (correctly) skip. The fix only takes effect when there's a demo change to detect.
Test plan