chore: don't include test files in line count changes for pr tiering (#2083)

Previously test files contributed to the line count of PRs, possibly elevating their tier unintentionally.
This commit is contained in:
Tom Alexander 2026-04-09 11:47:08 -04:00 committed by GitHub
parent 8f7d0d09c3
commit d866e99ed7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -138,7 +138,16 @@ jobs:
{ owner, repo, pull_number: prNumber, per_page: 100 }
);
const files = filesRes.map(f => f.filename);
const linesChanged = filesRes.reduce((sum, f) => sum + f.additions + f.deletions, 0);
const TEST_FILE_PATTERNS = [
/\/__tests__\//,
/\.test\.[jt]sx?$/,
/\.spec\.[jt]sx?$/,
/^packages\/app\/tests\//,
];
const isTestFile = f => TEST_FILE_PATTERNS.some(p => p.test(f));
const nonTestFiles = filesRes.filter(f => !isTestFile(f.filename));
const testLines = filesRes.filter(f => isTestFile(f.filename)).reduce((sum, f) => sum + f.additions + f.deletions, 0);
const linesChanged = nonTestFiles.reduce((sum, f) => sum + f.additions + f.deletions, 0);
// Fetch PR metadata
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: prNumber });
@ -250,7 +259,7 @@ jobs:
`<details><summary>Stats</summary>`,
'',
`- Files changed: ${files.length}`,
`- Lines changed: ${linesChanged}`,
`- Lines changed: ${linesChanged}${testLines > 0 ? ` (+ ${testLines} in test files, excluded from tier calculation)` : ''}`,
`- Branch: \`${branchName}\``,
`- Author: ${author}`,
'',