mirror of
https://github.com/grafana/grafana.git
synced 2026-02-03 20:49:50 -05:00
* chore(git): ignore coverage summary from CI workflow * feat(script): check if files changed for a codeowner * feat(ci): clean up PR comments when break glass label applied * feat(ci): add change detection to coverage workflow * feat(ci): conditionally run coverage checks only for teams changed files * feat(ci): compare code coverage reports by codeowner * feat(ci): improve PR comment message * feat(ci): add skip warning with opted-in teams list * fix(scripts): avoid rounding errors in test coverage summaries * fix(script): fix GHA linting errors * fix(script): multiple space delimited filenames in change detection * fix(scripts): round to two decimal points of precision * feat(script): collector job to fan-in coverage comparison matrix * fix(script): display correct git SHA * fix(script): serial execution in each test suite for deterministism * fix(script): use base branch SHA, not ref for main * fix(script): ignore CI scripts written in Node.js and Jest config file * fix(script): post failure message when coverage drops * fix(script): use correct SHAs in PR comment message * fix(script): fail when any one of the coverage comparisons fail * fix(script): use the same PR comment bot for all messages * fix(script): use the same token so comments are cleared when re-run etc. * feat(script): make PR message more concise
47 lines
1.8 KiB
JavaScript
Executable file
47 lines
1.8 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
const CODEOWNERS_MANIFEST_PATH = '../codeowners-manifest/filenames-by-team.json';
|
|
|
|
/**
|
|
* Checks if any files owned by a codeowner are in the list of changed files
|
|
* @param {string} codeowner - Codeowner name (e.g., '@grafana/dataviz-squad')
|
|
* @param {string[]} changedFiles - Array of changed file paths
|
|
* @param {string} manifestPath - Path to codeowners manifest JSON file
|
|
* @returns {boolean} True if any team files are in the changed files list
|
|
*/
|
|
function isCodeownerAffected(codeowner, changedFiles, manifestPath = CODEOWNERS_MANIFEST_PATH) {
|
|
const manifest = require(manifestPath);
|
|
const teamFiles = manifest[codeowner] || [];
|
|
|
|
if (teamFiles.length === 0) {
|
|
console.warn(`Warning: No files found for codeowner "${codeowner}"`);
|
|
return false;
|
|
}
|
|
|
|
return teamFiles.some((file) => changedFiles.includes(file));
|
|
}
|
|
|
|
/**
|
|
* Runs the codeowner affected check from command line
|
|
* @param {string} codeowner - Codeowner name from CLI args
|
|
* @param {string|string[]} changedFiles - Changed file paths (space-separated string or array)
|
|
*/
|
|
function checkCodeownerAffected(codeowner, changedFiles) {
|
|
if (!codeowner) {
|
|
console.error('Usage: node check-codeowner-affected.js <codeowner> <space-separated-files>');
|
|
console.error(' or: node check-codeowner-affected.js <codeowner> <file1> <file2> ...');
|
|
process.exit(1);
|
|
}
|
|
|
|
const filesArray = typeof changedFiles === 'string' ? changedFiles.split(/\s+/).filter(Boolean) : changedFiles;
|
|
const isAffected = isCodeownerAffected(codeowner, filesArray);
|
|
console.log(isAffected ? 'true' : 'false');
|
|
}
|
|
|
|
if (require.main === module) {
|
|
const [codeowner, ...rest] = process.argv.slice(2);
|
|
const changedFiles = rest.length === 1 ? rest[0] : rest;
|
|
checkCodeownerAffected(codeowner, changedFiles);
|
|
}
|
|
|
|
module.exports = { isCodeownerAffected, checkCodeownerAffected };
|