mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 17:41:29 +00:00
1caedd5fd3
Bundle: ci-pipeline-cleanup, Phase 1. Pure relocation — no behavior change. Each guard's bash logic is byte-identical to the prior inline version; the only changes are: (a) the guard becomes a sibling script under scripts/ci-guards/<id>.sh, (b) ci.yml's per-guard step is replaced by a single loop step that iterates all scripts. 20 scripts extracted (alphabetized): B-1-orphan-crud.sh, D-1-D-2-statusbadge-phantom.sh, G-1-jwt-auth-literal.sh, G-2-api-key-hash-json.sh, G-3-env-docs-drift.sh, H-001-bare-from.sh, H-009-readme-jwt.sh, L-001-insecure-skip-verify.sh, L-1-bulk-action-loop.sh, M-012-no-root-user.sh, P-1-documented-orphan-fns.sh, S-1-hardcoded-source-counts.sh, S-2-strings-contains-err.sh, T-1-frontend-page-coverage.sh, U-2-plaintext-healthcheck.sh, U-3-migration-mount.sh, bundle-8-L-015-target-blank-rel-noopener.sh, bundle-8-L-019-dangerously-set-inner-html.sh, bundle-8-M-009-bare-usemutation.sh, test-naming-convention.sh Plus scripts/ci-guards/README.md documenting the contract: - Each script must exit 0 on clean repo, non-zero with ::error:: prefix on regression - Runnable from repo root via 'bash scripts/ci-guards/<id>.sh' - Adding a new guard: drop a new <id>.sh; CI auto-picks it up ci.yml dropped 1488 → 557 lines (-931, -63%). Single CI loop step now collects ALL guard failures before failing the build instead of fail-fast — UX win for regressions that hit two guards at once. Two guards (QA-doc Part-count + seed-count, ci.yml lines 868-917) deliberately NOT extracted — they move to 'make verify-docs' in Phase 11 because they protect docs-the-operator-reads, not the product itself. Verification (sandbox): - All 20 scripts pass against HEAD (chmod +x; for g in scripts/ci-guards/*.sh; do bash $g; done) - New ci.yml YAML-parses cleanly - Job boundaries preserved: go-build-and-test, frontend-build, helm-lint, deploy-vendor-e2e, deploy-vendor-e2e-windows - Loop step appears twice (once at end of go-build-and-test, once at end of frontend-build) so both jobs continue running their set of guards
46 lines
2.2 KiB
Bash
Executable File
46 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# scripts/ci-guards/bundle-8-M-009-bare-usemutation.sh
|
|
#
|
|
# Audit M-009 + M-029 Pass 1 closure:
|
|
#
|
|
# Pre-Bundle-8 the codebase had 56 bare useMutation sites with
|
|
# discretionary invalidation. Bundle 8 shipped the useTrackedMutation
|
|
# wrapper (web/src/hooks/useTrackedMutation.ts) that requires every
|
|
# caller to declare `invalidates: QueryKey[] | 'noop'`. M-029 Pass 1
|
|
# then migrated all 56 sites to the wrapper across 6 batches.
|
|
#
|
|
# This guard pins the contract going forward: every useMutation call
|
|
# in src/ MUST be inside useTrackedMutation.ts (the wrapper itself
|
|
# is the only legitimate caller of useMutation). Any bare useMutation
|
|
# call elsewhere is a regression — adding a new mutation site means
|
|
# going through the wrapper so the invalidates contract is enforced
|
|
# per-site, not by a soft budget guard.
|
|
#
|
|
# If you genuinely need raw useMutation (extremely unlikely — the
|
|
# wrapper supports invalidates: 'noop' for fire-and-forget mutations),
|
|
# update this guard's exclusion list and document the carve-out.
|
|
|
|
set -e
|
|
# Test files (web/src/**/*.test.{ts,tsx}) are excluded so existing
|
|
# useMutation-mocking test patterns and the wrapper's own unit
|
|
# tests don't trip the production guard — symmetric with L-015
|
|
# and L-019 above.
|
|
BARE=$(grep -rnE '\buseMutation\(' web/src/ 2>/dev/null \
|
|
| grep -v 'web/src/hooks/useTrackedMutation\.ts' \
|
|
| grep -vE '\.test\.(ts|tsx)(:[0-9]+)?:' \
|
|
|| true)
|
|
if [ -n "$BARE" ]; then
|
|
echo "::error::M-009 hard-zero regression: bare useMutation() call(s) outside the wrapper:"
|
|
echo "$BARE"
|
|
echo
|
|
echo "Every mutation must go through useTrackedMutation"
|
|
echo "(web/src/hooks/useTrackedMutation.ts) with explicit"
|
|
echo "invalidates: QueryKey[] | 'noop'. See file header for usage."
|
|
exit 1
|
|
fi
|
|
# Sanity counts (informational, not a gate).
|
|
TRACKED=$(grep -rcE '\buseTrackedMutation\(' web/src/ 2>/dev/null | awk -F: '{s+=$2} END{print s}')
|
|
INVALIDATIONS=$(grep -rcE 'invalidateQueries|setQueryData|removeQueries|invalidates:' web/src/ 2>/dev/null | awk -F: '{s+=$2} END{print s}')
|
|
echo "M-009 bare-usemutation: clean (wrapper-internal call + test files excluded)."
|
|
echo "M-009 informational: useTrackedMutation sites = $TRACKED; invalidation surface = $INVALIDATIONS."
|