CI static checks: shellcheck job, bash -n over onboarding/hooks/tests, a shared test assert lib #211

Open
opened 2026-10-15 02:59:31 +00:00 by ben · 2 comments
Owner

Filed from the 2026-10-14 infrastructure review (Claude Code session on Ben's workstation; four parallel read-only review passes over the root harness). Line anchors are against main at 3e50274.

Symptom

ci.yml:46 runs bash -n on root *.sh only — onboarding/*.sh, git-hooks/*, git-fence and tests/*.sh are unchecked. shellcheck appears only in # shellcheck source= comments and is not in CI. 87 test scripts (79 in tests/, 8 in onboarding/tests/) are ad hoc: 56 define their own fail() exit-on-first, ~6 use a check()/ok() counter, tests/test-env.sh is a hermetic helper sourced by 10. Representative timings: claim-lib 8.4 s, policy-lib 0.6 s, check-harness-drift 2.6 s.

Proposed change

  • ci.yml: bash -n over *.sh onboarding/*.sh onboarding/tests/*.sh tests/*.sh git-hooks/* git-fence; a shellcheck -S warning -x job (runner needs shellcheck; add to the registry tools for matou-workstation).
  • tests/lib.sh with check/fail/tmpdir/shim helpers; migrate tests opportunistically (one commit per handful, no behaviour change).
  • Fix the misleading comment at tests/run-swarm-ready-list-test.sh:68 ("a macOS host with no flock" — bens-mac-04 runs Ubuntu 24.04).

Acceptance

  • CI green with both new steps; shellcheck baseline failures either fixed or disabled per line with a reason.
_Filed from the 2026-10-14 infrastructure review (Claude Code session on Ben's workstation; four parallel read-only review passes over the root harness). Line anchors are against `main` at 3e50274._ ## Symptom `ci.yml:46` runs `bash -n` on root `*.sh` only — `onboarding/*.sh`, `git-hooks/*`, `git-fence` and `tests/*.sh` are unchecked. `shellcheck` appears only in `# shellcheck source=` comments and is not in CI. 87 test scripts (79 in `tests/`, 8 in `onboarding/tests/`) are ad hoc: 56 define their own `fail()` exit-on-first, ~6 use a `check()`/`ok()` counter, `tests/test-env.sh` is a hermetic helper sourced by 10. Representative timings: claim-lib 8.4 s, policy-lib 0.6 s, check-harness-drift 2.6 s. ## Proposed change - ci.yml: `bash -n` over `*.sh onboarding/*.sh onboarding/tests/*.sh tests/*.sh git-hooks/* git-fence`; a `shellcheck -S warning -x` job (runner needs shellcheck; add to the registry `tools` for matou-workstation). - `tests/lib.sh` with `check`/`fail`/`tmpdir`/`shim` helpers; migrate tests opportunistically (one commit per handful, no behaviour change). - Fix the misleading comment at `tests/run-swarm-ready-list-test.sh:68` ("a macOS host with no flock" — bens-mac-04 runs Ubuntu 24.04). ## Acceptance - CI green with both new steps; shellcheck baseline failures either fixed or disabled per line with a reason.

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

  • Ruling: ready-for-agent.
  • Why this is a two-way door: CI steps, a shared test helper, and a stale-comment fix are all revertible by a commit and change no runtime behaviour; shellcheck installs inside the workflow step, so there is no host-provisioning residue a human must supply.
  • What proves it: the CI run itself going green with the broadened bash -n step and the new shellcheck job.

Agent Brief

Category: enhancement

Summary: Extend CI static analysis across all shell, add a shellcheck job, and give tests a shared assertion helper — tightening the net that today only catches syntax errors in root *.sh.

Current behavior: CI syntax-checks only root *.sh; onboarding/, tests/, git-hooks/, and git-fence are unchecked. shellcheck runs nowhere. Dozens of test files each define their own fail(); there is no shared helper. One test carries a factually-wrong "macOS host" comment.

Desired behavior: (1) bash -n over *.sh onboarding/*.sh onboarding/tests/*.sh tests/*.sh git-hooks/* git-fence. (2) A shellcheck -S warning -x CI job (install shellcheck within the workflow step, or declare it in the host registry tools); baseline findings either fixed or suppressed per-line with a stated reason. (3) A shared tests/lib.sh exposing check/fail/tmpdir/shim, migrated into opportunistically (small commits, no behaviour change). (4) Correct the misleading "macOS host with no flock" comment in the ready-list test (the referenced runner runs Ubuntu).

Key interfaces: tests/lib.sh sourced by test scripts, providing a pass/fail counter and a first-class failure reporter compatible with the existing check()/ok() style and the offline test-env.sh helper; CI steps emit grouped, individually-attributable output.

Acceptance criteria:

  • CI green with the broadened bash -n step and a shellcheck job; every shellcheck finding is fixed or line-disabled with a reason.
  • tests/lib.sh exists; at least a first handful of tests use it with no behaviour change (suite still green).
  • The misleading "macOS host" comment in the ready-list test no longer claims a macOS host.

Out of scope: Migrating all test files in one go; any test behaviour change beyond the helper swap.

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** - **Ruling:** `ready-for-agent`. - **Why this is a two-way door:** CI steps, a shared test helper, and a stale-comment fix are all revertible by a commit and change no runtime behaviour; shellcheck installs inside the workflow step, so there is no host-provisioning residue a human must supply. - **What proves it:** the CI run itself going green with the broadened `bash -n` step and the new shellcheck job. ## Agent Brief **Category:** enhancement **Summary:** Extend CI static analysis across all shell, add a shellcheck job, and give tests a shared assertion helper — tightening the net that today only catches syntax errors in root `*.sh`. **Current behavior:** CI syntax-checks only root `*.sh`; `onboarding/`, `tests/`, `git-hooks/`, and `git-fence` are unchecked. shellcheck runs nowhere. Dozens of test files each define their own `fail()`; there is no shared helper. One test carries a factually-wrong "macOS host" comment. **Desired behavior:** (1) `bash -n` over `*.sh onboarding/*.sh onboarding/tests/*.sh tests/*.sh git-hooks/* git-fence`. (2) A `shellcheck -S warning -x` CI job (install shellcheck within the workflow step, or declare it in the host registry `tools`); baseline findings either fixed or suppressed per-line with a stated reason. (3) A shared `tests/lib.sh` exposing `check`/`fail`/`tmpdir`/`shim`, migrated into opportunistically (small commits, no behaviour change). (4) Correct the misleading "macOS host with no flock" comment in the ready-list test (the referenced runner runs Ubuntu). **Key interfaces:** `tests/lib.sh` sourced by test scripts, providing a pass/fail counter and a first-class failure reporter compatible with the existing `check()`/`ok()` style and the offline `test-env.sh` helper; CI steps emit grouped, individually-attributable output. **Acceptance criteria:** - [ ] CI green with the broadened `bash -n` step and a shellcheck job; every shellcheck finding is fixed or line-disabled with a reason. - [ ] `tests/lib.sh` exists; at least a first handful of tests use it with no behaviour change (suite still green). - [ ] The misleading "macOS host" comment in the ready-list test no longer claims a macOS host. **Out of scope:** Migrating all test files in one go; any test behaviour change beyond the helper swap.

Partial landing + blocked on a protected path.

AC2 and AC3 landed on main in 25c0749:

  • AC2 — tests/lib.sh exists (the shared pass/fail counters, the dominant check <desc> <cond> asserter verbatim, a standalone fail reporter, summary, and tmpdir/shim fixtures under one $$-keyed per-process root cleaned on EXIT; carries its own self-test via a run-directly self-guard, the test-env.sh precedent). First handful migrated with the suite still green: evidence-lib-test.sh, guide-labels-test.sh, land-pr-test.sh, ticket-landing-test.sh.
  • AC3 — the stale "macOS host with no flock" comment in run-swarm-ready-list-test.sh is corrected (the mkdir-lock is portable because an atomic mkdir needs no flock, not because any runner is macOS).

AC1 is blocked: broadening bash -n and adding the shellcheck -S warning -x job both edit .forgejo/workflows/ci.yml — a protected path an agent worker must not touch (CLAUDE.md rule 9: a .forgejo/workflows/ change is filed for a session, not edited here). Filed as #215 (ready-for-session).

To re-arm #211: land #215 (the CI steps) and verify the suite is green under both new steps, then close #211 — or re-add ready-for-agent if there is remaining agent-completable work. Swapping ready-for-agent → agent-blocked so this does not loop back into the ready queue.

**Partial landing + blocked on a protected path.** AC2 and AC3 landed on `main` in 25c0749: - **AC2** — `tests/lib.sh` exists (the shared `pass`/`fail` counters, the dominant `check <desc> <cond>` asserter verbatim, a standalone `fail` reporter, `summary`, and `tmpdir`/`shim` fixtures under one `$$`-keyed per-process root cleaned on EXIT; carries its own self-test via a run-directly self-guard, the `test-env.sh` precedent). First handful migrated with the suite still green: `evidence-lib-test.sh`, `guide-labels-test.sh`, `land-pr-test.sh`, `ticket-landing-test.sh`. - **AC3** — the stale "macOS host with no flock" comment in `run-swarm-ready-list-test.sh` is corrected (the mkdir-lock is portable because an atomic mkdir needs no flock, not because any runner is macOS). **AC1 is blocked:** broadening `bash -n` and adding the `shellcheck -S warning -x` job both edit `.forgejo/workflows/ci.yml` — a protected path an agent worker must not touch (CLAUDE.md rule 9: a `.forgejo/workflows/` change is filed for a session, not edited here). Filed as **#215** (`ready-for-session`). **To re-arm #211:** land #215 (the CI steps) and verify the suite is green under both new steps, then close #211 — or re-add `ready-for-agent` if there is remaining agent-completable work. Swapping `ready-for-agent` → `agent-blocked` so this does not loop back into the ready queue.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#211
No description provided.