diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3edaa2a..7e04996 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,17 +14,27 @@ jobs: - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: { node-version: 24, cache: pnpm } - uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1 - with: { rustflags: "" } + with: { rustflags: "", components: "llvm-tools-preview" } - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 - run: rustup target add wasm32-unknown-unknown - name: Install wasm-pack 0.14.0 run: cargo install wasm-pack --version 0.14.0 --locked + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@25435dc8dd3baed7417e0c96d3fe89013a5b2e09 # v2.81.3 + with: { tool: cargo-llvm-cov } - run: pnpm install --frozen-lockfile - run: pnpm -r build - run: pnpm -r lint - run: pnpm -r test - run: cargo build --manifest-path packages/codec/Cargo.toml --release - - run: cargo test --manifest-path packages/codec/Cargo.toml + - name: Rust coverage gate (Constitution X — 80% line coverage) + run: cargo llvm-cov --manifest-path packages/codec/Cargo.toml --all-features --fail-under-lines 80 --lcov --output-path rust-lcov.info + - name: Upload coverage to Codecov + uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1 + with: + files: rust-lcov.info,packages/codec/coverage/lcov.info + flags: rust,ts + fail_ci_if_error: false - name: Assert size budgets run: bash scripts/assert-size.sh working-directory: packages/codec diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..d5def11 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,16 @@ +coverage: + status: + patch: + rust: + informational: true + project: + rust: + informational: true + +flags: + rust: + paths: + - packages/codec/src/ + ts: + paths: + - packages/codec/src/ diff --git a/packages/codec/vitest.config.ts b/packages/codec/vitest.config.ts index 0cb1996..bf4a462 100644 --- a/packages/codec/vitest.config.ts +++ b/packages/codec/vitest.config.ts @@ -16,7 +16,8 @@ export default defineConfig({ // enabled: true → `vitest run` always collects + gates coverage, so the // 80% threshold (Constitution X) is enforced by plain `pnpm -r test` in CI. enabled: true, - include: ['src/**'], + include: ['src/**/*.ts'], + reporter: ['text', 'lcov'], exclude: [ 'target/**', 'pkg/**',