mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
fix(scripts): add help to coverage gates (#3070)
Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
This commit is contained in:
co-authored by
Steven Enamakel
parent
8319b95074
commit
c0cccb14e5
@@ -0,0 +1,41 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { spawnSync } from 'node:child_process';
|
||||||
|
import { dirname, resolve } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import { test } from 'node:test';
|
||||||
|
|
||||||
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const SCRIPTS = resolve(HERE, '..');
|
||||||
|
|
||||||
|
function run(scriptName, args) {
|
||||||
|
return spawnSync(process.execPath, [resolve(SCRIPTS, scriptName), ...args], {
|
||||||
|
encoding: 'utf8',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
test('coverage helper scripts print help without running checks', () => {
|
||||||
|
for (const [scriptName, usage] of [
|
||||||
|
['check-coverage-matrix.mjs', 'Usage: node scripts/check-coverage-matrix.mjs'],
|
||||||
|
['check-domain-e2e-coverage.mjs', 'Usage: node scripts/check-domain-e2e-coverage.mjs'],
|
||||||
|
]) {
|
||||||
|
for (const helpFlag of ['--help', '-h']) {
|
||||||
|
const result = run(scriptName, [helpFlag]);
|
||||||
|
|
||||||
|
assert.equal(result.status, 0, result.stderr);
|
||||||
|
assert.equal(result.stdout.trim(), usage);
|
||||||
|
assert.equal(result.stderr, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('coverage helper scripts reject unknown arguments', () => {
|
||||||
|
for (const [scriptName, error] of [
|
||||||
|
['check-coverage-matrix.mjs', /check-coverage-matrix: unknown argument: --bogus/],
|
||||||
|
['check-domain-e2e-coverage.mjs', /check-domain-e2e-coverage: unknown argument: --bogus/],
|
||||||
|
]) {
|
||||||
|
const result = run(scriptName, ['--bogus']);
|
||||||
|
|
||||||
|
assert.equal(result.status, 2, result.stdout);
|
||||||
|
assert.match(result.stderr, error);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -7,6 +7,20 @@ import { parseMatrix, validateAgainstCatalog } from './lib/coverage-matrix-parse
|
|||||||
const here = dirname(fileURLToPath(import.meta.url));
|
const here = dirname(fileURLToPath(import.meta.url));
|
||||||
const repoRoot = join(here, '..');
|
const repoRoot = join(here, '..');
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
return 'Usage: node scripts/check-coverage-matrix.mjs';
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const arg of process.argv.slice(2)) {
|
||||||
|
if (arg === '--help' || arg === '-h') {
|
||||||
|
console.log(usage());
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
console.error(`check-coverage-matrix: unknown argument: ${arg}`);
|
||||||
|
console.error(usage());
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
let matrixMd;
|
let matrixMd;
|
||||||
let catalog;
|
let catalog;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,6 +3,21 @@ import fs from 'node:fs';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
const ROOT = process.cwd();
|
const ROOT = process.cwd();
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
return 'Usage: node scripts/check-domain-e2e-coverage.mjs';
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const arg of process.argv.slice(2)) {
|
||||||
|
if (arg === '--help' || arg === '-h') {
|
||||||
|
console.log(usage());
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
console.error(`check-domain-e2e-coverage: unknown argument: ${arg}`);
|
||||||
|
console.error(usage());
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
const rawThreshold = process.env.DOMAIN_E2E_COVERAGE_THRESHOLD ?? '90';
|
const rawThreshold = process.env.DOMAIN_E2E_COVERAGE_THRESHOLD ?? '90';
|
||||||
const THRESHOLD = Number(rawThreshold);
|
const THRESHOLD = Number(rawThreshold);
|
||||||
if (!Number.isFinite(THRESHOLD) || THRESHOLD < 0 || THRESHOLD > 100) {
|
if (!Number.isFinite(THRESHOLD) || THRESHOLD < 0 || THRESHOLD > 100) {
|
||||||
|
|||||||
Reference in New Issue
Block a user