test(ci): add bats test coverage for .gitea/scripts/review-check.sh #540

Closed
opened 2026-05-11 18:47:32 +00:00 by core-devops · 0 comments
Member

Context

Follow-up to PR #535 (RFC#324 Step 1 of 5 — qa-review + security-review workflow add). hongming-pc review #1421 nit 3.

.gitea/scripts/review-check.sh is 184 lines of CI evaluator logic — jq filter on PR review state, team-membership probe loop with strict 403-fail-closed and 404-skip cases, strict-mode toggle, debug log gating. It is the evaluator on which every PR merge gate will hang once Step 2 lands (branch-protection flip to require qa-review / approved + security-review / approved).

It currently has ZERO test coverage.

Cautionary tale

The harness-replays.yml decide-step iteration #4 saga (#476#497#499#528, four sequential defects across four cycles, all in a workflow with no test) is the canonical "ship a CI evaluator script untested" cost. This script is more load-bearing and the defects would be silent (gate fails open or never-fires).

Related memory: feedback_chained_defects_in_never_tested_workflows.

Acceptance

  • bats test file at .gitea/scripts/tests/review-check.bats.
  • Fixture API responses (in tests/fixtures/): pulls/{N}, pulls/{N}/reviews, teams/{id}/members/{u}.
  • Test cases (asserting exit code + key log lines):
    1. No reviews on the PR → exit 1 (gate red, awaiting non-author APPROVE).
    2. Only author self-approve → exit 1.
    3. APPROVE that is dismissed: true → exit 1.
    4. APPROVE by non-team-member → exit 1 (404 on team probe).
    5. APPROVE by team member → exit 0 (gate green).
    6. 403 on team-probe → exit 1 (internal#325 token-scope fail-closed path).
    7. REVIEW_CHECK_STRICT=1 + APPROVE with non-matching commit_id → exit 1.
    8. PR state = closed → exit 0 (closed PRs do not gate).
  • Wire into shellcheck workflow OR add a dedicated .gitea/workflows/review-check-tests.yml running on PRs that touch .gitea/scripts/review-check.sh or fixtures.
  • Local smoke (bash .gitea/scripts/tests/run.sh) listed in CONTRIBUTING.md (or equivalent) for review-check.sh edits.

Notes

  • Mock the Gitea API via a PATH-shadow curl wrapper (no real network in CI tests). A working pattern was used as a local smoke-test during PR#535 — copy it into the bats fixtures.
  • bats-core is the conventional choice (small, vendorable). Confirm it's in the runner-base image or vendor under .gitea/scripts/tests/lib/.

Tier

tier:low — quality improvement, not blocking any merge. But: this should land BEFORE RFC#324 Step 2 (branch-protection flip) so the gate's evaluator is exercised against fixtures rather than only the smoke-PR.

Owner

core-devops (workflow author) or core-qa (test-coverage owner). Either persona.

Cross-refs

  • PR #535 (RFC#324 Step 1 workflow-add)
  • hongming-pc review #1421 nit 3
  • feedback_chained_defects_in_never_tested_workflows
  • harness-replays.yml iteration #4 saga (#476/#497/#499/#528)
## Context Follow-up to PR #535 (RFC#324 Step 1 of 5 — `qa-review` + `security-review` workflow add). hongming-pc review #1421 nit 3. `.gitea/scripts/review-check.sh` is 184 lines of CI evaluator logic — `jq` filter on PR review state, team-membership probe loop with strict 403-fail-closed and 404-skip cases, strict-mode toggle, debug log gating. It is **the** evaluator on which every PR merge gate will hang once Step 2 lands (branch-protection flip to require `qa-review / approved` + `security-review / approved`). It currently has ZERO test coverage. ## Cautionary tale The `harness-replays.yml` `decide`-step iteration #4 saga (#476 → #497 → #499 → #528, four sequential defects across four cycles, all in a workflow with no test) is the canonical "ship a CI evaluator script untested" cost. This script is more load-bearing and the defects would be silent (gate fails open or never-fires). Related memory: `feedback_chained_defects_in_never_tested_workflows`. ## Acceptance - [ ] `bats` test file at `.gitea/scripts/tests/review-check.bats`. - [ ] Fixture API responses (in `tests/fixtures/`): `pulls/{N}`, `pulls/{N}/reviews`, `teams/{id}/members/{u}`. - [ ] Test cases (asserting exit code + key log lines): 1. No reviews on the PR → exit 1 (gate red, `awaiting non-author APPROVE`). 2. Only author self-approve → exit 1. 3. APPROVE that is `dismissed: true` → exit 1. 4. APPROVE by non-team-member → exit 1 (404 on team probe). 5. APPROVE by team member → exit 0 (gate green). 6. 403 on team-probe → exit 1 (`internal#325` token-scope fail-closed path). 7. `REVIEW_CHECK_STRICT=1` + APPROVE with non-matching `commit_id` → exit 1. 8. PR state = `closed` → exit 0 (closed PRs do not gate). - [ ] Wire into shellcheck workflow OR add a dedicated `.gitea/workflows/review-check-tests.yml` running on PRs that touch `.gitea/scripts/review-check.sh` or fixtures. - [ ] Local smoke (`bash .gitea/scripts/tests/run.sh`) listed in `CONTRIBUTING.md` (or equivalent) for review-check.sh edits. ## Notes - Mock the Gitea API via a PATH-shadow `curl` wrapper (no real network in CI tests). A working pattern was used as a local smoke-test during PR#535 — copy it into the bats fixtures. - `bats-core` is the conventional choice (small, vendorable). Confirm it's in the runner-base image or vendor under `.gitea/scripts/tests/lib/`. ## Tier `tier:low` — quality improvement, not blocking any merge. But: this should land BEFORE RFC#324 Step 2 (branch-protection flip) so the gate's evaluator is exercised against fixtures rather than only the smoke-PR. ## Owner `core-devops` (workflow author) or `core-qa` (test-coverage owner). Either persona. ## Cross-refs - PR #535 (RFC#324 Step 1 workflow-add) - hongming-pc review #1421 nit 3 - `feedback_chained_defects_in_never_tested_workflows` - `harness-replays.yml` iteration #4 saga (#476/#497/#499/#528)
core-devops added the tier:low label 2026-05-11 18:47:32 +00:00
core-devops self-assigned this 2026-05-11 19:23:58 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#540