SonarCloud ran Automatic Analysis: no coverage, and a scan of the repo rather than of what CI builds. sonarcloud.yml replaces it — full-history checkout, the coverage run, then the scan with the package version as the new-code baseline. It is its own workflow so a Sonar outage or gate opinion can never turn CI red, the scan action is pinned to a commit because it holds SONAR_TOKEN, the token reaches only the two steps that use it, and runs without secrets (Dependabot, forks) skip with a notice instead of failing. Coverage now measures every src/**/*.ts module and emits lcov, but the CI gate is unchanged: a glob threshold applies the docs/11 §1 numbers to src/lib/core/** only (verified to still fail a run below them). Hardening, from SonarCloud's findings and the scripts/config audit: - npm ci --ignore-scripts everywhere, with `wxt prepare` run explicitly; - checkouts drop persisted credentials; - release.yml is split: gates and zip run with a read-only token; only a job that installs nothing and runs no repo code creates the Release; the store submit uses the local wxt binary, never `npx` with secrets in scope; - reusables get named secrets instead of `inherit`. The announce job could never have worked: this repo stores RELEASES_WEBHOOK/REPO_WEBHOOK, the reusable reads DISCORD_*, and inherit passed neither; - CI runs `npm audit --omit=dev`, which docs/09 already claimed it did; - a non-required Windows smoke job (guard + unit tests). serializeMarkdown's trailing-newline trim used /\n+$/, which backtracks quadratically over a long newline run that is not at the end (S8786); it is now a single backward scan, with a 20k-newline regression test. docs/12 no longer copies the workflow YAML — the copies drifted three times, and under docs-win a stale copy invites reverting a pinned action. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
import { defineConfig } from 'vitest/config';
|
|
import { WxtVitest } from 'wxt/testing/vitest-plugin';
|
|
|
|
/**
|
|
* jsdom, not happy-dom (docs/02 §3). The Netscape parser walk depends on
|
|
* HTML5 "generate implied end tags" — the child <DL> nesting inside an
|
|
* unclosed <DT> — and on `:scope > h3` from an element root. jsdom uses
|
|
* parse5 and is spec-compliant on both; happy-dom is not, so a suite run
|
|
* there would validate a DOM the browser never produces.
|
|
*/
|
|
export default defineConfig({
|
|
// The svelte plugin is what compiles runes inside `.svelte.ts` store modules;
|
|
// without it they throw "$state is not defined" under vitest.
|
|
plugins: [svelte(), WxtVitest()],
|
|
test: {
|
|
environment: 'jsdom',
|
|
include: ['tests/unit/**/*.test.ts'],
|
|
coverage: {
|
|
provider: 'v8',
|
|
// Every TypeScript module is MEASURED, so SonarCloud sees real numbers
|
|
// for the browser layer, stores and edit logic too (docs/12 §2.5).
|
|
// Components and entrypoints are excluded on Sonar's side, matching the
|
|
// docs/11 §1 split: they are covered by the manual QA pass.
|
|
include: ['src/**/*.ts'],
|
|
reporter: ['text', 'lcov'],
|
|
// Only core is GATED, and with a glob threshold rather than a global one,
|
|
// so widening `include` cannot loosen or tighten the CI gate: the numbers
|
|
// below apply to src/lib/core/** alone, exactly as before (docs/11 §1).
|
|
thresholds: {
|
|
'src/lib/core/**': { lines: 90, functions: 90, branches: 85 },
|
|
},
|
|
},
|
|
},
|
|
});
|