forked from inkeep/agents
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoverage.config.ts
More file actions
183 lines (169 loc) · 4.84 KB
/
coverage.config.ts
File metadata and controls
183 lines (169 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/**
* Unified Coverage Configuration for Monorepo
*
* This configuration defines the coverage threshold progression strategy
* for all packages in the monorepo. Each package can be at different phases
* of coverage maturity.
*/
export interface CoverageThresholds {
lines: number;
statements: number;
functions: number;
branches: number;
}
export interface PackageCoverageConfig {
package: string;
phase: 'baseline' | 'intermediate' | 'target';
thresholds: CoverageThresholds;
customThresholds?: Partial<CoverageThresholds>; // Override specific metrics
}
/**
* Coverage progression phases
* - baseline: Minimum acceptable coverage for new/legacy code
* - intermediate: Mid-term goal for actively developed packages
* - target: Long-term goal for mature, stable packages
*/
export const COVERAGE_PHASES = {
baseline: {
lines: 30,
statements: 30,
functions: 40,
branches: 50,
},
intermediate: {
lines: 60,
statements: 60,
functions: 65,
branches: 65,
},
target: {
lines: 75,
statements: 75,
functions: 75,
branches: 75,
},
} as const;
/**
* Package-specific coverage configurations
* Packages progress through phases based on their maturity and development status
*/
export const PACKAGE_CONFIGS: PackageCoverageConfig[] = [
{
package: 'configuration-api',
phase: 'baseline',
thresholds: COVERAGE_PHASES.baseline,
// Custom override based on current coverage
customThresholds: {
functions: 50, // Current: 61.62%, set realistic intermediate goal
},
},
{
package: 'execution-api',
phase: 'baseline',
thresholds: COVERAGE_PHASES.baseline,
// Custom override based on current coverage
customThresholds: {
functions: 50, // Current: 61.62%, set realistic intermediate goal
},
},
{
package: 'agent-builder',
phase: 'baseline',
thresholds: COVERAGE_PHASES.baseline,
},
{
package: 'cli',
phase: 'intermediate',
thresholds: COVERAGE_PHASES.intermediate,
// CLI has higher current coverage, aim for target
customThresholds: {
lines: 70,
statements: 70,
functions: 70,
branches: 70,
},
},
{
package: 'packages/core',
phase: 'target',
thresholds: COVERAGE_PHASES.target,
},
];
/**
* Get coverage thresholds for a specific package
*/
export function getPackageThresholds(packageName: string): CoverageThresholds {
const config = PACKAGE_CONFIGS.find((c) => c.package === packageName);
if (!config) {
// Default to baseline for new packages
console.warn(`No coverage config for ${packageName}, using baseline thresholds`);
return COVERAGE_PHASES.baseline;
}
// Merge phase thresholds with custom overrides
return {
...config.thresholds,
...config.customThresholds,
};
}
/**
* Get the overall monorepo thresholds (minimum of all packages)
*/
export function getMonorepoThresholds(): CoverageThresholds {
const allThresholds = PACKAGE_CONFIGS.map((config) => ({
...config.thresholds,
...config.customThresholds,
}));
return {
lines: Math.min(...allThresholds.map((t) => t.lines)),
statements: Math.min(...allThresholds.map((t) => t.statements)),
functions: Math.min(...allThresholds.map((t) => t.functions)),
branches: Math.min(...allThresholds.map((t) => t.branches)),
};
}
/**
* Generate Vitest coverage config for a package
*/
export function generateVitestCoverageConfig(packageName: string) {
const thresholds = getPackageThresholds(packageName);
return {
provider: 'v8',
reporter: ['text', 'json', 'lcov', 'json-summary'],
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/*.test.ts',
'**/*.test.tsx',
'**/tests/**',
'**/__tests__/**',
'**/coverage/**',
'**/.next/**',
'**/vitest.config.ts',
'**/next.config.js',
'**/postcss.config.js',
'**/tailwind.config.ts',
],
thresholds,
};
}
/**
* CLI helper to display coverage phase information
*/
export function displayCoveragePhases() {
console.log('📊 Coverage Progression Phases:\n');
Object.entries(COVERAGE_PHASES).forEach(([phase, thresholds]) => {
console.log(`${phase.toUpperCase()}:`);
console.log(` Lines: ${thresholds.lines}%`);
console.log(` Statements: ${thresholds.statements}%`);
console.log(` Functions: ${thresholds.functions}%`);
console.log(` Branches: ${thresholds.branches}%\n`);
});
console.log('📦 Package Coverage Targets:\n');
PACKAGE_CONFIGS.forEach((config) => {
const thresholds = getPackageThresholds(config.package);
console.log(`${config.package} (${config.phase}):`);
console.log(` Lines: ${thresholds.lines}%`);
console.log(` Statements: ${thresholds.statements}%`);
console.log(` Functions: ${thresholds.functions}%`);
console.log(` Branches: ${thresholds.branches}%\n`);
});
}