ci(evals): only run evals if prompts or tools changed

This commit is contained in:
Christian Gunderman
2026-03-02 15:19:54 -08:00
parent 01927a36d1
commit 90d0ea00c5
2 changed files with 53 additions and 2 deletions

View File

@@ -0,0 +1,40 @@
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { execSync } from 'node:child_process';
function main() {
try {
// Fetch main branch to compare against. Use || true to avoid failing if already up to date or no remote.
execSync('git fetch https://github.com/google-gemini/gemini-cli.git main', {
stdio: 'ignore',
});
// Find the merge base with main
const mergeBase = execSync('git merge-base HEAD FETCH_HEAD', {
encoding: 'utf-8',
}).trim();
// Get changed files
const changedFiles = execSync(`git diff --name-only ${mergeBase} HEAD`, {
encoding: 'utf-8',
})
.split('\n')
.filter(Boolean);
const shouldRun = changedFiles.some(
(file) =>
file.startsWith('packages/core/src/prompts/') ||
file.startsWith('packages/core/src/tools/'),
);
console.log(shouldRun ? 'true' : 'false');
} catch (_error) {
// If anything fails (e.g., no git history), run evals to be safe
console.log('true');
}
}
main();