mirror of
https://github.com/actions/labeler
synced 2026-09-04 19:15:10 +02:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8dd2d9be0 | ||
|
|
53affe8ca4 | ||
|
|
f612d9ad18 | ||
|
|
f27b608878 |
@@ -12,6 +12,7 @@ allowed:
|
||||
|
||||
reviewed:
|
||||
npm:
|
||||
- "@actions/http-client"
|
||||
- balanced-match
|
||||
- brace-expansion
|
||||
- minimatch
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/core"
|
||||
version: 1.11.1
|
||||
version: 2.0.3
|
||||
type: npm
|
||||
summary: Actions core lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||
|
||||
Generated
+2
-2
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/exec"
|
||||
version: 1.1.1
|
||||
version: 2.0.0
|
||||
type: npm
|
||||
summary: Actions exec lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/exec
|
||||
@@ -17,4 +17,4 @@ licenses:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
notices: []
|
||||
|
||||
Generated
+1
-1
@@ -4,7 +4,7 @@ version: 2.2.3
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
|
||||
license: mit
|
||||
license: other
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: "@actions/http-client"
|
||||
version: 3.0.2
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
|
||||
license: other
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
Generated
+2
-2
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/io"
|
||||
version: 1.1.3
|
||||
version: 2.0.0
|
||||
type: npm
|
||||
summary: Actions io lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/io
|
||||
@@ -17,4 +17,4 @@ licenses:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
notices: []
|
||||
|
||||
Generated
-30
@@ -1,30 +0,0 @@
|
||||
---
|
||||
name: "@fastify/busboy"
|
||||
version: 2.0.0
|
||||
type: npm
|
||||
summary: A streaming parser for HTML form data for node.js
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |-
|
||||
Copyright Brian White. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
notices: []
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: brace-expansion
|
||||
version: 5.0.4
|
||||
version: 5.0.7
|
||||
type: npm
|
||||
summary: Brace expansion as known from sh/bash
|
||||
homepage:
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: js-yaml
|
||||
version: 4.1.1
|
||||
version: 4.2.0
|
||||
type: npm
|
||||
summary: YAML 1.2 parser and serializer
|
||||
homepage:
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: minimatch
|
||||
version: 10.2.3
|
||||
version: 10.2.5
|
||||
type: npm
|
||||
summary: a glob matcher in javascript
|
||||
homepage:
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: undici
|
||||
version: 5.29.0
|
||||
version: 6.27.0
|
||||
type: npm
|
||||
summary: An HTTP/1.1 client, written from scratch for Node.js
|
||||
homepage: https://undici.nodejs.org
|
||||
|
||||
@@ -441,6 +441,197 @@ describe('run', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('(with pr-number: non-numeric string) warns and makes no API call', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['abc']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
"'abc' is not a valid pull request number"
|
||||
);
|
||||
expect(getPullMock).not.toHaveBeenCalled();
|
||||
expect(setLabelsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('(with pr-number: negative number) warns and makes no API call', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['-1']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
"'-1' is not a valid pull request number"
|
||||
);
|
||||
expect(getPullMock).not.toHaveBeenCalled();
|
||||
expect(setLabelsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('(with pr-number: zero) warns and makes no API call', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['0']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
"'0' is not a valid pull request number"
|
||||
);
|
||||
expect(getPullMock).not.toHaveBeenCalled();
|
||||
expect(setLabelsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('(with pr-number: number with internal space) warns and makes no API call', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['10 4']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
"'10 4' is not a valid pull request number"
|
||||
);
|
||||
expect(getPullMock).not.toHaveBeenCalled();
|
||||
expect(setLabelsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('(with pr-number: number with trailing non-numeric chars) warns and makes no API call', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['104abc']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
"'104abc' is not a valid pull request number"
|
||||
);
|
||||
expect(getPullMock).not.toHaveBeenCalled();
|
||||
expect(setLabelsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('(with pr-number: valid number with surrounding whitespace) trims and processes correctly', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': [' 104 ']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
getPullMock.mockResolvedValue(<any>{data: {labels: []}});
|
||||
|
||||
await run();
|
||||
|
||||
expect(getPullMock).toHaveBeenCalled();
|
||||
expect(coreWarningMock).not.toHaveBeenCalledWith(
|
||||
expect.stringContaining('is not a valid pull request number')
|
||||
);
|
||||
});
|
||||
|
||||
it('(with pr-number: string with carriage return) sanitizes CR as \\x0d in warning', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['abc\rdef']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
"'abc\\x0ddef' is not a valid pull request number (non-printable characters were escaped as \\xNN)"
|
||||
);
|
||||
expect(getPullMock).not.toHaveBeenCalled();
|
||||
expect(setLabelsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('(with pr-number: string with tab) sanitizes tab as \\x09 in warning', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['abc\tdef']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
"'abc\\x09def' is not a valid pull request number (non-printable characters were escaped as \\xNN)"
|
||||
);
|
||||
expect(getPullMock).not.toHaveBeenCalled();
|
||||
expect(setLabelsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('(with pr-number: string with ANSI escape sequence) sanitizes ESC byte as \\x1b in warning', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['abc\x1b[31mINJECTED\x1b[0m']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
"'abc\\x1b[31mINJECTED\\x1b[0m' is not a valid pull request number (non-printable characters were escaped as \\xNN)"
|
||||
);
|
||||
expect(getPullMock).not.toHaveBeenCalled();
|
||||
expect(setLabelsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('(with pr-number: mix of valid and invalid) processes valid, skips invalid with warning', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['104', 'abc']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
|
||||
getPullMock.mockResolvedValue(<any>{
|
||||
data: {labels: []}
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
"'abc' is not a valid pull request number"
|
||||
);
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(setLabelsMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 104,
|
||||
labels: ['touched-a-pdf-file']
|
||||
});
|
||||
});
|
||||
|
||||
it('does not add labels to PRs that have no changed files', async () => {
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles();
|
||||
|
||||
Vendored
+18529
-13392
File diff suppressed because one or more lines are too long
Generated
+506
-525
File diff suppressed because it is too large
Load Diff
+11
-9
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "labeler",
|
||||
"version": "6.0.0",
|
||||
"version": "6.2.0",
|
||||
"description": "Labels pull requests by files altered",
|
||||
"main": "lib/main.js",
|
||||
"engines": {
|
||||
"engines": {
|
||||
"node": ">=24"
|
||||
},
|
||||
"scripts": {
|
||||
@@ -27,12 +27,15 @@
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@actions/core": "^2.0.3",
|
||||
"@actions/github": "^6.0.1",
|
||||
"@octokit/plugin-retry": "^6.0.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"js-yaml": "^4.2.0",
|
||||
"lodash.isequal": "^4.5.0",
|
||||
"minimatch": "^10.2.3"
|
||||
"minimatch": "^10.2.5"
|
||||
},
|
||||
"overrides": {
|
||||
"undici": "6.27.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
@@ -40,8 +43,8 @@
|
||||
"@types/lodash.isequal": "^4.5.8",
|
||||
"@types/minimatch": "^5.1.2",
|
||||
"@types/node": "^24.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.61.1",
|
||||
"@typescript-eslint/parser": "^8.59.0",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
@@ -51,6 +54,5 @@
|
||||
"prettier": "^3.4.2",
|
||||
"ts-jest": "^29.2.5",
|
||||
"typescript": "^5.7.3"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function* getPullRequests(
|
||||
pull_number: prNumber
|
||||
});
|
||||
prData = result.data;
|
||||
} catch (error: any) {
|
||||
} catch {
|
||||
core.warning(`Could not find pull request #${prNumber}, skipping`);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,13 @@ import * as github from '@actions/github';
|
||||
const getPrNumberFromContext = () =>
|
||||
github.context.payload.pull_request?.number;
|
||||
|
||||
const sanitizeForWarning = (value: string): string => {
|
||||
return value.replace(
|
||||
/[\x00-\x1F\x7F-\x9F]/g,
|
||||
c => `\\x${c.charCodeAt(0).toString(16).padStart(2, '0')}`
|
||||
);
|
||||
};
|
||||
|
||||
export const getPrNumbers = (): number[] => {
|
||||
const prInput = core.getMultilineInput('pr-number');
|
||||
|
||||
@@ -14,10 +21,16 @@ export const getPrNumbers = (): number[] => {
|
||||
const result: number[] = [];
|
||||
|
||||
for (const line of prInput) {
|
||||
const prNumber = parseInt(line, 10);
|
||||
const trimmed = line.trim();
|
||||
const prNumber = parseInt(trimmed, 10);
|
||||
|
||||
if (isNaN(prNumber) && prNumber <= 0) {
|
||||
core.warning(`'${prNumber}' is not a valid pull request number`);
|
||||
if (isNaN(prNumber) || prNumber <= 0 || String(prNumber) !== trimmed) {
|
||||
const sanitized = sanitizeForWarning(line);
|
||||
const hint =
|
||||
sanitized !== line
|
||||
? ' (non-printable characters were escaped as \\xNN)'
|
||||
: '';
|
||||
core.warning(`'${sanitized}' is not a valid pull request number${hint}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user