PSA/scripts/check-skip-budget.mjs
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

62 lines
2.0 KiB
JavaScript

#!/usr/bin/env node
/**
* Guard against silently accumulating skipped tests.
*
* Counts `it.skip` / `test.skip` / `describe.skip` / `xit` / `xdescribe`
* markers in test files and fails when the count exceeds the budget in
* skip-budget.json. Lowering the budget as skips are fixed is encouraged;
* raising it requires editing skip-budget.json in the same PR, which makes
* the change visible in review.
*/
import { execFileSync } from 'node:child_process';
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const budgetFile = path.join(repoRoot, 'skip-budget.json');
const { maxSkips } = JSON.parse(readFileSync(budgetFile, 'utf8'));
const SEARCH_ROOTS = ['server/src', 'packages', 'shared', 'ee/server/src', 'ee/temporal-workflows/src'];
const PATTERN = String.raw`\b(it|test|describe)\.skip\b|\bxit\b|\bxdescribe\b`;
let output = '';
try {
output = execFileSync(
'grep',
[
'-rEn',
PATTERN,
'--include=*.test.ts',
'--include=*.test.tsx',
'--include=*.test.js',
'--include=*.spec.ts',
'--include=*.spec.tsx',
...SEARCH_ROOTS,
],
{ cwd: repoRoot, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 }
);
} catch (err) {
// grep exits 1 when there are no matches; anything else is a real error.
if (err.status !== 1) throw err;
}
const matches = output.split('\n').filter(Boolean);
console.log(`Skipped-test markers found: ${matches.length} (budget: ${maxSkips})`);
if (matches.length > maxSkips) {
console.error('\nSkip budget exceeded. New skipped tests:');
for (const line of matches) console.error(` ${line}`);
console.error(
`\nEither un-skip tests to get back under the budget, or raise maxSkips in skip-budget.json ` +
`in this PR with a justification.`
);
process.exit(1);
}
if (matches.length < maxSkips) {
console.log(
`Budget can be lowered: set maxSkips to ${matches.length} in skip-budget.json to lock in the improvement.`
);
}