fix(ci): remove external dependency from detection script

This commit is contained in:
Alisa Novikova
2026-04-08 22:06:37 -07:00
parent 573199c58f
commit ce674a5c59
+19 -2
View File
@@ -20,7 +20,6 @@
import { execSync } from 'node:child_process';
import fs from 'node:fs';
import { minimatch } from 'minimatch';
const CORE_STEERING_PATHS = [
'packages/core/src/prompts/',
@@ -37,6 +36,24 @@ const STEERING_SIGNATURES = [
"kind: 'local'",
];
/**
* Simple dependency-free glob matcher for suites.json patterns.
* Supports: path/to/file.ts, path/to/*.ts, and path/to/**
*/
function matchesPattern(file, pattern) {
if (pattern.endsWith('/**')) {
return file.startsWith(pattern.slice(0, -3));
}
if (pattern.includes('*')) {
// Escape regex special characters except '*'
const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, '\\$&');
// Convert glob '*' to regex '[^/]*'
const regex = new RegExp('^' + escaped.replace(/\\\*/g, '[^/]*') + '$');
return regex.test(file);
}
return file === pattern;
}
function main() {
const targetBranch = process.env.GITHUB_BASE_REF || 'main';
const verbose = process.argv.includes('--verbose');
@@ -139,7 +156,7 @@ function main() {
for (const [suiteName, suite] of Object.entries(suitesConfig)) {
if (suiteName === 'allowedOverlaps' || !suite.patterns) continue;
if (suite.patterns.some((pattern) => minimatch(file, pattern))) {
if (suite.patterns.some((pattern) => matchesPattern(file, pattern))) {
affectedSuites.add(suiteName);
const isTestFile = file.endsWith('.eval.ts');
const rationale = isTestFile