Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Cache npm in the setup action and skip contributor fixes for bot authors (#876)

Nguyen Xuan An14cd2aaa5ad8
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml
index 0754edc0..153093f9 100644
--- a/.github/actions/setup/action.yml
+++ b/.github/actions/setup/action.yml
@@ -14,7 +14,10 @@ runs:
with:
node-version: '24'
registry-url: ${{ inputs.registry-url }}
+ # Publishing jobs (registry-url set) never restore a cache, so a poisoned cache cannot reach a release.
+ cache: ${{ inputs.registry-url == '' && 'npm' || '' }}
package-manager-cache: false
+ cache-dependency-path: package-lock.json
- run: npm install --global [email protected]
shell: bash
- run: npm ci --ignore-scripts
diff --git a/scripts/pr-metadata-check.mjs b/scripts/pr-metadata-check.mjs
index 26c73855..78b78068 100644
--- a/scripts/pr-metadata-check.mjs
+++ b/scripts/pr-metadata-check.mjs
@@ -98,11 +98,16 @@ export function isLightPullRequest(files) {
});
}
-// Owner, maintainers, collaborators and bots are never closed by the bot. The check still reports for them.
+// Dependabot and other GitHub App accounts cannot fill in a description template, so they get no contributor fixes.
+export function isBotAuthor(pr) {
+ return (pr.author ?? '').toLowerCase().endsWith('[bot]');
+}
+
+// Owner, maintainers, collaborators and bots are never closed by the bot.
export function isAutoCloseExempt(pr) {
const author = (pr.author ?? '').toLowerCase();
return author === OWNER_LOGIN
- || author.endsWith('[bot]')
+ || isBotAuthor(pr)
|| TRUSTED_ASSOCIATIONS.has(pr.authorAssociation ?? '');
}
@@ -190,7 +195,7 @@ function maintainerTodosFor(pr, files, contributorFixes) {
export function checkPullRequest({ pr, files }) {
const labels = pr.labels ?? [];
const light = isLightPullRequest(files);
- const contributorFixes = contributorFixesFor(pr, files, light);
+ const contributorFixes = isBotAuthor(pr) ? [] : contributorFixesFor(pr, files, light);
const maintainerTodos = maintainerTodosFor(pr, files, contributorFixes);
const addLabels = [];
const removeLabels = [];
diff --git a/tests/pr-metadata-check.test.js b/tests/pr-metadata-check.test.js
index 7ea7a563..39976f7c 100644
--- a/tests/pr-metadata-check.test.js
+++ b/tests/pr-metadata-check.test.js
@@ -194,6 +194,22 @@ test('status:needs-author follows the contributor fixes, except for exempt autho
assert.ok(!owner.addLabels.includes('status:needs-author'));
});
+test('a bot author such as Dependabot gets no contributor fixes and no author label', () => {
+ const dependabotPullRequest = pullRequest({
+ author: 'dependabot[bot]',
+ authorAssociation: 'NONE',
+ title: 'Bump actions/checkout from 6 to 7',
+ body: 'Bumps actions/checkout.',
+ labels: [],
+ milestone: null,
+ });
+ const files = [file('src/scene.js')];
+ const result = checkPullRequest({ pr: dependabotPullRequest, files });
+ assert.deepEqual(result.contributorFixes, []);
+ assert.ok(!result.addLabels.includes('status:needs-author'));
+ assert.ok(fixIds({ pr: pullRequest({ author: 'someone', body: 'Bumps.', labels: [] }), files }).length > 0);
+});
+
test('owner, members, collaborators and bots are exempt from auto close', () => {
assert.ok(isAutoCloseExempt({ author: 'anxuanng', authorAssociation: 'NONE' }));
assert.ok(isAutoCloseExempt({ author: 'AnXuanNg', authorAssociation: 'NONE' }));