ci: split unit tests from static guards, de-&&-chain checks - #2214
Merged
Merged
Conversation
…push hook
## Changes
1. **Split CI workflows:**
- `unit-tests.yml` now runs only vitest (behavioral tests)
- New `static-guards.yml` runs all 13 guard checks (build collisions, icon imports,
srv-qa parity, slug-lookup canonicalization, CSRF, GraphQL breaking-changes, etc.)
This halves alert fatigue: a red "unit tests" now signals a real behavioral failure
(rare, worth reading), not a policy-linter violation that's noisy by design.
2. **De-`&&`-chained guard runner:**
- Created `scripts/run-static-guards.ts` that runs all checks to completion
before reporting, instead of failing on the first violation
- Reports all failures at once (eliminates "fix one, next one appears" death-by-cuts)
- Summary at the end shows pass/fail count and which guards failed
3. **Pre-push git hook:**
- Added `scripts/git-hooks/pre-push` wired via `npm run setup:git-hooks`
- Runs `npm run static-guards` locally before push (deterministic, instant feedback)
- Skipped in non-interactive environments (CI, deploy scripts)
## Why
Last 10 failed CI runs: 8 failed on guard chain (`postbuild:apps`), only 2 on real tests.
Guard violations (missing magic comments, new service count off by one, etc.) are high-frequency
noise that drowns out signal. Team has started ignoring CI, risking real regressions.
Splitting unit tests (vitest only) from guards (policy linters) means:
- PR gate is fast + behavioral (genuine failures)
- Guards run everywhere (locally via pre-push, in deploy CI) with instant feedback
- Developer sees all violations at once, not one-by-one
- db-flags.test.js: replace toBe(14) with managedFlagKeys().length-derived coverage checks (+ a floor for the registry-membership test) so adding a feature flag no longer breaks the suite. - seed-sapphire-2026-concepts.test.js: exact-count -> floor; shape, uniqueness, headline coverage already asserted separately. - run-static-guards.ts: --fix flag routes to fixable guards + prints hint. - check-icon-imports.ts / check-kg-meta-formatters-mirror.ts: --fix mode applies the mechanical, zero-judgment fix (add side-effect import / copy authoritative mirror).
# Conflicts: # test/unit/db-flags.test.js
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the chronic CI brittleness where unit-test gates fail daily on policy-linter noise, not real behavioral failures. Developers now ignore the red gate (normalization of deviance), risking actual regressions through.
Data: Last 10 failed CI runs — 8 failed on the guard chain, only 2 on vitest. Both vitest failures were magic-number assertions (expected 15, got 14; expected 50, got 49), not product bugs.
Changes
unit-tests.yml(vitest only) + newstatic-guards.yml(13 policy linters)&&-chained runners:npm run static-guardsruns all checks, reports all failures at oncescripts/git-hooks/pre-pushruns guards before push (instant local feedback)Signal restoration
Testing
npm run static-guardspasses all 13 checks locally (14.8s)npm run setup:git-hooksinstalls pre-push hookFollow-up (optional, after merge)
Items 4–5 from the original plan (delete exact-count assertions, add auto-fix to guards) are separate PRs; they require curating which specific assertions are worth hardening vs. softening.