mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
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:
parent
8f7d0d09c3
commit
d866e99ed7
1 changed files with 11 additions and 2 deletions
13
.github/workflows/pr-triage.yml
vendored
13
.github/workflows/pr-triage.yml
vendored
|
|
@ -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}`,
|
||||
'',
|
||||
|
|
|
|||
Loading…
Reference in a new issue