veza/scripts/coverage-trend.mjs

63 lines
1.8 KiB
JavaScript
Raw Normal View History

chore(cleanup): remove orphan code + archive disabled workflows + .playwright-mcp Triple cleanup, landed together because they share the same cleanup branch intent and touch non-overlapping trees. 1. 38× tracked .playwright-mcp/*.yml stage-deleted MCP session recordings that had been inadvertently committed. .gitignore already covers .playwright-mcp/ (post-audit J2 block added in d12b901de). Working tree copies removed separately. 2. 19× disabled CI workflows moved to docs/archive/workflows/ Legacy .yml.disabled files in .github/workflows/ were 1676 LOC of dead config (backend-ci, cd, staging-validation, accessibility, chromatic, visual-regression, storybook-audit, contract-testing, zap-dast, container-scan, semgrep, sast, mutation-testing, rust-mutation, load-test-nightly, flaky-report, openapi-lint, commitlint, performance). Preserved in docs/archive/workflows/ for historical reference; `.github/workflows/` now only lists the 5 actually-running pipelines. 3. Orphan code removed (0 consumers confirmed via grep) - veza-backend-api/internal/repository/user_repository.go In-memory UserRepository mock, never imported anywhere. - proto/chat/chat.proto Chat server Rust deleted 2026-02-22 (commit 279a10d31); proto file was orphan spec. Chat lives 100% in Go backend now. - veza-common/src/types/chat.rs (Conversation, Message, MessageType, Attachment, Reaction) - veza-common/src/types/websocket.rs (WebSocketMessage, PresenceStatus, CallType — depended on chat::MessageType) - veza-common/src/types/mod.rs updated: removed `pub mod chat;`, `pub mod websocket;`, and their re-exports. Only `veza_common::logging` is consumed by veza-stream-server (verified with `grep -r "veza_common::"`). `cargo check` on veza-common passes post-removal. Refs: AUDIT_REPORT.md §8.2 "Code mort / orphelin" + §9.1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 18:33:40 +00:00
#!/usr/bin/env node
/**
* Coverage Trend Script
*
* Reads Vitest coverage summary and appends to a JSON trend file.
* Usage: node scripts/coverage-trend.mjs [coverage-summary.json] [trend-output.json]
*/
import { readFileSync, writeFileSync, existsSync } from 'fs';
const summaryPath = process.argv[2] || 'apps/web/coverage/coverage-summary.json';
const trendPath = process.argv[3] || 'coverage-trend.json';
function readTrend() {
if (existsSync(trendPath)) {
return JSON.parse(readFileSync(trendPath, 'utf8'));
}
return { entries: [] };
}
function extractCoverage(summaryPath) {
if (!existsSync(summaryPath)) {
console.error(`Coverage summary not found: ${summaryPath}`);
return null;
}
const summary = JSON.parse(readFileSync(summaryPath, 'utf8'));
const total = summary.total || {};
return {
date: new Date().toISOString().split('T')[0],
commit: process.env.GITHUB_SHA?.slice(0, 7) || 'local',
lines: total.lines?.pct ?? 0,
branches: total.branches?.pct ?? 0,
functions: total.functions?.pct ?? 0,
statements: total.statements?.pct ?? 0,
};
}
const coverage = extractCoverage(summaryPath);
if (coverage) {
const trend = readTrend();
// Keep last 100 entries
trend.entries.push(coverage);
if (trend.entries.length > 100) {
trend.entries = trend.entries.slice(-100);
}
writeFileSync(trendPath, JSON.stringify(trend, null, 2));
console.log(`Coverage trend updated: lines=${coverage.lines}%, branches=${coverage.branches}%`);
// Check for regression (> 2% drop from last entry)
if (trend.entries.length >= 2) {
const prev = trend.entries[trend.entries.length - 2];
const linesDrop = prev.lines - coverage.lines;
if (linesDrop > 2) {
console.warn(`WARNING: Line coverage dropped ${linesDrop.toFixed(1)}% (${prev.lines}% -> ${coverage.lines}%)`);
}
}
}