Skip to content

Commit f63c87a

Browse files
committed
ci(pr): cap metadata file scans for large imports
Refs #1
1 parent e40ae58 commit f63c87a

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/pr-metadata.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,19 @@ jobs:
3232
assignees.push(pr.user.login);
3333
}
3434
35-
const files = await github.paginate(github.rest.pulls.listFiles, {
35+
const FILE_SCAN_LIMIT = 500;
36+
const files = [];
37+
const fileIterator = github.paginate.iterator(github.rest.pulls.listFiles, {
3638
owner,
3739
repo,
3840
pull_number: issue_number,
3941
per_page: 100,
4042
});
43+
for await (const { data } of fileIterator) {
44+
files.push(...data);
45+
if (files.length >= FILE_SCAN_LIMIT) break;
46+
}
47+
const filesWereCapped = (pr.changed_files || files.length) > files.length;
4148
4249
const labels = new Set();
4350
const title = pr.title.toLowerCase();
@@ -101,7 +108,7 @@ jobs:
101108
break;
102109
}
103110
104-
const changedLines = files.reduce((sum, file) => sum + file.additions + file.deletions, 0);
111+
const changedLines = (pr.additions || 0) + (pr.deletions || 0);
105112
let priority = 'Medium';
106113
if (labels.has('data') && (files.length >= 25 || changedLines >= 1000)) {
107114
priority = 'High';
@@ -190,8 +197,8 @@ jobs:
190197
`- Author: @${pr.user.login}`,
191198
`- Labels: ${labelText}`,
192199
`- Priority: ${priority}`,
193-
`- Files changed: ${files.length}`,
194-
`- Lines changed: +${files.reduce((sum, file) => sum + file.additions, 0)} / -${files.reduce((sum, file) => sum + file.deletions, 0)}`,
200+
`- Files changed: ${pr.changed_files || files.length}${filesWereCapped ? ` (sampled ${files.length} for metadata)` : ''}`,
201+
`- Lines changed: +${pr.additions || files.reduce((sum, file) => sum + file.additions, 0)} / -${pr.deletions || files.reduce((sum, file) => sum + file.deletions, 0)}`,
195202
'',
196203
'### Changed Data',
197204
'',
@@ -208,6 +215,7 @@ jobs:
208215
'### Notes',
209216
'',
210217
'- This is an automatic tracking comment for the long-running issue.',
218+
...(filesWereCapped ? ['- Large PR detected: changed-area tables are based on the first sampled files, while total file/line counts come from GitHub PR metadata.'] : []),
211219
'- PR validation details are posted on the PR by TechEngineBot.',
212220
'- The tracker issue remains open even when the PR uses `Closes #...` for GitHub Development linking.',
213221
].join('\n');

0 commit comments

Comments
 (0)