Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions ghost/core/.c8rc.e2e.json

This file was deleted.

25 changes: 0 additions & 25 deletions ghost/core/.c8rc.json

This file was deleted.

5 changes: 2 additions & 3 deletions ghost/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"test:integration": "vitest run -c vitest.config.db.ts --project integration",
"test:e2e": "vitest run -c vitest.config.db.ts --project e2e --project e2e-api --project e2e-isolated",
"test:legacy": "vitest run -c vitest.config.db.ts --project legacy",
"test:ci:e2e": "c8 -c ./.c8rc.e2e.json -o coverage-e2e pnpm test:e2e",
"test:ci:integration": "c8 -c ./.c8rc.e2e.json -o coverage-integration --lines 52 --functions 47 --branches 73 --statements 52 pnpm test:integration",
"test:ci:e2e": "COVERAGE_LANE=e2e pnpm test:e2e --coverage",
"test:ci:integration": "COVERAGE_LANE=integration pnpm test:integration --coverage",
"test:int:slow": "pnpm test:integration",
"test:e2e:slow": "vitest run -c vitest.config.db.ts --project e2e --project e2e-api --reporter=verbose",
"test:leg:slow": "vitest run -c vitest.config.db.ts --project legacy --reporter=verbose",
Expand Down Expand Up @@ -279,7 +279,6 @@
"@types/supertest": "6.0.3",
"@typescript/native": "catalog:",
"@vitest/coverage-v8": "catalog:",
"c8": "catalog:",
"chai": "catalog:",
"cli-progress": "3.12.0",
"cssnano": "7.1.9",
Expand Down
58 changes: 58 additions & 0 deletions ghost/core/vitest.config.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,43 @@ const sharedDbConfig = {
hookTimeout: 60000,
};

// Coverage gates per acceptance lane, selected by COVERAGE_LANE (set in the
// test:ci:* scripts). Baselines measured against MySQL 8.0 + Redis + MinIO,
// minus ~2pt of headroom. Unset means no gate — ad-hoc local --coverage runs
// report without failing.
type CoverageLane = {
reportsDirectory: string;
thresholds: {
statements: number;
branches: number;
functions: number;
lines: number;
};
};

const COVERAGE_LANES: Record<string, CoverageLane> = {
e2e: {
reportsDirectory: 'coverage-e2e',
thresholds: { statements: 70, branches: 56, functions: 74, lines: 70 },
},
integration: {
reportsDirectory: 'coverage-integration',
thresholds: { statements: 47, branches: 32, functions: 47, lines: 47 },
},
};

// Object.hasOwn, not a truthy lookup: 'constructor' and the rest of
// Object.prototype would otherwise resolve to inherited members and silently
// skip the gate. An empty string is a bad value too, not "unset".
const laneName = process.env.COVERAGE_LANE;
if (laneName !== undefined && !Object.hasOwn(COVERAGE_LANES, laneName)) {
// eslint-disable-next-line ghost/ghost-custom/no-native-error
throw new Error(
`Unknown COVERAGE_LANE '${laneName}' — expected one of: ${Object.keys(COVERAGE_LANES).join(', ')}`,
);
}
const coverageLane = laneName === undefined ? undefined : COVERAGE_LANES[laneName];

export default defineConfig({
test: {
resolveSnapshotPath,
Expand All @@ -109,6 +146,27 @@ export default defineConfig({
// Local runs use the compact `dot` reporter. CI uses `default` plus
// `github-actions` for inline annotations (mirrors vitest.config.ts).
reporters: process.env.GITHUB_ACTIONS ? ['default', 'github-actions'] : ['dot'],
// Coverage for the CI acceptance lanes (test:ci:e2e / test:ci:integration),
// which pass --coverage and pick their lane via COVERAGE_LANE. `include`
// is what reports never-loaded files under vitest 4 (there is no `all`).
coverage: {
provider: 'v8',
include: ['core/*.js', 'core/{frontend,server,shared}/**/*.{js,cjs,mjs,ts}'],
exclude: [
'core/frontend/src/**',
'core/frontend/public/**',
'core/frontend/helpers/**',
'core/server/data/migrations/**',
'core/server/data/schema/schema.js',
'core/server/web/api/testmode/**',
'core/server/services/koenig/**',
// Type-only declarations: no runtime code, and the remapper's parser
// rejects them ('Expected `from` but found `{`' on `import type`).
'**/*.d.ts',
],
reporter: ['text-summary', 'cobertura'],
...coverageLane,
},
projects: [
{
ssr: sharedSsrConfig,
Expand Down
Loading
Loading