ci(scope): narrow #494 invariant — changed tests join windows lane, not full matrix
full_matrix fired on 15/15 sampled PRs because any tests/** change forced it, costing ~25 runner-minutes each. A changed test file now always joins the scoped windows lane (covering the #482 OS-specific failure class per-file) and still runs on ubuntu 22/24 via targeted_tests; the residual macOS / windows-node-22 cross-product is covered on every push to next. Also narrows WINDOWS_HINTS from 6 substrings (102/633 files, a ~10-minute scoped lane) to windows/win32/shell/path — the dropped hints (workflow, install, hook) are either platform-independent lint tests or already covered by fullMatrix rules. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -169,11 +169,11 @@ const RULES = [
|
||||
path.includes('prompt-injection-scan') ||
|
||||
path.startsWith('tests/fixtures/adversarial/security/'),
|
||||
tests: [
|
||||
'tests/secret-scan-lint.test.cjs',
|
||||
'tests/prompt-injection-scan.test.cjs',
|
||||
'tests/security-prompt-injection.test.cjs',
|
||||
'tests/read-injection-scanner.test.cjs',
|
||||
'tests/security-scan.test.cjs',
|
||||
'tests/secret-scan-lint.security.test.cjs',
|
||||
'tests/prompt-injection-scan.security.test.cjs',
|
||||
'tests/security-prompt-injection.security.test.cjs',
|
||||
'tests/read-injection-scanner.security.test.cjs',
|
||||
'tests/security-scan.security.test.cjs',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -308,7 +308,13 @@ function addAll(set, values) {
|
||||
for (const value of values) set.add(value);
|
||||
}
|
||||
|
||||
const WINDOWS_HINTS = ['windows', 'path', 'shell', 'workflow', 'install', 'hook'];
|
||||
// Windows-sensitive filename hints — deliberately narrow. 'workflow',
|
||||
// 'install', and 'hook' were dropped from this list: workflow-lint tests are
|
||||
// platform-independent YAML/policy checks, and the installer/hooks RULES set
|
||||
// fullMatrix=true, so the full Windows lane already runs when those paths
|
||||
// change. The old six-hint list pulled 102 of ~633 test files into the scoped
|
||||
// windows lane, turning it into a ~10-minute job on every PR.
|
||||
const WINDOWS_HINTS = ['windows', 'win32', 'shell', 'path'];
|
||||
const isWindowsHint = s => WINDOWS_HINTS.some(k => s.toLowerCase().includes(k));
|
||||
|
||||
function classify(files) {
|
||||
@@ -343,10 +349,15 @@ function classify(files) {
|
||||
|
||||
if (file.startsWith('tests/') && file.endsWith('.test.cjs')) {
|
||||
targeted.add(file);
|
||||
fullMatrix = true;
|
||||
if (isWindowsHint(file)) {
|
||||
windows.add(file);
|
||||
}
|
||||
// #494 invariant, narrowed: a changed test must still be exercised on
|
||||
// the divergent OS before merge, but at per-file cost — it ALWAYS joins
|
||||
// the scoped windows lane instead of triggering the three full parity
|
||||
// lanes. (full_matrix fired on 15/15 sampled PRs because test-driven
|
||||
// PRs always touch tests/, costing ~25 runner-minutes each.) Changed
|
||||
// tests already run on ubuntu-22 and ubuntu-24 via targeted_tests; the
|
||||
// residual macOS / windows-node-22 cross-product is covered by the full
|
||||
// matrix on every push to next.
|
||||
windows.add(file);
|
||||
}
|
||||
|
||||
for (const rule of RULES) {
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { spawnSync } = require('child_process');
|
||||
const { ExitError, runMain } = require('./lib/cli-exit.cjs');
|
||||
|
||||
const CROSS_PLATFORM_TEST_REASON = Object.freeze({
|
||||
PASS: 'pass',
|
||||
TEST_FAILURE: 'test_failure',
|
||||
INFRA_FAILURE: 'infra_failure',
|
||||
UNKNOWN_FAILURE: 'unknown_failure',
|
||||
});
|
||||
|
||||
function classify(exitCode, output) {
|
||||
if (exitCode === 0) return CROSS_PLATFORM_TEST_REASON.PASS;
|
||||
if (exitCode === 2 || /infrastructure failure|worktree\.Construct/i.test(output)) {
|
||||
return CROSS_PLATFORM_TEST_REASON.INFRA_FAILURE;
|
||||
}
|
||||
if (/\bFAIL\b|\d+\s+failures?\)/i.test(output)) {
|
||||
return CROSS_PLATFORM_TEST_REASON.TEST_FAILURE;
|
||||
}
|
||||
return CROSS_PLATFORM_TEST_REASON.UNKNOWN_FAILURE;
|
||||
}
|
||||
|
||||
function runCrossPlatformTests(options = {}, deps = {}) {
|
||||
const {
|
||||
base = 'next',
|
||||
head = 'HEAD',
|
||||
source = '.',
|
||||
targets = 'linux,macos',
|
||||
cwd = process.cwd(),
|
||||
} = options;
|
||||
const runner = deps.spawnSync || spawnSync;
|
||||
|
||||
const args = ['--targets', targets, '--base', base, '--head', head, '--source', source];
|
||||
const result = runner('gsd-test', args, { cwd, encoding: 'utf8' });
|
||||
|
||||
const stdout = result.stdout || '';
|
||||
const stderr = result.stderr || '';
|
||||
const output = `${stdout}\n${stderr}`;
|
||||
const exitCode = Number(result.status ?? 1);
|
||||
const reason = classify(exitCode, output);
|
||||
|
||||
return {
|
||||
ok: exitCode === 0,
|
||||
reason,
|
||||
exitCode,
|
||||
command: ['gsd-test', ...args].join(' '),
|
||||
stdout,
|
||||
stderr,
|
||||
};
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
function main() {
|
||||
const result = runCrossPlatformTests();
|
||||
const line = `[cross-platform-tests] reason=${result.reason} exit=${result.exitCode}`;
|
||||
if (result.ok) {
|
||||
process.stdout.write(`${line}\n`);
|
||||
return 0;
|
||||
}
|
||||
process.stderr.write(`${line}\n`);
|
||||
throw new ExitError(result.exitCode);
|
||||
}
|
||||
runMain(main);
|
||||
}
|
||||
|
||||
module.exports = { CROSS_PLATFORM_TEST_REASON, runCrossPlatformTests };
|
||||
Reference in New Issue
Block a user