fix(automation): issue watcher must not open PRs without tests
PR #137 shipped a code change under App/app with no test — the test-presence gate in pr-checks.yml would reject it, but the watcher opened the PR anyway. Add the same gate to the watcher's fix phase: before pushing/opening a PR, run the pr-checks.yml test-presence check against the branch diff. If code under App/(app|lib|components|hooks) changed with no accompanying test, the watcher does NOT open a PR — it marks the issue claude-failed and comments, so the queue can retry. Never raises a PR the CI would immediately fail. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
6c5aebd3fb
commit
a5248e5c23
2 changed files with 21 additions and 0 deletions
|
|
@ -60,6 +60,11 @@ requires an interactive ESLint migration (a follow-up). Integration tests are
|
||||||
type-checked here but executed against the `pelagia_test` DB by the autofix / locally
|
type-checked here but executed against the `pelagia_test` DB by the autofix / locally
|
||||||
(not in this shared CI, to avoid prod-mirror schema drift).
|
(not in this shared CI, to avoid prod-mirror schema drift).
|
||||||
|
|
||||||
|
The **issue watcher pre-applies gate 1 (test-presence) locally** before opening a PR:
|
||||||
|
if Claude's fix changes code under `App/app|lib|components|hooks` but adds no test, the
|
||||||
|
watcher does **not** open a PR — it marks the issue `claude-failed` and comments — so it
|
||||||
|
never raises a PR that this CI would immediately reject. Re-queue (`claude-queue`) to retry.
|
||||||
|
|
||||||
A [`PULL_REQUEST_TEMPLATE.md`](../.forgejo/PULL_REQUEST_TEMPLATE.md) carries the checklist.
|
A [`PULL_REQUEST_TEMPLATE.md`](../.forgejo/PULL_REQUEST_TEMPLATE.md) carries the checklist.
|
||||||
|
|
||||||
## Components
|
## Components
|
||||||
|
|
|
||||||
|
|
@ -339,6 +339,22 @@ while [ "$f" -lt "$n_fix" ]; do
|
||||||
|
|
||||||
commits=$(git -C "$WORKDIR" rev-list "origin/$BASE_BRANCH..HEAD" --count)
|
commits=$(git -C "$WORKDIR" rev-list "origin/$BASE_BRANCH..HEAD" --count)
|
||||||
if [ "$commits" -gt 0 ]; then
|
if [ "$commits" -gt 0 ]; then
|
||||||
|
# Test-presence gate -- mirror .forgejo/workflows/pr-checks.yml so the watcher
|
||||||
|
# never opens a PR the CI will immediately reject. "Code" = app source under
|
||||||
|
# App/(app|lib|components|hooks); tests, prisma, config, docs are exempt.
|
||||||
|
changed=$(git -C "$WORKDIR" diff --name-only "origin/$BASE_BRANCH...HEAD")
|
||||||
|
code_changed=$(printf '%s\n' "$changed" | grep -E '^App/(app|lib|components|hooks)/' | grep -vE '(\.test\.|\.spec\.|/tests/)' || true)
|
||||||
|
test_changed=$(printf '%s\n' "$changed" | grep -E '(\.test\.|\.spec\.|/tests/)' || true)
|
||||||
|
if [ -n "$code_changed" ] && [ -z "$test_changed" ]; then
|
||||||
|
log "Test-presence gate FAILED for #$num: code changed with no test; not opening a PR"
|
||||||
|
set_labels "$num" "claude-working" "claude-failed"
|
||||||
|
add_comment "$num" "$BOT_MARKER
|
||||||
|
[Claude] Implemented a change but added **no test**, so no PR was opened. The contribution policy (\`pr-checks.yml\`) requires a test for any change under \`App/app|lib|components|hooks\`, and would reject this. Re-add \`claude-queue\` to retry, or pick it up interactively.
|
||||||
|
|
||||||
|
Code files that needed an accompanying test:
|
||||||
|
$code_changed"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
log "Claude made $commits commit(s); pushing $branch"
|
log "Claude made $commits commit(s); pushing $branch"
|
||||||
if ! git -C "$WORKDIR" push -f -u origin "$branch" -q 2>>"$LOG_FILE"; then
|
if ! git -C "$WORKDIR" push -f -u origin "$branch" -q 2>>"$LOG_FILE"; then
|
||||||
log "push failed for #$num"; set_labels "$num" "claude-working" "claude-failed"; continue
|
log "push failed for #$num"; set_labels "$num" "claude-working" "claude-failed"; continue
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue