Commit 8b4b17b
authored
🤖 ci: document fetch-depth for paths-filter changes (#17)
## Summary
Documented why the `changes` job uses full history checkout in CI.
## Background
`dorny/paths-filter` compares `github.event.before` to the current ref
on push events. A shallow checkout can miss the `before` commit and
force an extra fetch that may fail when credentials are not persisted.
## Implementation
- Added an inline comment next to `fetch-depth: 0` in
`.github/workflows/ci.yaml` to explain the behavior and rationale.
## Validation
- `go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.10`
---
<details>
<summary>📋 Implementation Plan</summary>
# Plan: Fix “Detect changed paths” failing on `main`
## Context / Why
The GitHub Actions job **“Detect changed paths”** (uses
`dorny/paths-filter`) is failing on pushes to `main` with:
- “Changes will be detected between `<before_sha>` and `main`”
- “Ensuring `<before_sha>` is fetched from origin”
- `git` exits with code **128**
On `push` events, `paths-filter` diffs `github.event.before` →
`github.ref`/`main`. With a **shallow checkout**, the `before` commit is
often missing locally, so the action tries to fetch it. Because the
workflow uses `actions/checkout` with `persist-credentials: false`, that
follow-up fetch can fail (common in private repos / restricted
environments), producing the observed error.
## Evidence (what we verified)
- User-provided CI log excerpt shows `paths-filter` attempting to fetch
the `before` SHA and failing with `git` exit code 128.
- `.github/workflows/ci.yaml`:
- `changes` job checks out code with `persist-credentials: false` and
**no `fetch-depth`**, so `fetch-depth` defaults to **1** (shallow).
(Lines 15–30)
- `changes` job runs `dorny/paths-filter` for non-`merge_group` events.
(Lines 41–64)
## Implementation details (edits to make)
### 1) Fetch enough history in the `changes` job
Edit `.github/workflows/ci.yaml` in the `jobs.changes.steps` checkout
step to fetch full history (recommended) so `paths-filter` never needs
to perform an extra `git fetch`.
**Change:**
```yaml
jobs:
changes:
steps:
- name: Checkout
uses: actions/checkout@34e1148 # v4.3.1
with:
fetch-depth: 0 # ensure github.event.before commit exists locally
persist-credentials: false
```
Notes:
- `fetch-depth: 0` is the most robust fix (handles multi-commit pushes,
merge commits, and non-linear history).
- A smaller `fetch-depth: 2` *might* work for typical “single new
commit” pushes, but is brittle; prefer `0` unless checkout performance
is a proven issue.
## Validation / Rollout
1. Run workflow lint locally:
- `go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.10`
2. Push the workflow change and confirm the next `push`-to-`main` CI run
completes the `Detect changed paths` job.
3. If failures persist, capture the full `git` stderr from the action
logs; the next fallback is to keep shallow checkout but allow
authenticated fetch (remove `persist-credentials: false` for just the
`changes` job or explicitly pass auth), but this should not be necessary
with `fetch-depth: 0`.
</details>
---
_Generated with [`mux`](https://github.com/coder/mux) • Model:
`openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.20`_
<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh
costs=0.20 -->1 parent 3c191c5 commit 8b4b17b
3 files changed
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
72 | 81 | | |
73 | 82 | | |
74 | 83 | | |
| |||
0 commit comments