mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Collapse duplicate CI spend while keeping each gate's existence reason: - quality.yml: TIA __RUN_ALL__ defers full unit to fast-unit 4-shard (#6781); path filters via classify-pr-changes; docs-gates split; draft skip - ci.yml: wire docs/i18n/code path filters; ESLint JSON artifact for quality-gate; drop advisory typecheck:noimplicit; float actions/cache@v6 - TIA parity: memory/usage/combo/serial; **/*.test.mjs any depth; electron/bin no longer force unit __RUN_ALL__ - check:complexity-ratchets: one ESLint walk, ruleId-isolated baselines + cache - check:api-docs-refs + lib/apiRoutes: shared API route inventory - husky pre-push: intentionally light (gates live in pre-commit); CLAUDE.md + QUALITY_GATES.md docs synced - collect-metrics / lint:json: path.resolve cache path; Windows-safe eslint bin - env-doc allowlist for ESLINT_RESULTS_JSON / COMPLEXITY_ESLINT_REPORT - release-green --full-ci expects check:api-docs-refs (not docs-symbols alone) Tests: select-impacted, classify-pr-changes, api-routes lib, complexity-rule-count, validate-release-green. Reconciled after #6781 (fast-unit 2→4 shards) per maintainer request on #6716. Co-authored-by: Diego Rodrigues de Sa e Souza <8016841+diegosouzapw@users.noreply.github.com>
120 lines
3.2 KiB
JavaScript
120 lines
3.2 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* PR change classification for ci.yml path filters.
|
|
*
|
|
* Why this exists (not "skip work for free"):
|
|
* - code → typecheck, unit/vitest, lint bag, quality ratchets (code regressions)
|
|
* - docs → docs-sync / prose (doc/API contract regressions)
|
|
* - i18n → message/UI-key validation (translation regressions)
|
|
* - workflow → CI definition changes (always treat as code — gates protect the gates)
|
|
*
|
|
* Pure docs or pure message-catalog PRs should NOT pay full unit/lint wall time.
|
|
* Unknown paths default to code (fail-safe: better over-run than under-protect).
|
|
*/
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
/**
|
|
* @param {string[]} files relative paths from git diff
|
|
* @returns {{ code: boolean, docs: boolean, i18n: boolean, workflow: boolean }}
|
|
*/
|
|
export function classifyPaths(files) {
|
|
let code = false;
|
|
let docs = false;
|
|
let i18n = false;
|
|
let workflow = false;
|
|
|
|
for (const raw of files) {
|
|
const f = String(raw || "")
|
|
.trim()
|
|
.replace(/\\/g, "/");
|
|
if (!f) continue;
|
|
|
|
if (f.startsWith(".github/workflows/") || f === ".zizmor.yml") {
|
|
workflow = true;
|
|
// Workflow edits can weaken or remove gates — treat as code.
|
|
code = true;
|
|
continue;
|
|
}
|
|
|
|
// Message catalogs only: translation content, not runtime TS.
|
|
if (f.startsWith("src/i18n/messages/")) {
|
|
i18n = true;
|
|
continue;
|
|
}
|
|
|
|
// i18n tooling / non-message i18n source → also code (scripts, config, loaders).
|
|
if (
|
|
f.startsWith("scripts/i18n/") ||
|
|
f === "config/i18n.json" ||
|
|
f.startsWith("src/i18n/")
|
|
) {
|
|
i18n = true;
|
|
code = true;
|
|
continue;
|
|
}
|
|
|
|
if (f.startsWith("docs/") || f.endsWith(".md")) {
|
|
docs = true;
|
|
continue;
|
|
}
|
|
|
|
if (
|
|
f.startsWith("src/") ||
|
|
f.startsWith("open-sse/") ||
|
|
f.startsWith("bin/") ||
|
|
f.startsWith("electron/") ||
|
|
f.startsWith("tests/") ||
|
|
f.startsWith("scripts/") ||
|
|
f.startsWith("db/") ||
|
|
f.startsWith("config/") ||
|
|
f === "package.json" ||
|
|
f === "package-lock.json" ||
|
|
/^tsconfig.*\.json$/.test(f) ||
|
|
f.startsWith("next.config.") ||
|
|
f.startsWith("vitest") ||
|
|
f.startsWith("playwright.config.")
|
|
) {
|
|
code = true;
|
|
continue;
|
|
}
|
|
|
|
// Fail-safe: unknown path class → code (do not skip heavy gates by accident).
|
|
code = true;
|
|
}
|
|
|
|
return { code, docs, i18n, workflow };
|
|
}
|
|
|
|
function main() {
|
|
const listPath = process.argv[2];
|
|
let files;
|
|
if (listPath && listPath !== "-") {
|
|
files = fs
|
|
.readFileSync(listPath, "utf8")
|
|
.split(/\r?\n/)
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
} else {
|
|
const stdin = fs.readFileSync(0, "utf8");
|
|
files = stdin
|
|
.split(/\r?\n/)
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
}
|
|
const c = classifyPaths(files);
|
|
// GitHub Actions output format (also human-readable key=value).
|
|
process.stdout.write(
|
|
`code=${c.code}\ndocs=${c.docs}\ni18n=${c.i18n}\nworkflow=${c.workflow}\n`
|
|
);
|
|
}
|
|
|
|
const isMain =
|
|
process.argv[1] &&
|
|
path.resolve(fileURLToPath(import.meta.url)) === path.resolve(process.argv[1]);
|
|
|
|
if (isMain) {
|
|
main();
|
|
}
|