@decohere/ci-tools 0.0.1-dev.13 → 0.0.1-dev.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/LICENSE +15 -0
  2. package/package.json +17 -3
  3. package/src/audit/enforce.mjs +7 -5
  4. package/src/audit/format.mjs +133 -0
  5. package/src/audit/summarize.mjs +10 -32
  6. package/src/audit/upsert-issue.mjs +25 -74
  7. package/src/bench/bench.mjs +134 -368
  8. package/src/bench/file-regressions.mjs +76 -0
  9. package/src/bench/history.mjs +248 -0
  10. package/src/bench/nightly.mjs +118 -0
  11. package/src/bench/regression-issue.mjs +44 -0
  12. package/src/bench/trace.mjs +18 -14
  13. package/src/github/npm-bootstrap.mjs +179 -0
  14. package/src/github/oidc-bootstrap-nudge.mjs +214 -0
  15. package/src/github/publish-verify.mjs +206 -0
  16. package/src/github/smoke-create-launcher.mjs +85 -0
  17. package/src/lib/github-issue.mjs +75 -0
  18. package/src/lib/lcov.mjs +1 -1
  19. package/src/lib/workspace-packages.mjs +30 -0
  20. package/src/pages/artifact.mjs +38 -183
  21. package/src/pages/bench-page.mjs +323 -0
  22. package/src/pages/restore-badges.mjs +35 -0
  23. package/src/pages/restore-bench-history.mjs +15 -28
  24. package/src/release/npm-links.mjs +6 -13
  25. package/src/release/sync-dependencies.mjs +1 -2
  26. package/tests/audit/format.test.mjs +115 -0
  27. package/tests/bench/history.test.mjs +279 -0
  28. package/tests/bench/regression-issue.test.mjs +42 -0
  29. package/tests/github/ci-workflow.test.mjs +19 -0
  30. package/tests/github/npm-bootstrap.test.mjs +125 -0
  31. package/tests/github/oidc-bootstrap-nudge.test.mjs +89 -0
  32. package/tests/github/package-metadata.test.mjs +69 -0
  33. package/tests/github/publish-verify.test.mjs +115 -0
  34. package/tests/github/smoke-create-launcher.test.mjs +132 -0
  35. package/tests/lib/github-issue.test.mjs +85 -0
  36. package/tests/lib/lcov.test.mjs +8 -8
  37. package/tests/pages/bench-page.test.mjs +123 -0
  38. package/src/coverage/enforce-thresholds.mjs +0 -144
  39. package/src/pages/clear-bench-history.mjs +0 -27
  40. package/src/pages/keep-prior-bench-badge.mjs +0 -38
@@ -1,144 +0,0 @@
1
- import { existsSync, readdirSync, readFileSync } from "node:fs";
2
- import { resolve } from "node:path";
3
- import { pathToFileURL } from "node:url";
4
- import { parseLcovByProject } from "../lib/lcov.mjs";
5
-
6
- function parseArgs(argv) {
7
- const options = {
8
- lcov: ".forge/coverage/lcov.info",
9
- thresholds: null,
10
- thresholdsModule: null,
11
- projectsDir: "projects",
12
- };
13
-
14
- for (let index = 0; index < argv.length; index += 1) {
15
- const arg = argv[index];
16
- if (arg === "--lcov") {
17
- options.lcov = argv[index + 1] ?? options.lcov;
18
- index += 1;
19
- continue;
20
- }
21
- if (arg === "--thresholds") {
22
- options.thresholds = argv[index + 1] ?? options.thresholds;
23
- index += 1;
24
- continue;
25
- }
26
- if (arg === "--thresholds-module") {
27
- options.thresholdsModule = argv[index + 1] ?? options.thresholdsModule;
28
- index += 1;
29
- continue;
30
- }
31
- if (arg === "--projectsDir") {
32
- options.projectsDir = argv[index + 1] ?? options.projectsDir;
33
- index += 1;
34
- }
35
- }
36
-
37
- return options;
38
- }
39
-
40
- async function resolveThresholds(options) {
41
- if (options.thresholdsModule) {
42
- const moduleUrl = pathToFileURL(resolve(options.thresholdsModule)).href;
43
- const mod = await import(moduleUrl);
44
- const thresholds = mod.projectCoverageThresholds;
45
- if (typeof thresholds !== "object" || thresholds == null) {
46
- console.error(
47
- `Module ${options.thresholdsModule} must export a 'projectCoverageThresholds' object.`,
48
- );
49
- process.exit(1);
50
- }
51
- return thresholds;
52
- }
53
-
54
- const path = options.thresholds ?? "coverage.config.json";
55
- if (!existsSync(path)) {
56
- console.error(`Thresholds config not found: ${path}`);
57
- process.exit(1);
58
- }
59
- const parsed = JSON.parse(readFileSync(path, "utf8"));
60
- if (typeof parsed !== "object" || parsed == null) {
61
- console.error(
62
- "Thresholds config must be a JSON object mapping project => minimum coverage percentage.",
63
- );
64
- process.exit(1);
65
- }
66
- return parsed;
67
- }
68
-
69
- function formatPct(value) {
70
- return `${value.toFixed(2)}%`;
71
- }
72
-
73
- async function main() {
74
- const options = parseArgs(process.argv.slice(2));
75
- const lcovPath = resolve(options.lcov);
76
- const projectsDirPath = resolve(options.projectsDir);
77
-
78
- if (!existsSync(lcovPath)) {
79
- console.error(`LCOV file not found: ${lcovPath}`);
80
- console.error("Run coverage first (example: npm run test:coverage)");
81
- process.exit(1);
82
- }
83
-
84
- if (!existsSync(projectsDirPath)) {
85
- console.error(`Projects directory not found: ${projectsDirPath}`);
86
- process.exit(1);
87
- }
88
-
89
- const thresholds = await resolveThresholds(options);
90
- const projectDirs = readdirSync(projectsDirPath, { withFileTypes: true })
91
- .filter((entry) => entry.isDirectory())
92
- .map((entry) => entry.name)
93
- .sort((left, right) => left.localeCompare(right));
94
-
95
- const coverageByProject = parseLcovByProject(readFileSync(lcovPath, "utf8"));
96
-
97
- const missingThresholds = projectDirs.filter(
98
- (projectName) => thresholds[projectName] == null,
99
- );
100
- if (missingThresholds.length > 0) {
101
- console.error("Missing coverage thresholds for projects:");
102
- for (const projectName of missingThresholds) console.error(`- ${projectName}`);
103
- console.error(
104
- "Update projectCoverageThresholds in vitest.config.ts to include all project directories.",
105
- );
106
- process.exit(1);
107
- }
108
-
109
- const failures = [];
110
- console.log("Project line coverage thresholds");
111
-
112
- for (const projectName of projectDirs) {
113
- const projectCoverage = coverageByProject.get(projectName) ?? {
114
- totalLines: 0,
115
- coveredLines: 0,
116
- };
117
- const currentPct =
118
- projectCoverage.totalLines === 0
119
- ? 0
120
- : (projectCoverage.coveredLines / projectCoverage.totalLines) * 100;
121
- const minimumPct = Number(thresholds[projectName]);
122
- const passed = Number.isFinite(minimumPct) && currentPct >= minimumPct;
123
-
124
- console.log(
125
- `${passed ? "✅" : "❌"} ${projectName}: ${formatPct(currentPct)} (min ${formatPct(minimumPct)})`,
126
- );
127
-
128
- if (!passed) failures.push({ projectName, currentPct, minimumPct });
129
- }
130
-
131
- if (failures.length > 0) {
132
- console.error("\nCoverage threshold check failed:");
133
- for (const failure of failures) {
134
- console.error(
135
- `- ${failure.projectName}: ${formatPct(failure.currentPct)} is below ${formatPct(failure.minimumPct)}`,
136
- );
137
- }
138
- process.exit(1);
139
- }
140
-
141
- console.log("\nAll project coverage thresholds passed.");
142
- }
143
-
144
- main();
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Clear benchmark history for this publish (workflow_dispatch with clear-history=true)
4
-
5
- import { writeFileSync } from "node:fs";
6
- import { mkdir } from "node:fs/promises";
7
-
8
- const HISTORY_DIR = "projects/ci-tools/dist/ci/bench";
9
- const HISTORY_FILE = `${HISTORY_DIR}/bench-history.json`;
10
-
11
- try {
12
- await mkdir(HISTORY_DIR, { recursive: true });
13
- writeFileSync(
14
- HISTORY_FILE,
15
- JSON.stringify(
16
- {
17
- runs: {},
18
- },
19
- null,
20
- 2,
21
- ),
22
- );
23
- console.log("✓ Cleared benchmark history");
24
- } catch (error) {
25
- console.error("Error clearing benchmark history:", error.message);
26
- process.exit(1);
27
- }
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Keep prior bench badge if no code changes; create fallback if none exists
4
-
5
- import { execSync } from "node:child_process";
6
- import { existsSync, writeFileSync } from "node:fs";
7
- import { mkdir } from "node:fs/promises";
8
-
9
- const BADGES_DIR = "projects/ci-tools/dist/ci/badges";
10
- const BADGE_FILE = `${BADGES_DIR}/bench.svg`;
11
- const PAGES_URL = "https://typesmiths.github.io/decohere/badges/bench.svg";
12
-
13
- const FALLBACK_BADGE = `<svg xmlns="http://www.w3.org/2000/svg" width="120" height="20" role="img" aria-label="bench: unavailable">
14
- <title>bench: unavailable</title>
15
- <rect width="120" height="20" fill="#555"/>
16
- <rect x="46" width="74" height="20" fill="#9f9f9f"/>
17
- <text x="24" y="14" fill="#fff" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11" text-anchor="middle">bench</text>
18
- <text x="83" y="14" fill="#fff" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11" text-anchor="middle">unavailable</text>
19
- </svg>`;
20
-
21
- try {
22
- if (!existsSync(BADGE_FILE)) {
23
- await mkdir(BADGES_DIR, { recursive: true });
24
-
25
- try {
26
- execSync(`curl -fsSL "${PAGES_URL}" -o "${BADGE_FILE}"`, {
27
- stdio: "pipe",
28
- });
29
- console.log("✓ Restored prior bench badge from Pages");
30
- } catch {
31
- console.warn("::warning::No prior bench badge found on Pages; creating fallback badge.");
32
- writeFileSync(BADGE_FILE, FALLBACK_BADGE);
33
- }
34
- }
35
- } catch (error) {
36
- console.error("Error keeping prior bench badge:", error.message);
37
- process.exit(1);
38
- }