Skip to content

Commit 690e0e3

Browse files
authored
test: add critical unit coverage gate (#13313)
## Summary Add a `COVERAGE_CRITICAL` unit-coverage gate over folder-based critical runtime areas and wire it into the unit CI job. First PR of a stacked series that ratchets the gate upward as tests land. ## Changes - **What**: `vite.config.mts` gains `CRITICAL_COVERAGE_INCLUDE` folder globs for core runtime areas: `src/base`, `src/composables`, `src/core`, `src/schemas`, `src/scripts`, `src/services`, `src/stores`, `src/utils`, selected `src/platform` logic slices, selected `src/lib/litegraph/src/{node,subgraph,utils}` primitives, and selected `src/workbench` manager logic; `package.json` gains `test:coverage:critical` (`COVERAGE_CRITICAL=true vitest run --coverage`); `ci-tests-unit.yaml` runs the gate. The thresholds are env-gated, so the normal `test:coverage` run is unaffected. - **Breaking**: none. ## Review Focus Establishes the measurement substrate, no tests added yet. Thresholds are locked to the current baseline over the folder-based critical scope so CI is green: | metric | baseline | threshold | |---|---|---| | statements | 69.53% (24287/34930) | 69 | | branches | 60.7% (11497/18940) | 60 | | functions | 67.34% (4980/7395) | 67 | | lines | 70.83% (22619/31930) | 70 | The scope is intentionally not whole `src/platform`, `src/lib`, or `src/workbench`: UI-heavy and specialized lanes like platform components, telemetry/surveys, litegraph canvas/widgets/infrastructure/types, and manager components/types stay outside this gate for now. Subsequent stacked PRs add tests and bump these thresholds; a later refactor series ratchets branches to 90. Created by Codex <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Changes are limited to test/coverage configuration and CI; no application runtime behavior is modified. > > **Overview** > Introduces a **critical-path unit coverage gate** that only runs when `COVERAGE_CRITICAL=true`, leaving the existing `pnpm test:coverage` behavior unchanged. > > **Vitest** (`vite.config.mts`): when the flag is set, coverage is limited to folder globs for core runtime areas (base, composables, core, services, stores, utils, selected platform/workspace/auth slices, litegraph node/subgraph/utils, workbench manager logic, etc.) and **Vitest thresholds** are enforced (statements 69%, branches 60%, functions 67%, lines 70%). In that mode, litegraph is no longer blanket-excluded from coverage the way the full `src` run still excludes `src/lib/litegraph/**`. > > **Tooling & CI**: adds `test:coverage:critical` in `package.json` and a new unit CI step after Codecov upload that runs the gate so regressions in those areas fail the job. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 25e73f3. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: huang47 <157390+huang47@users.noreply.github.com>
1 parent 01738b7 commit 690e0e3

3 files changed

Lines changed: 58 additions & 3 deletions

File tree

.github/workflows/ci-tests-unit.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ jobs:
5555
flags: unit
5656
token: ${{ secrets.CODECOV_TOKEN }}
5757
fail_ci_if_error: false
58+
59+
- name: Enforce critical coverage gate
60+
run: pnpm test:coverage:critical

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"test:browser:coverage": "cross-env COLLECT_COVERAGE=true pnpm test:browser",
5454
"test:browser:local": "cross-env PLAYWRIGHT_LOCAL=1 PLAYWRIGHT_TEST_URL=http://localhost:5173 pnpm test:browser",
5555
"test:coverage": "vitest run --coverage",
56+
"test:coverage:critical": "cross-env COVERAGE_CRITICAL=true vitest run --coverage",
5657
"test:unit": "vitest run",
5758
"typecheck": "vue-tsc --noEmit",
5859
"typecheck:browser": "vue-tsc --project browser_tests/tsconfig.json",

vite.config.mts

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,54 @@ const VITE_REMOTE_DEV = process.env.VITE_REMOTE_DEV === 'true'
2929
const DISABLE_TEMPLATES_PROXY = process.env.DISABLE_TEMPLATES_PROXY === 'true'
3030
const GENERATE_SOURCEMAP = process.env.GENERATE_SOURCEMAP !== 'false'
3131
const IS_STORYBOOK = process.env.npm_lifecycle_event === 'storybook'
32+
const COVERAGE_CRITICAL = process.env.COVERAGE_CRITICAL === 'true'
33+
34+
const CRITICAL_COVERAGE_INCLUDE = [
35+
'src/base/**/*.{ts,vue}',
36+
'src/composables/**/*.{ts,vue}',
37+
'src/core/**/*.{ts,vue}',
38+
'src/lib/litegraph/src/node/**/*.{ts,vue}',
39+
'src/lib/litegraph/src/subgraph/**/*.{ts,vue}',
40+
'src/lib/litegraph/src/utils/**/*.{ts,vue}',
41+
'src/platform/assets/composables/**/*.{ts,vue}',
42+
'src/platform/assets/mappings/**/*.{ts,vue}',
43+
'src/platform/assets/schemas/**/*.{ts,vue}',
44+
'src/platform/assets/services/**/*.{ts,vue}',
45+
'src/platform/assets/utils/**/*.{ts,vue}',
46+
'src/platform/errorCatalog/**/*.{ts,vue}',
47+
'src/platform/keybindings/**/*.{ts,vue}',
48+
'src/platform/missingMedia/**/*.{ts,vue}',
49+
'src/platform/missingModel/**/*.{ts,vue}',
50+
'src/platform/navigation/**/*.{ts,vue}',
51+
'src/platform/nodeReplacement/**/*.{ts,vue}',
52+
'src/platform/remote/**/*.{ts,vue}',
53+
'src/platform/remoteConfig/**/*.{ts,vue}',
54+
'src/platform/secrets/**/*.{ts,vue}',
55+
'src/platform/settings/**/*.{ts,vue}',
56+
'src/platform/workflow/**/*.{ts,vue}',
57+
'src/platform/workspace/api/**/*.{ts,vue}',
58+
'src/platform/workspace/auth/**/*.{ts,vue}',
59+
'src/platform/workspace/composables/**/*.{ts,vue}',
60+
'src/platform/workspace/stores/**/*.{ts,vue}',
61+
'src/platform/workspace/utils/**/*.{ts,vue}',
62+
'src/schemas/**/*.{ts,vue}',
63+
'src/scripts/**/*.{ts,vue}',
64+
'src/services/**/*.{ts,vue}',
65+
'src/stores/**/*.{ts,vue}',
66+
'src/utils/**/*.{ts,vue}',
67+
'src/workbench/extensions/manager/composables/**/*.{ts,vue}',
68+
'src/workbench/extensions/manager/services/**/*.{ts,vue}',
69+
'src/workbench/extensions/manager/stores/**/*.{ts,vue}',
70+
'src/workbench/extensions/manager/utils/**/*.{ts,vue}',
71+
'src/workbench/utils/**/*.{ts,vue}'
72+
]
73+
74+
const CRITICAL_COVERAGE_THRESHOLDS = {
75+
statements: 69,
76+
branches: 60,
77+
functions: 67,
78+
lines: 70
79+
}
3280

3381
// Open Graph / Twitter Meta Tags Constants
3482
const VITE_OG_URL = 'https://cloud.comfy.org'
@@ -668,16 +716,19 @@ export default defineConfig({
668716
coverage: {
669717
provider: 'v8',
670718
reporter: ['text', 'json', 'html', 'lcov'],
671-
include: ['src/**/*.{ts,vue}'],
719+
include: COVERAGE_CRITICAL
720+
? CRITICAL_COVERAGE_INCLUDE
721+
: ['src/**/*.{ts,vue}'],
672722
exclude: [
673723
'src/**/*.test.ts',
674724
'src/**/*.spec.ts',
675725
'src/**/*.stories.ts',
676726
'src/**/*.d.ts',
677727
'src/locales/**',
678-
'src/lib/litegraph/**',
728+
...(COVERAGE_CRITICAL ? [] : ['src/lib/litegraph/**']),
679729
'src/assets/**'
680-
]
730+
],
731+
...(COVERAGE_CRITICAL ? { thresholds: CRITICAL_COVERAGE_THRESHOLDS } : {})
681732
},
682733
exclude: [
683734
'**/node_modules/**',

0 commit comments

Comments
 (0)