mirror of
https://github.com/actions/labeler.git
synced 2025-12-12 04:27:34 +00:00
Compare commits
123 Commits
v4.3.0
...
v5.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4eefdc659 | ||
|
|
4f052778de | ||
|
|
26342ba349 | ||
|
|
e1fcf6fe5b | ||
|
|
3352df1f2b | ||
|
|
57d34076e0 | ||
|
|
a256a58edf | ||
|
|
a5bed11d4d | ||
|
|
4ac17648a4 | ||
|
|
34a5bf6e83 | ||
|
|
09645fd40d | ||
|
|
51cc5e079c | ||
|
|
9cfddd0144 | ||
|
|
3aa0d436e5 | ||
|
|
9488def29a | ||
|
|
11812c37f6 | ||
|
|
68a2598016 | ||
|
|
13e75b4361 | ||
|
|
2a3422a64e | ||
|
|
c1b0ca76ee | ||
|
|
2637d23bca | ||
|
|
d4d4a104a2 | ||
|
|
7f169bc0f2 | ||
|
|
2f1dfd1ef0 | ||
|
|
b1a2f85ed8 | ||
|
|
67604ee822 | ||
|
|
4be192c7d6 | ||
|
|
3ddce51a65 | ||
|
|
938f9c9893 | ||
|
|
210043eed1 | ||
|
|
fa7f98c785 | ||
|
|
29382eb4ff | ||
|
|
0b2cfb01d7 | ||
|
|
62f22bdebe | ||
|
|
ef6ab1b64a | ||
|
|
5ac9519cbf | ||
|
|
4554c0d1af | ||
|
|
49676461cb | ||
|
|
432b275f71 | ||
|
|
3bec9227d1 | ||
|
|
a9e07ce8ff | ||
|
|
e51b118725 | ||
|
|
5d0a66ed59 | ||
|
|
9bfc9998ab | ||
|
|
8e6367ddee | ||
|
|
1c9c27e128 | ||
|
|
b25e3a8c27 | ||
|
|
d31255f7be | ||
|
|
92990c0c57 | ||
|
|
d0d3628020 | ||
|
|
cc1e02580b | ||
|
|
64ce5e9235 | ||
|
|
7741e57c6a | ||
|
|
65b7640e45 | ||
|
|
e9a1777eb0 | ||
|
|
17694aa238 | ||
|
|
c31ee1fd86 | ||
|
|
3af9a47a26 | ||
|
|
a988f4eb9d | ||
|
|
ef108a9d83 | ||
|
|
1ce9b356f6 | ||
|
|
9f259ee115 | ||
|
|
c08f5faa12 | ||
|
|
51b763cbf2 | ||
|
|
e939550344 | ||
|
|
e4486e9ed9 | ||
|
|
fc5eb711b0 | ||
|
|
3eec5d8ccc | ||
|
|
90ef37079a | ||
|
|
f40b38734d | ||
|
|
84e83a9b19 | ||
|
|
5e6bdf6d89 | ||
|
|
394a01bde3 | ||
|
|
2a5bc55cbf | ||
|
|
2e10ffb6ec | ||
|
|
e5b1bddf5e | ||
|
|
8943ca20c9 | ||
|
|
56347d54a1 | ||
|
|
da83a1845f | ||
|
|
ed31b27f2e | ||
|
|
09f085373a | ||
|
|
0eb9d49330 | ||
|
|
b071d82cb8 | ||
|
|
7d175313b7 | ||
|
|
969899da68 | ||
|
|
7a5c525049 | ||
|
|
922ffdf5ad | ||
|
|
231de6bc24 | ||
|
|
2daf35ae4b | ||
|
|
0b6e68d75a | ||
|
|
cd3a8df80d | ||
|
|
2343710777 | ||
|
|
f2b2513f41 | ||
|
|
8c59eccb9d | ||
|
|
7b1327b4c4 | ||
|
|
c54c5a2057 | ||
|
|
7f8d8e472d | ||
|
|
4c74e84461 | ||
|
|
0861fa5acc | ||
|
|
0ad789cf22 | ||
|
|
6e276063fe | ||
|
|
818399d10f | ||
|
|
71fc664414 | ||
|
|
7aadc17f94 | ||
|
|
89f6b77325 | ||
|
|
2246b667c6 | ||
|
|
ab49f7a2bd | ||
|
|
2d63815c83 | ||
|
|
76242143df | ||
|
|
27a1d89941 | ||
|
|
79c0cc7c0b | ||
|
|
d9ed3e87f6 | ||
|
|
2ced1f3255 | ||
|
|
cb5f4480b2 | ||
|
|
8aa7614bc1 | ||
|
|
827e1186a2 | ||
|
|
765934f274 | ||
|
|
bce88a9ea3 | ||
|
|
a01b9aebb2 | ||
|
|
ee0e0eb513 | ||
|
|
6c50d09410 | ||
|
|
ad73546cad | ||
|
|
2bf42e445d |
@@ -7,7 +7,7 @@ module.exports = {
|
||||
'eslint-config-prettier'
|
||||
],
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
|
||||
plugins: ['@typescript-eslint', 'eslint-plugin-jest'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-require-imports': 'error',
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
@@ -28,8 +28,7 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
'no-control-regex': 'off',
|
||||
'no-constant-condition': ['error', {checkLoops: false}],
|
||||
'node/no-extraneous-import': 'error'
|
||||
'no-constant-condition': ['error', {checkLoops: false}]
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
.DS_Store
|
||||
node_modules/
|
||||
lib/
|
||||
.idea
|
||||
|
||||
32
.licenses/npm/@jest/schemas.dep.yml
generated
32
.licenses/npm/@jest/schemas.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: "@jest/schemas"
|
||||
version: 29.6.0
|
||||
type: npm
|
||||
summary:
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
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: []
|
||||
32
.licenses/npm/@jest/types.dep.yml
generated
32
.licenses/npm/@jest/types.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: "@jest/types"
|
||||
version: 29.6.1
|
||||
type: npm
|
||||
summary:
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
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: []
|
||||
20
.licenses/npm/@octokit/openapi-types-18.0.0.dep.yml
generated
20
.licenses/npm/@octokit/openapi-types-18.0.0.dep.yml
generated
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: "@octokit/openapi-types"
|
||||
version: 18.0.0
|
||||
type: npm
|
||||
summary: Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |-
|
||||
Copyright 2020 Gregor Martynus
|
||||
|
||||
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.
|
||||
- sources: README.md
|
||||
text: "[MIT](LICENSE)"
|
||||
notices: []
|
||||
34
.licenses/npm/@octokit/plugin-retry.dep.yml
generated
34
.licenses/npm/@octokit/plugin-retry.dep.yml
generated
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: "@octokit/plugin-retry"
|
||||
version: 5.0.5
|
||||
type: npm
|
||||
summary: Automatic retry plugin for octokit
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Octokit contributors
|
||||
|
||||
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.
|
||||
- sources: README.md
|
||||
text: "[MIT](LICENSE)"
|
||||
notices: []
|
||||
34
.licenses/npm/@octokit/request-error-4.0.2.dep.yml
generated
34
.licenses/npm/@octokit/request-error-4.0.2.dep.yml
generated
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: "@octokit/request-error"
|
||||
version: 4.0.2
|
||||
type: npm
|
||||
summary: Error class for Octokit request errors
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
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.
|
||||
- sources: README.md
|
||||
text: "[MIT](LICENSE)"
|
||||
notices: []
|
||||
20
.licenses/npm/@octokit/types-10.0.0.dep.yml
generated
20
.licenses/npm/@octokit/types-10.0.0.dep.yml
generated
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: "@octokit/types"
|
||||
version: 10.0.0
|
||||
type: npm
|
||||
summary: Shared TypeScript definitions for Octokit projects
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License Copyright (c) 2019 Octokit contributors
|
||||
|
||||
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 (including the next paragraph) 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.
|
||||
- sources: README.md
|
||||
text: "[MIT](LICENSE)"
|
||||
notices: []
|
||||
26
.licenses/npm/@sinclair/typebox.dep.yml
generated
26
.licenses/npm/@sinclair/typebox.dep.yml
generated
@@ -1,26 +0,0 @@
|
||||
---
|
||||
name: "@sinclair/typebox"
|
||||
version: 0.27.8
|
||||
type: npm
|
||||
summary: JSONSchema Type Builder with Static Type Resolution for TypeScript
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: license
|
||||
text: "TypeBox: JSON Schema Type Builder with Static Type Resolution for TypeScript
|
||||
\n\nThe MIT License (MIT)\n\nCopyright (c) 2017-2023 Haydn Paterson (sinclair)
|
||||
<haydn.developer@gmail.com>\n\nPermission is hereby granted, free of charge, to
|
||||
any person obtaining a copy\nof this software and associated documentation files
|
||||
(the \"Software\"), to deal\nin the Software without restriction, including without
|
||||
limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell\ncopies of the Software, and to permit persons to whom the Software
|
||||
is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright
|
||||
notice and this permission notice shall be included in\nall copies or substantial
|
||||
portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY
|
||||
OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
||||
OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN\nTHE SOFTWARE."
|
||||
notices: []
|
||||
32
.licenses/npm/@types/istanbul-lib-coverage.dep.yml
generated
32
.licenses/npm/@types/istanbul-lib-coverage.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: "@types/istanbul-lib-coverage"
|
||||
version: 2.0.4
|
||||
type: npm
|
||||
summary: TypeScript definitions for istanbul-lib-coverage
|
||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-coverage
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |2
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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: []
|
||||
32
.licenses/npm/@types/istanbul-lib-report.dep.yml
generated
32
.licenses/npm/@types/istanbul-lib-report.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: "@types/istanbul-lib-report"
|
||||
version: 3.0.0
|
||||
type: npm
|
||||
summary: TypeScript definitions for istanbul-lib-report
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |2
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. 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: []
|
||||
32
.licenses/npm/@types/istanbul-reports.dep.yml
generated
32
.licenses/npm/@types/istanbul-reports.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: "@types/istanbul-reports"
|
||||
version: 3.0.1
|
||||
type: npm
|
||||
summary: TypeScript definitions for istanbul-reports
|
||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-reports
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |2
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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: []
|
||||
32
.licenses/npm/@types/node.dep.yml
generated
32
.licenses/npm/@types/node.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: "@types/node"
|
||||
version: 16.18.11
|
||||
type: npm
|
||||
summary: TypeScript definitions for Node.js
|
||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |2
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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: []
|
||||
32
.licenses/npm/@types/yargs-parser.dep.yml
generated
32
.licenses/npm/@types/yargs-parser.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: "@types/yargs-parser"
|
||||
version: 21.0.0
|
||||
type: npm
|
||||
summary: TypeScript definitions for yargs-parser
|
||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs-parser
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |2
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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: []
|
||||
32
.licenses/npm/@types/yargs.dep.yml
generated
32
.licenses/npm/@types/yargs.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: "@types/yargs"
|
||||
version: 17.0.24
|
||||
type: npm
|
||||
summary: TypeScript definitions for yargs
|
||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |2
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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: []
|
||||
20
.licenses/npm/ansi-styles-4.3.0.dep.yml
generated
20
.licenses/npm/ansi-styles-4.3.0.dep.yml
generated
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: ansi-styles
|
||||
version: 4.3.0
|
||||
type: npm
|
||||
summary: ANSI escape codes for styling strings in the terminal
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: license
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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: []
|
||||
20
.licenses/npm/ansi-styles-5.2.0.dep.yml
generated
20
.licenses/npm/ansi-styles-5.2.0.dep.yml
generated
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: ansi-styles
|
||||
version: 5.2.0
|
||||
type: npm
|
||||
summary: ANSI escape codes for styling strings in the terminal
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: license
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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: []
|
||||
31
.licenses/npm/bottleneck.dep.yml
generated
31
.licenses/npm/bottleneck.dep.yml
generated
@@ -1,31 +0,0 @@
|
||||
---
|
||||
name: bottleneck
|
||||
version: 2.19.5
|
||||
type: npm
|
||||
summary: Distributed task scheduler and rate limiter
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Simon Grondin
|
||||
|
||||
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: []
|
||||
20
.licenses/npm/chalk.dep.yml
generated
20
.licenses/npm/chalk.dep.yml
generated
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: chalk
|
||||
version: 4.1.2
|
||||
type: npm
|
||||
summary: Terminal string styling done right
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: license
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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: []
|
||||
34
.licenses/npm/ci-info.dep.yml
generated
34
.licenses/npm/ci-info.dep.yml
generated
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: ci-info
|
||||
version: 3.7.1
|
||||
type: npm
|
||||
summary: Get details about the current Continuous Integration environment
|
||||
homepage: https://github.com/watson/ci-info
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016-2023 Thomas Watson Steen
|
||||
|
||||
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.
|
||||
- sources: README.md
|
||||
text: "[MIT](LICENSE)"
|
||||
notices: []
|
||||
35
.licenses/npm/color-convert.dep.yml
generated
35
.licenses/npm/color-convert.dep.yml
generated
@@ -1,35 +0,0 @@
|
||||
---
|
||||
name: color-convert
|
||||
version: 2.0.1
|
||||
type: npm
|
||||
summary: Plain color conversion functions
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |+
|
||||
Copyright (c) 2011-2016 Heather Arthur <fayearthur@gmail.com>
|
||||
|
||||
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.
|
||||
|
||||
- sources: README.md
|
||||
text: Copyright © 2011-2016, Heather Arthur and Josh Junon. Licensed under
|
||||
the [MIT License](LICENSE).
|
||||
notices: []
|
||||
19
.licenses/npm/color-name.dep.yml
generated
19
.licenses/npm/color-name.dep.yml
generated
@@ -1,19 +0,0 @@
|
||||
---
|
||||
name: color-name
|
||||
version: 1.1.4
|
||||
type: npm
|
||||
summary: A list of color names and its values
|
||||
homepage: https://github.com/colorjs/color-name
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |-
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2015 Dmitry Ivanov
|
||||
|
||||
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: []
|
||||
26
.licenses/npm/graceful-fs.dep.yml
generated
26
.licenses/npm/graceful-fs.dep.yml
generated
@@ -1,26 +0,0 @@
|
||||
---
|
||||
name: graceful-fs
|
||||
version: 4.2.10
|
||||
type: npm
|
||||
summary: A drop-in replacement for fs, making various improvements.
|
||||
homepage:
|
||||
license: isc
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The ISC License
|
||||
|
||||
Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
notices: []
|
||||
22
.licenses/npm/has-flag.dep.yml
generated
22
.licenses/npm/has-flag.dep.yml
generated
@@ -1,22 +0,0 @@
|
||||
---
|
||||
name: has-flag
|
||||
version: 4.0.0
|
||||
type: npm
|
||||
summary: Check if argv has a specific flag
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: license
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
- sources: readme.md
|
||||
text: MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
notices: []
|
||||
34
.licenses/npm/jest-each.dep.yml
generated
34
.licenses/npm/jest-each.dep.yml
generated
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: jest-each
|
||||
version: 29.6.1
|
||||
type: npm
|
||||
summary: Parameterised tests for Jest
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
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.
|
||||
- sources: README.md
|
||||
text: MIT
|
||||
notices: []
|
||||
32
.licenses/npm/jest-get-type.dep.yml
generated
32
.licenses/npm/jest-get-type.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: jest-get-type
|
||||
version: 29.4.3
|
||||
type: npm
|
||||
summary: A utility function to get the type of a value
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
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: []
|
||||
32
.licenses/npm/jest-util.dep.yml
generated
32
.licenses/npm/jest-util.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: jest-util
|
||||
version: 29.6.1
|
||||
type: npm
|
||||
summary:
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
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: []
|
||||
38
.licenses/npm/picomatch.dep.yml
generated
38
.licenses/npm/picomatch.dep.yml
generated
@@ -1,38 +0,0 @@
|
||||
---
|
||||
name: picomatch
|
||||
version: 2.3.1
|
||||
type: npm
|
||||
summary: Blazing fast and accurate glob matcher written in JavaScript, with no dependencies
|
||||
and full support for standard and extended Bash glob features, including braces,
|
||||
extglobs, POSIX brackets, and regular expressions.
|
||||
homepage: https://github.com/micromatch/picomatch
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017-present, Jon Schlinkert.
|
||||
|
||||
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.
|
||||
- sources: README.md
|
||||
text: |-
|
||||
Copyright © 2017-present, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
notices: []
|
||||
32
.licenses/npm/pretty-format.dep.yml
generated
32
.licenses/npm/pretty-format.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: pretty-format
|
||||
version: 29.6.1
|
||||
type: npm
|
||||
summary: Stringify any JavaScript value.
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
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: []
|
||||
32
.licenses/npm/react-is.dep.yml
generated
32
.licenses/npm/react-is.dep.yml
generated
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: react-is
|
||||
version: 18.2.0
|
||||
type: npm
|
||||
summary: Brand checking of React Elements.
|
||||
homepage: https://reactjs.org/
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
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: []
|
||||
20
.licenses/npm/supports-color.dep.yml
generated
20
.licenses/npm/supports-color.dep.yml
generated
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: supports-color
|
||||
version: 7.2.0
|
||||
type: npm
|
||||
summary: Detect whether a terminal supports color
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: license
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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: []
|
||||
221
README.md
221
README.md
@@ -2,63 +2,83 @@
|
||||
|
||||
[](https://github.com/actions/labeler/actions/workflows/basic-validation.yml)
|
||||
|
||||
Automatically label new pull requests based on the paths of files being changed.
|
||||
Automatically label new pull requests based on the paths of files being changed or the branch name.
|
||||
|
||||
## Usage
|
||||
|
||||
### Create `.github/labeler.yml`
|
||||
|
||||
Create a `.github/labeler.yml` file with a list of labels and [minimatch](https://github.com/isaacs/minimatch) globs to match to apply the label.
|
||||
Create a `.github/labeler.yml` file with a list of labels and config options to match and apply the label.
|
||||
|
||||
The key is the name of the label in your repository that you want to add (e.g. `merge conflict`, `needs-updating`) and the value is the path (glob) of the changed files (e.g. `src/**`, `tests/*.spec.js`) or a match object.
|
||||
The key is the name of the label in your repository that you want to add (eg: "merge conflict", "needs-updating") and the value is a match object.
|
||||
|
||||
#### Match Object
|
||||
|
||||
For more control over matching, you can provide a match object instead of a simple path glob. The match object is defined as:
|
||||
The match object allows control over the matching options, you can specify the label to be applied based on the files that have changed or the name of either the base branch or the head branch. For the changed files options you provide a [path glob](https://github.com/isaacs/minimatch#minimatch), and for the branches you provide a regexp to match against the branch name.
|
||||
|
||||
The base match object is defined as:
|
||||
```yml
|
||||
- any: ['list', 'of', 'globs']
|
||||
all: ['list', 'of', 'globs']
|
||||
- changed-files: ['list', 'of', 'globs']
|
||||
- base-branch: ['list', 'of', 'regexps']
|
||||
- head-branch: ['list', 'of', 'regexps']
|
||||
```
|
||||
|
||||
One or both fields can be provided for fine-grained matching. Unlike the top-level list, the list of path globs provided to `any` and `all` must ALL match against a path for the label to be applied.
|
||||
There are two top level keys of `any` and `all`, which both accept the same config options:
|
||||
```yml
|
||||
- any:
|
||||
- changed-files: ['list', 'of', 'globs']
|
||||
- base-branch: ['list', 'of', 'regexps']
|
||||
- head-branch: ['list', 'of', 'regexps']
|
||||
- all:
|
||||
- changed-files: ['list', 'of', 'globs']
|
||||
- base-branch: ['list', 'of', 'regexps']
|
||||
- head-branch: ['list', 'of', 'regexps']
|
||||
```
|
||||
|
||||
One or all fields can be provided for fine-grained matching.
|
||||
The fields are defined as follows:
|
||||
* `any`: match ALL globs against ANY changed path
|
||||
* `all`: match ALL globs against ALL changed paths
|
||||
* `all`: all of the provided options must match in order for the label to be applied
|
||||
* `any`: if any of the provided options match then a label will be applied
|
||||
* `base-branch`: match regexps against the base branch name
|
||||
* `changed-files`: match glob patterns against the changed paths
|
||||
* `head-branch`: match regexps against the head branch name
|
||||
|
||||
A simple path glob is the equivalent to `any: ['glob']`. More specifically, the following two configurations are equivalent:
|
||||
If a base option is provided without a top-level key then it will default to `any`. More specifically, the following two configurations are equivalent:
|
||||
```yml
|
||||
label1:
|
||||
- example1/*
|
||||
- changed-files: example1/*
|
||||
```
|
||||
and
|
||||
```yml
|
||||
label1:
|
||||
- any: ['example1/*']
|
||||
- any:
|
||||
- changed-files: ['example1/*']
|
||||
```
|
||||
|
||||
From a boolean logic perspective, top-level match objects are `OR`-ed together and individual match rules within an object are `AND`-ed. Combined with `!` negation, you can write complex matching rules.
|
||||
|
||||
> ⚠️ This action uses [minimatch](https://www.npmjs.com/package/minimatch) to apply glob patterns.
|
||||
> For historical reasons, paths starting with dot (e.g. `.github`) are not matched by default.
|
||||
> You need to set `dot: true` to change this behavior.
|
||||
> See [Inputs](#inputs) table below for details.
|
||||
From a boolean logic perspective, top-level match objects, and options within `all` are `AND`-ed together and individual match rules within the `any` object are `OR`-ed. If path globs are combined with `!` negation, you can write complex matching rules.
|
||||
|
||||
#### Basic Examples
|
||||
|
||||
```yml
|
||||
# Add 'label1' to any changes within 'example' folder or any subfolders
|
||||
label1:
|
||||
- example/**
|
||||
- changed-files: example/**/*
|
||||
|
||||
# Add 'label2' to any file changes within 'example2' folder
|
||||
label2: example2/*
|
||||
label2:
|
||||
- changed-files: example2/*
|
||||
|
||||
# Add label3 to any change to .txt files within the entire repository. Quotation marks are required for the leading asterisk
|
||||
label3:
|
||||
- '**/*.txt'
|
||||
- changed-files: '**/*.txt'
|
||||
|
||||
# Add 'label4' to any PR where the head branch name starts with 'example4'
|
||||
label4:
|
||||
- head-branch: '^example4'
|
||||
|
||||
# Add 'label5' to any PR where the base branch name starts with 'example5'
|
||||
label5:
|
||||
- base-branch: '^example5'
|
||||
```
|
||||
|
||||
#### Common Examples
|
||||
@@ -66,40 +86,42 @@ label3:
|
||||
```yml
|
||||
# Add 'repo' label to any root file changes
|
||||
repo:
|
||||
- '*'
|
||||
- changed-files: '*'
|
||||
|
||||
# Add '@domain/core' label to any change within the 'core' package
|
||||
'@domain/core':
|
||||
- package/core/**
|
||||
- changed-files:
|
||||
- package/core/*
|
||||
- package/core/**/*
|
||||
|
||||
# Add 'test' label to any change to *.spec.js files within the source dir
|
||||
test:
|
||||
- src/**/*.spec.js
|
||||
- changed-files: src/**/*.spec.js
|
||||
|
||||
# Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
|
||||
source:
|
||||
- any: ['src/**', '!src/docs/*']
|
||||
- changed-files:
|
||||
- any: ['src/**/*', '!src/docs/*']
|
||||
|
||||
# Add 'frontend` label to any change to *.js files as long as the `main.js` hasn't changed
|
||||
frontend:
|
||||
- any: ['src/**/*.js']
|
||||
all: ['!src/main.js']
|
||||
- any:
|
||||
- changed-files: ['src/**/*.js']
|
||||
- all:
|
||||
- changed-files: ['!src/main.js']
|
||||
|
||||
# Add the 'AnyChange' label to any changes within the entire repository if the 'dot' option is set to 'false'
|
||||
AnyChange:
|
||||
- '**'
|
||||
- '**/.*'
|
||||
- '**/.*/**'
|
||||
- '**/.*/**/.*'
|
||||
# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name
|
||||
feature:
|
||||
- head-branch: ['^feature', 'feature']
|
||||
|
||||
# Add the 'AnyChange' label to any changes within the entire repository if the 'dot' option is set to 'true'
|
||||
AnyChange:
|
||||
- '**'
|
||||
# Add 'release' label to any PR that is opened against the `main` branch
|
||||
release:
|
||||
- base-branch: 'main'
|
||||
```
|
||||
|
||||
### Create Workflow
|
||||
|
||||
Create a workflow (e.g. `.github/workflows/labeler.yml` see [Creating a Workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file)) to utilize the labeler action with content:
|
||||
Create a workflow (eg: `.github/workflows/labeler.yml` see [Creating a Workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file)) to utilize the labeler action with content:
|
||||
|
||||
```yml
|
||||
name: "Pull Request Labeler"
|
||||
@@ -113,7 +135,7 @@ jobs:
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@v4
|
||||
- uses: actions/labeler@v5
|
||||
```
|
||||
|
||||
#### Inputs
|
||||
@@ -121,126 +143,11 @@ jobs:
|
||||
Various inputs are defined in [`action.yml`](action.yml) to let you configure the labeler:
|
||||
|
||||
| Name | Description | Default |
|
||||
|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|
|
||||
| `repo-token` | Token to use to authorize label changes. Typically the GITHUB_TOKEN secret | N/A |
|
||||
| `configuration-path` | The path to the label configuration file. If the file doesn't exist at the specified path on the runner, action will read from the source repository via the Github API. | `.github/labeler.yml` |
|
||||
| - | - | - |
|
||||
| `repo-token` | Token to use to authorize label changes. Typically the GITHUB_TOKEN secret, with `contents:read` and `pull-requests:write` access | `github.token` |
|
||||
| `configuration-path` | The path to the label configuration file | `.github/labeler.yml` |
|
||||
| `sync-labels` | Whether or not to remove labels when matching files are reverted or no longer changed by the PR | `false`|
|
||||
| `dot` | Whether or not to auto-include paths starting with dot (e.g. `.github`) | `false` |
|
||||
| `pr-number` | The number(s) of pull request to update, rather than detecting from the workflow context | N/A |
|
||||
|
||||
##### Using `configuration-path` input together with the `@actions/checkout` action
|
||||
You might want to use action called [@actions/checkout](https://github.com/actions/checkout) to upload label configuration file onto the runner from the current or any other repositories. See usage example below:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: actions/checkout@v3 # Uploads repository content to the runner
|
||||
with:
|
||||
repository: "owner/repositoryName" # The one of the available inputs, visit https://github.com/actions/checkout#readme to find more
|
||||
- uses: actions/labeler@v4
|
||||
```
|
||||
|
||||
##### Peculiarities of using the `dot` input
|
||||
|
||||
When `dot` is disabled, and you want to include _all_ files in a folder:
|
||||
|
||||
```yml
|
||||
label1:
|
||||
- path/to/folder/**/*
|
||||
- path/to/folder/**/.*
|
||||
```
|
||||
|
||||
If `dot` is enabled:
|
||||
|
||||
```yml
|
||||
label1:
|
||||
- path/to/folder/**
|
||||
```
|
||||
|
||||
##### Example workflow specifying Pull request numbers
|
||||
|
||||
```yml
|
||||
name: "Label Previous Pull Requests"
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 1 * * 1"
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
# Label PRs 1, 2, and 3
|
||||
- uses: actions/labeler@v4
|
||||
with:
|
||||
pr-number: |
|
||||
1
|
||||
2
|
||||
3
|
||||
```
|
||||
|
||||
**Note:** in normal usage the `pr-number` input is not required as the action will detect the PR number from the workflow context.
|
||||
|
||||
|
||||
#### Outputs
|
||||
|
||||
Labeler provides the following outputs:
|
||||
|
||||
| Name | Description |
|
||||
|--------------|-----------------------------------------------------------|
|
||||
| `new-labels` | A comma-separated list of all new labels |
|
||||
| `all-labels` | A comma-separated list of all labels that the PR contains |
|
||||
|
||||
The following example performs steps based on the output of labeler:
|
||||
```yml
|
||||
name: "My workflow"
|
||||
on:
|
||||
- pull_request_target
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- id: label-the-PR
|
||||
uses: actions/labeler@v4
|
||||
|
||||
- id: run-frontend-tests
|
||||
if: contains(steps.label-the-PR.outputs.all-labels, 'frontend')
|
||||
run: |
|
||||
echo "Running frontend tests..."
|
||||
# Put your commands for running frontend tests here
|
||||
|
||||
- id: run-backend-tests
|
||||
if: contains(steps.label-the-PR.outputs.all-labels, 'backend')
|
||||
run: |
|
||||
echo "Running backend tests..."
|
||||
# Put your commands for running backend tests here
|
||||
```
|
||||
|
||||
## Permissions
|
||||
|
||||
In order to add labels to pull requests, the GitHub labeler action requires
|
||||
write permissions on the pull-request. However, when the action runs on a pull
|
||||
request from a forked repository, GitHub only grants read access tokens for
|
||||
`pull_request` events, at most. If you encounter an `Error: HttpError: Resource
|
||||
not accessible by integration`, it's likely due to these permission constraints.
|
||||
To resolve this issue, you can modify the `on:` section of your workflow to use
|
||||
[`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target)
|
||||
instead of `pull_request` (see example [above](#create-workflow)). This change
|
||||
allows the action to have write access, because `pull_request_target` alters the
|
||||
[context of the
|
||||
action](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target)
|
||||
and safely grants additional permissions. Refer to the [GitHub token
|
||||
permissions
|
||||
documentation](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token)
|
||||
for more details about access levels and event contexts.
|
||||
|
||||
## Contributions
|
||||
# Contributions
|
||||
|
||||
Contributions are welcome! See the [Contributor's Guide](CONTRIBUTING.md).
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
export const context = {
|
||||
payload: {
|
||||
pull_request: {
|
||||
number: 123
|
||||
number: 123,
|
||||
head: {
|
||||
ref: 'head-branch-name'
|
||||
},
|
||||
base: {
|
||||
ref: 'base-branch-name'
|
||||
}
|
||||
}
|
||||
},
|
||||
repo: {
|
||||
@@ -13,14 +19,11 @@ export const context = {
|
||||
const mockApi = {
|
||||
rest: {
|
||||
issues: {
|
||||
setLabels: jest.fn()
|
||||
addLabels: jest.fn(),
|
||||
removeLabel: jest.fn()
|
||||
},
|
||||
pulls: {
|
||||
get: jest.fn().mockResolvedValue({
|
||||
data: {
|
||||
labels: []
|
||||
}
|
||||
}),
|
||||
get: jest.fn().mockResolvedValue({}),
|
||||
listFiles: {
|
||||
endpoint: {
|
||||
merge: jest.fn().mockReturnValue({})
|
||||
|
||||
210
__tests__/branch.test.ts
Normal file
210
__tests__/branch.test.ts
Normal file
@@ -0,0 +1,210 @@
|
||||
import {
|
||||
getBranchName,
|
||||
checkAnyBranch,
|
||||
checkAllBranch,
|
||||
toBranchMatchConfig,
|
||||
BranchMatchConfig
|
||||
} from '../src/branch';
|
||||
import * as github from '@actions/github';
|
||||
|
||||
jest.mock('@actions/core');
|
||||
jest.mock('@actions/github');
|
||||
|
||||
describe('getBranchName', () => {
|
||||
describe('when the pull requests base branch is requested', () => {
|
||||
it('returns the base branch name', () => {
|
||||
const result = getBranchName('base');
|
||||
expect(result).toEqual('base-branch-name');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the pull requests head branch is requested', () => {
|
||||
it('returns the head branch name', () => {
|
||||
const result = getBranchName('head');
|
||||
expect(result).toEqual('head-branch-name');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkAllBranch', () => {
|
||||
beforeEach(() => {
|
||||
github.context.payload.pull_request!.head = {
|
||||
ref: 'test/feature/123'
|
||||
};
|
||||
github.context.payload.pull_request!.base = {
|
||||
ref: 'main'
|
||||
};
|
||||
});
|
||||
|
||||
describe('when a single pattern is provided', () => {
|
||||
describe('and the pattern matches the head branch', () => {
|
||||
it('returns true', () => {
|
||||
const result = checkAllBranch(['^test'], 'head');
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and the pattern does not match the head branch', () => {
|
||||
it('returns false', () => {
|
||||
const result = checkAllBranch(['^feature/'], 'head');
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when multiple patterns are provided', () => {
|
||||
describe('and not all patterns matched', () => {
|
||||
it('returns false', () => {
|
||||
const result = checkAllBranch(['^test/', '^feature/'], 'head');
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and all patterns match', () => {
|
||||
it('returns true', () => {
|
||||
const result = checkAllBranch(['^test/', '/feature/'], 'head');
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and no patterns match', () => {
|
||||
it('returns false', () => {
|
||||
const result = checkAllBranch(['^feature/', '/test$'], 'head');
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the branch to check is specified as the base branch', () => {
|
||||
describe('and the pattern matches the base branch', () => {
|
||||
it('returns true', () => {
|
||||
const result = checkAllBranch(['^main$'], 'base');
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkAnyBranch', () => {
|
||||
beforeEach(() => {
|
||||
github.context.payload.pull_request!.head = {
|
||||
ref: 'test/feature/123'
|
||||
};
|
||||
github.context.payload.pull_request!.base = {
|
||||
ref: 'main'
|
||||
};
|
||||
});
|
||||
|
||||
describe('when a single pattern is provided', () => {
|
||||
describe('and the pattern matches the head branch', () => {
|
||||
it('returns true', () => {
|
||||
const result = checkAnyBranch(['^test'], 'head');
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and the pattern does not match the head branch', () => {
|
||||
it('returns false', () => {
|
||||
const result = checkAnyBranch(['^feature/'], 'head');
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when multiple patterns are provided', () => {
|
||||
describe('and at least one pattern matches', () => {
|
||||
it('returns true', () => {
|
||||
const result = checkAnyBranch(['^test/', '^feature/'], 'head');
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and all patterns match', () => {
|
||||
it('returns true', () => {
|
||||
const result = checkAnyBranch(['^test/', '/feature/'], 'head');
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and no patterns match', () => {
|
||||
it('returns false', () => {
|
||||
const result = checkAnyBranch(['^feature/', '/test$'], 'head');
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the branch to check is specified as the base branch', () => {
|
||||
describe('and the pattern matches the base branch', () => {
|
||||
it('returns true', () => {
|
||||
const result = checkAnyBranch(['^main$'], 'base');
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('toBranchMatchConfig', () => {
|
||||
describe('when there are no branch keys in the config', () => {
|
||||
const config = {'changed-files': [{any: ['testing']}]};
|
||||
|
||||
it('returns an empty object', () => {
|
||||
const result = toBranchMatchConfig(config);
|
||||
expect(result).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the config contains a head-branch option', () => {
|
||||
const config = {'head-branch': ['testing']};
|
||||
|
||||
it('sets headBranch in the matchConfig', () => {
|
||||
const result = toBranchMatchConfig(config);
|
||||
expect(result).toEqual<BranchMatchConfig>({
|
||||
headBranch: ['testing']
|
||||
});
|
||||
});
|
||||
|
||||
describe('and the matching option is a string', () => {
|
||||
const stringConfig = {'head-branch': 'testing'};
|
||||
|
||||
it('sets headBranch in the matchConfig', () => {
|
||||
const result = toBranchMatchConfig(stringConfig);
|
||||
expect(result).toEqual<BranchMatchConfig>({
|
||||
headBranch: ['testing']
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the config contains a base-branch option', () => {
|
||||
const config = {'base-branch': ['testing']};
|
||||
it('sets baseBranch in the matchConfig', () => {
|
||||
const result = toBranchMatchConfig(config);
|
||||
expect(result).toEqual<BranchMatchConfig>({
|
||||
baseBranch: ['testing']
|
||||
});
|
||||
});
|
||||
|
||||
describe('and the matching option is a string', () => {
|
||||
const stringConfig = {'base-branch': 'testing'};
|
||||
|
||||
it('sets baseBranch in the matchConfig', () => {
|
||||
const result = toBranchMatchConfig(stringConfig);
|
||||
expect(result).toEqual<BranchMatchConfig>({
|
||||
baseBranch: ['testing']
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the config contains both a base-branch and head-branch option', () => {
|
||||
const config = {'base-branch': ['testing'], 'head-branch': ['testing']};
|
||||
it('sets headBranch and baseBranch in the matchConfig', () => {
|
||||
const result = toBranchMatchConfig(config);
|
||||
expect(result).toEqual<BranchMatchConfig>({
|
||||
baseBranch: ['testing'],
|
||||
headBranch: ['testing']
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
220
__tests__/changedFiles.test.ts
Normal file
220
__tests__/changedFiles.test.ts
Normal file
@@ -0,0 +1,220 @@
|
||||
import {
|
||||
ChangedFilesMatchConfig,
|
||||
checkAllChangedFiles,
|
||||
checkAnyChangedFiles,
|
||||
toChangedFilesMatchConfig,
|
||||
checkIfAnyGlobMatchesAnyFile,
|
||||
checkIfAllGlobsMatchAnyFile,
|
||||
checkIfAnyGlobMatchesAllFiles,
|
||||
checkIfAllGlobsMatchAllFiles
|
||||
} from '../src/changedFiles';
|
||||
|
||||
jest.mock('@actions/core');
|
||||
jest.mock('@actions/github');
|
||||
|
||||
describe('checkAllChangedFiles', () => {
|
||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||
|
||||
describe('when all given glob pattern configs matched', () => {
|
||||
const globPatternsConfigs = [
|
||||
{AnyGlobToAnyFile: ['foo.txt']},
|
||||
{AnyGlobToAllFiles: ['*.txt']},
|
||||
{AllGlobsToAllFiles: ['**']}
|
||||
];
|
||||
|
||||
it('returns true', () => {
|
||||
const result = checkAllChangedFiles(changedFiles, globPatternsConfigs);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe(`when some given glob pattern config did not match`, () => {
|
||||
const globPatternsConfigs = [
|
||||
{AnyGlobToAnyFile: ['*.md']},
|
||||
{AnyGlobToAllFiles: ['*.txt']},
|
||||
{AllGlobsToAllFiles: ['**']}
|
||||
];
|
||||
|
||||
it('returns false', () => {
|
||||
const result = checkAllChangedFiles(changedFiles, globPatternsConfigs);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkAnyChangedFiles', () => {
|
||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||
|
||||
describe('when any given glob pattern config matched', () => {
|
||||
const globPatternsConfigs = [
|
||||
{AnyGlobToAnyFile: ['*.md']},
|
||||
{AnyGlobToAllFiles: ['*.txt']}
|
||||
];
|
||||
|
||||
it('returns true', () => {
|
||||
const result = checkAnyChangedFiles(changedFiles, globPatternsConfigs);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when none of the given glob pattern configs matched', () => {
|
||||
const globPatternsConfigs = [
|
||||
{AnyGlobToAnyFile: ['*.md']},
|
||||
{AnyGlobToAllFiles: ['!*.txt']}
|
||||
];
|
||||
|
||||
it('returns false', () => {
|
||||
const result = checkAnyChangedFiles(changedFiles, globPatternsConfigs);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('toChangedFilesMatchConfig', () => {
|
||||
describe(`when there is no 'changed-files' key in the config`, () => {
|
||||
const config = {'head-branch': 'test'};
|
||||
|
||||
it('returns an empty object', () => {
|
||||
const result = toChangedFilesMatchConfig(config);
|
||||
expect(result).toEqual<ChangedFilesMatchConfig>({});
|
||||
});
|
||||
});
|
||||
|
||||
describe(`when there is a 'changed-files' key in the config`, () => {
|
||||
describe('but the glob pattern config key is not provided', () => {
|
||||
const config = {'changed-files': ['bar']};
|
||||
|
||||
it('throws the error', () => {
|
||||
expect(() => {
|
||||
toChangedFilesMatchConfig(config);
|
||||
}).toThrow(
|
||||
`The "changed-files" section must have a valid config structure. Please read the action documentation for more information`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('but the glob pattern config key is not valid', () => {
|
||||
const config = {'changed-files': [{NotValidConfigKey: ['bar']}]};
|
||||
|
||||
it('throws the error', () => {
|
||||
expect(() => {
|
||||
toChangedFilesMatchConfig(config);
|
||||
}).toThrow(
|
||||
`Unknown config options were under "changed-files": NotValidConfigKey`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and the glob pattern config key is provided', () => {
|
||||
describe('and the value is an array of strings', () => {
|
||||
const config = {'changed-files': [{AnyGlobToAnyFile: ['testing']}]};
|
||||
|
||||
it('sets the value in the config object', () => {
|
||||
const result = toChangedFilesMatchConfig(config);
|
||||
expect(result).toEqual<ChangedFilesMatchConfig>({
|
||||
changedFiles: [{AnyGlobToAnyFile: ['testing']}]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('and the value is a string', () => {
|
||||
const config = {'changed-files': [{AnyGlobToAnyFile: 'testing'}]};
|
||||
|
||||
it(`sets the string as an array in the config object`, () => {
|
||||
const result = toChangedFilesMatchConfig(config);
|
||||
expect(result).toEqual<ChangedFilesMatchConfig>({
|
||||
changedFiles: [{AnyGlobToAnyFile: ['testing']}]
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkIfAnyGlobMatchesAnyFile', () => {
|
||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||
|
||||
describe('when any given glob pattern matched any file', () => {
|
||||
const globPatterns = ['*.md', 'foo.txt'];
|
||||
|
||||
it('returns true', () => {
|
||||
const result = checkIfAnyGlobMatchesAnyFile(changedFiles, globPatterns);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when none of the given glob pattern matched any file', () => {
|
||||
const globPatterns = ['*.md', '!*.txt'];
|
||||
|
||||
it('returns false', () => {
|
||||
const result = checkIfAnyGlobMatchesAnyFile(changedFiles, globPatterns);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkIfAllGlobsMatchAnyFile', () => {
|
||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||
|
||||
describe('when all given glob patterns matched any file', () => {
|
||||
const globPatterns = ['**/bar.txt', 'bar.txt'];
|
||||
|
||||
it('returns true', () => {
|
||||
const result = checkIfAllGlobsMatchAnyFile(changedFiles, globPatterns);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when some of the given glob patterns did not match any file', () => {
|
||||
const globPatterns = ['*.txt', '*.md'];
|
||||
|
||||
it('returns false', () => {
|
||||
const result = checkIfAllGlobsMatchAnyFile(changedFiles, globPatterns);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkIfAnyGlobMatchesAllFiles', () => {
|
||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||
|
||||
describe('when any given glob pattern matched all files', () => {
|
||||
const globPatterns = ['*.md', '*.txt'];
|
||||
|
||||
it('returns true', () => {
|
||||
const result = checkIfAnyGlobMatchesAllFiles(changedFiles, globPatterns);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when none of the given glob patterns matched all files', () => {
|
||||
const globPatterns = ['*.md', 'bar.txt', 'foo.txt'];
|
||||
|
||||
it('returns false', () => {
|
||||
const result = checkIfAnyGlobMatchesAllFiles(changedFiles, globPatterns);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkIfAllGlobsMatchAllFiles', () => {
|
||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||
|
||||
describe('when all given glob patterns matched all files', () => {
|
||||
const globPatterns = ['*.txt', '**'];
|
||||
|
||||
it('returns true', () => {
|
||||
const result = checkIfAllGlobsMatchAllFiles(changedFiles, globPatterns);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when some of the given glob patterns did not match all files', () => {
|
||||
const globPatterns = ['**', 'foo.txt'];
|
||||
|
||||
it('returns false', () => {
|
||||
const result = checkIfAllGlobsMatchAllFiles(changedFiles, globPatterns);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
17
__tests__/fixtures/all_options.yml
Normal file
17
__tests__/fixtures/all_options.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
label1:
|
||||
- any:
|
||||
- changed-files:
|
||||
- AnyGlobToAnyFile: ['glob']
|
||||
- head-branch: ['regexp']
|
||||
- base-branch: ['regexp']
|
||||
- all:
|
||||
- changed-files:
|
||||
- AllGlobsToAllFiles: ['glob']
|
||||
- head-branch: ['regexp']
|
||||
- base-branch: ['regexp']
|
||||
|
||||
label2:
|
||||
- changed-files:
|
||||
- AnyGlobToAnyFile: ['glob']
|
||||
- head-branch: ['regexp']
|
||||
- base-branch: ['regexp']
|
||||
8
__tests__/fixtures/any_and_all.yml
Normal file
8
__tests__/fixtures/any_and_all.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
tests:
|
||||
- any:
|
||||
- head-branch: ['^tests/', '^test/']
|
||||
- changed-files:
|
||||
- AnyGlobToAnyFile: ['tests/**/*']
|
||||
- all:
|
||||
- changed-files:
|
||||
- AllGlobsToAllFiles: ['!tests/requirements.txt']
|
||||
11
__tests__/fixtures/branches.yml
Normal file
11
__tests__/fixtures/branches.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
test-branch:
|
||||
- head-branch: '^test/'
|
||||
|
||||
feature-branch:
|
||||
- head-branch: '/feature/'
|
||||
|
||||
bug-branch:
|
||||
- head-branch: '^bug/|fix/'
|
||||
|
||||
array-branch:
|
||||
- head-branch: ['^array/']
|
||||
3
__tests__/fixtures/not_supported.yml
Normal file
3
__tests__/fixtures/not_supported.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
label:
|
||||
- all:
|
||||
- unknown: 'this-is-not-supported'
|
||||
@@ -1,2 +1,3 @@
|
||||
touched-a-pdf-file:
|
||||
- any: ['*.pdf']
|
||||
- changed-files:
|
||||
- AnyGlobToAnyFile: ['*.pdf']
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import {checkGlobs} from '../src/labeler';
|
||||
|
||||
import {
|
||||
checkMatchConfigs,
|
||||
MatchConfig,
|
||||
toMatchConfig,
|
||||
getLabelConfigMapFromObject,
|
||||
BaseMatchConfig
|
||||
} from '../src/labeler';
|
||||
import * as yaml from 'js-yaml';
|
||||
import * as core from '@actions/core';
|
||||
import * as fs from 'fs';
|
||||
|
||||
jest.mock('@actions/core');
|
||||
|
||||
@@ -10,34 +17,131 @@ beforeAll(() => {
|
||||
});
|
||||
});
|
||||
|
||||
const matchConfig = [{any: ['*.txt']}];
|
||||
const loadYaml = (filepath: string) => {
|
||||
const loadedFile = fs.readFileSync(filepath);
|
||||
const content = Buffer.from(loadedFile).toString();
|
||||
return yaml.load(content);
|
||||
};
|
||||
|
||||
describe('getLabelConfigMapFromObject', () => {
|
||||
const yamlObject = loadYaml('__tests__/fixtures/all_options.yml');
|
||||
const expected = new Map<string, MatchConfig[]>();
|
||||
expected.set('label1', [
|
||||
{
|
||||
any: [
|
||||
{changedFiles: [{AnyGlobToAnyFile: ['glob']}]},
|
||||
{baseBranch: undefined, headBranch: ['regexp']},
|
||||
{baseBranch: ['regexp'], headBranch: undefined}
|
||||
]
|
||||
},
|
||||
{
|
||||
all: [
|
||||
{changedFiles: [{AllGlobsToAllFiles: ['glob']}]},
|
||||
{baseBranch: undefined, headBranch: ['regexp']},
|
||||
{baseBranch: ['regexp'], headBranch: undefined}
|
||||
]
|
||||
}
|
||||
]);
|
||||
expected.set('label2', [
|
||||
{
|
||||
any: [
|
||||
{changedFiles: [{AnyGlobToAnyFile: ['glob']}]},
|
||||
{baseBranch: undefined, headBranch: ['regexp']},
|
||||
{baseBranch: ['regexp'], headBranch: undefined}
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
it('returns a MatchConfig', () => {
|
||||
const result = getLabelConfigMapFromObject(yamlObject);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toMatchConfig', () => {
|
||||
describe('when all expected config options are present', () => {
|
||||
const config = {
|
||||
'changed-files': [{AnyGlobToAnyFile: ['testing-files']}],
|
||||
'head-branch': ['testing-head'],
|
||||
'base-branch': ['testing-base']
|
||||
};
|
||||
const expected: BaseMatchConfig = {
|
||||
changedFiles: [{AnyGlobToAnyFile: ['testing-files']}],
|
||||
headBranch: ['testing-head'],
|
||||
baseBranch: ['testing-base']
|
||||
};
|
||||
|
||||
it('returns a MatchConfig object with all options', () => {
|
||||
const result = toMatchConfig(config);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
describe('and there are also unexpected options present', () => {
|
||||
config['test-test'] = 'testing';
|
||||
|
||||
it('does not include the unexpected items in the returned MatchConfig object', () => {
|
||||
const result = toMatchConfig(config);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkMatchConfigs', () => {
|
||||
describe('when a single match config is provided', () => {
|
||||
const matchConfig: MatchConfig[] = [
|
||||
{any: [{changedFiles: [{AnyGlobToAnyFile: ['*.txt']}]}]}
|
||||
];
|
||||
|
||||
describe('checkGlobs', () => {
|
||||
it('returns true when our pattern does match changed files', () => {
|
||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||
const result = checkGlobs(changedFiles, matchConfig, false);
|
||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('returns false when our pattern does not match changed files', () => {
|
||||
const changedFiles = ['foo.docx'];
|
||||
const result = checkGlobs(changedFiles, matchConfig, false);
|
||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('returns false for a file starting with dot if `dot` option is false', () => {
|
||||
const changedFiles = ['.foo.txt'];
|
||||
const result = checkGlobs(changedFiles, matchConfig, false);
|
||||
it('returns true when either the branch or changed files patter matches', () => {
|
||||
const matchConfig: MatchConfig[] = [
|
||||
{
|
||||
any: [
|
||||
{changedFiles: [{AnyGlobToAnyFile: ['*.txt']}]},
|
||||
{headBranch: ['some-branch']}
|
||||
]
|
||||
}
|
||||
];
|
||||
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('returns true for a file starting with dot if `dot` option is true', () => {
|
||||
const changedFiles = ['.foo.txt'];
|
||||
const result = checkGlobs(changedFiles, matchConfig, true);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when multiple MatchConfigs are supplied', () => {
|
||||
const matchConfig: MatchConfig[] = [
|
||||
{any: [{changedFiles: [{AnyGlobToAnyFile: ['*.txt']}]}]},
|
||||
{any: [{headBranch: ['some-branch']}]}
|
||||
];
|
||||
const changedFiles = ['foo.txt', 'bar.md'];
|
||||
|
||||
it('returns false when only one config matches', () => {
|
||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true when only both config matches', () => {
|
||||
const matchConfig: MatchConfig[] = [
|
||||
{any: [{changedFiles: [{AnyGlobToAnyFile: ['*.txt']}]}]},
|
||||
{any: [{headBranch: ['head-branch']}]}
|
||||
];
|
||||
const result = checkMatchConfigs(changedFiles, matchConfig);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,381 +1,209 @@
|
||||
import {run} from '../src/labeler';
|
||||
import * as github from '@actions/github';
|
||||
import * as core from '@actions/core';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import each from 'jest-each';
|
||||
|
||||
const fs = jest.requireActual('fs');
|
||||
|
||||
jest.mock('@actions/core');
|
||||
jest.mock('@actions/github');
|
||||
|
||||
const gh = github.getOctokit('_');
|
||||
const setLabelsMock = jest.spyOn(gh.rest.issues, 'setLabels');
|
||||
const addLabelsMock = jest.spyOn(gh.rest.issues, 'addLabels');
|
||||
const removeLabelMock = jest.spyOn(gh.rest.issues, 'removeLabel');
|
||||
const reposMock = jest.spyOn(gh.rest.repos, 'getContent');
|
||||
const paginateMock = jest.spyOn(gh, 'paginate');
|
||||
const getPullMock = jest.spyOn(gh.rest.pulls, 'get');
|
||||
const readFileSyncMock = jest.spyOn(fs, 'readFileSync');
|
||||
const existsSyncMock = jest.spyOn(fs, 'existsSync');
|
||||
const coreErrorMock = jest.spyOn(core, 'error');
|
||||
const coreWarningMock = jest.spyOn(core, 'warning');
|
||||
const coreSetFailedMock = jest.spyOn(core, 'setFailed');
|
||||
const setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||
|
||||
class HttpError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'HttpError';
|
||||
}
|
||||
}
|
||||
|
||||
class NotFound extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'NotFound';
|
||||
}
|
||||
}
|
||||
|
||||
const yamlFixtures = {
|
||||
'only_pdfs.yml': fs.readFileSync('__tests__/fixtures/only_pdfs.yml')
|
||||
};
|
||||
|
||||
const configureInput = (
|
||||
mockInput: Partial<{
|
||||
'repo-token': string;
|
||||
'configuration-path': string;
|
||||
'sync-labels': boolean;
|
||||
dot: boolean;
|
||||
'pr-number': string[];
|
||||
}>
|
||||
) => {
|
||||
jest
|
||||
.spyOn(core, 'getInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
jest
|
||||
.spyOn(core, 'getMultilineInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
jest
|
||||
.spyOn(core, 'getBooleanInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
'branches.yml': fs.readFileSync('__tests__/fixtures/branches.yml'),
|
||||
'only_pdfs.yml': fs.readFileSync('__tests__/fixtures/only_pdfs.yml'),
|
||||
'not_supported.yml': fs.readFileSync('__tests__/fixtures/not_supported.yml'),
|
||||
'any_and_all.yml': fs.readFileSync('__tests__/fixtures/any_and_all.yml')
|
||||
};
|
||||
|
||||
afterAll(() => jest.restoreAllMocks());
|
||||
|
||||
describe('run', () => {
|
||||
it('(with dot: false) adds labels to PRs that match our glob patterns', async () => {
|
||||
configureInput({});
|
||||
it('adds labels to PRs that match our glob patterns', async () => {
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
getPullMock.mockResolvedValue(<any>{
|
||||
data: {
|
||||
labels: []
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(setLabelsMock).toHaveBeenCalledWith({
|
||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 123,
|
||||
labels: ['touched-a-pdf-file']
|
||||
});
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'new-labels',
|
||||
'touched-a-pdf-file'
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'all-labels',
|
||||
'touched-a-pdf-file'
|
||||
);
|
||||
});
|
||||
|
||||
it('(with dot: true) adds labels to PRs that match our glob patterns', async () => {
|
||||
configureInput({dot: true});
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('.foo.pdf');
|
||||
getPullMock.mockResolvedValue(<any>{
|
||||
data: {
|
||||
labels: []
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(setLabelsMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 123,
|
||||
labels: ['touched-a-pdf-file']
|
||||
});
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'new-labels',
|
||||
'touched-a-pdf-file'
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'all-labels',
|
||||
'touched-a-pdf-file'
|
||||
);
|
||||
});
|
||||
|
||||
it('(with dot: false) does not add labels to PRs that do not match our glob patterns', async () => {
|
||||
configureInput({});
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('.foo.pdf');
|
||||
getPullMock.mockResolvedValue(<any>{
|
||||
data: {
|
||||
labels: []
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(0);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('new-labels', '');
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('all-labels', '');
|
||||
});
|
||||
|
||||
it('(with dot: true) does not add labels to PRs that do not match our glob patterns', async () => {
|
||||
configureInput({dot: true});
|
||||
it('does not add labels to PRs that do not match our glob patterns', async () => {
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.txt');
|
||||
|
||||
await run();
|
||||
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(0);
|
||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('does not add a label when the match config options are not supported', async () => {
|
||||
usingLabelerConfigYaml('not_supported.yml');
|
||||
await run();
|
||||
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('(with sync-labels: true) it deletes preexisting PR labels that no longer match the glob pattern', async () => {
|
||||
configureInput({
|
||||
const mockInput = {
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'sync-labels': true
|
||||
});
|
||||
'sync-labels': 'true'
|
||||
};
|
||||
|
||||
jest
|
||||
.spyOn(core, 'getInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
jest
|
||||
.spyOn(core, 'getBooleanInput')
|
||||
.mockImplementation(
|
||||
(name: string, ...opts) => mockInput[name] === 'true'
|
||||
);
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.txt');
|
||||
getPullMock.mockResolvedValue(<any>{
|
||||
data: {
|
||||
labels: [{name: 'touched-a-pdf-file'}, {name: 'manually-added'}]
|
||||
labels: [{name: 'touched-a-pdf-file'}]
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(setLabelsMock).toHaveBeenCalledWith({
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
||||
expect(removeLabelMock).toHaveBeenCalledTimes(1);
|
||||
expect(removeLabelMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 123,
|
||||
labels: ['manually-added']
|
||||
name: 'touched-a-pdf-file'
|
||||
});
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('new-labels', '');
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('all-labels', 'manually-added');
|
||||
});
|
||||
|
||||
it('(with sync-labels: false) it issues no delete calls even when there are preexisting PR labels that no longer match the glob pattern', async () => {
|
||||
configureInput({
|
||||
const mockInput = {
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'sync-labels': false
|
||||
});
|
||||
'sync-labels': 'false'
|
||||
};
|
||||
|
||||
jest
|
||||
.spyOn(core, 'getInput')
|
||||
.mockImplementation((name: string, ...opts) => mockInput[name]);
|
||||
jest
|
||||
.spyOn(core, 'getBooleanInput')
|
||||
.mockImplementation(
|
||||
(name: string, ...opts) => mockInput[name] === 'true'
|
||||
);
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.txt');
|
||||
getPullMock.mockResolvedValue(<any>{
|
||||
data: {
|
||||
labels: [{name: 'touched-a-pdf-file'}, {name: 'manually-added'}]
|
||||
labels: [{name: 'touched-a-pdf-file'}]
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(0);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('new-labels', '');
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'all-labels',
|
||||
'touched-a-pdf-file,manually-added'
|
||||
);
|
||||
});
|
||||
|
||||
it('(with sync-labels: false) it only logs the excess labels', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'sync-labels': false
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
|
||||
const existingLabels = Array.from({length: 100}).map((_, idx) => ({
|
||||
name: `existing-label-${idx}`
|
||||
}));
|
||||
getPullMock.mockResolvedValue(<any>{
|
||||
data: {
|
||||
labels: existingLabels
|
||||
}
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('adds labels based on the branch names that match the regexp pattern', async () => {
|
||||
github.context.payload.pull_request!.head = {ref: 'test/testing-time'};
|
||||
usingLabelerConfigYaml('branches.yml');
|
||||
await run();
|
||||
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(0);
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledTimes(1);
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(
|
||||
'Maximum of 100 labels allowed. Excess labels: touched-a-pdf-file',
|
||||
{title: 'Label limit for a PR exceeded'}
|
||||
);
|
||||
const allLabels: string = existingLabels.map(i => i.name).join(',');
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('new-labels', '');
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('all-labels', allLabels);
|
||||
});
|
||||
|
||||
it('(with pr-number: array of one item, uses the PR number specified in the parameters', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['104']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
|
||||
getPullMock.mockResolvedValue(<any>{
|
||||
data: {
|
||||
labels: [{name: 'manually-added'}]
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(setLabelsMock).toHaveBeenCalledWith({
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 104,
|
||||
labels: ['manually-added', 'touched-a-pdf-file']
|
||||
issue_number: 123,
|
||||
labels: ['test-branch']
|
||||
});
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'new-labels',
|
||||
'touched-a-pdf-file'
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'all-labels',
|
||||
'manually-added,touched-a-pdf-file'
|
||||
);
|
||||
});
|
||||
|
||||
it('(with pr-number: array of two items, uses the PR number specified in the parameters', async () => {
|
||||
configureInput({
|
||||
'repo-token': 'foo',
|
||||
'configuration-path': 'bar',
|
||||
'pr-number': ['104', '150']
|
||||
});
|
||||
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
|
||||
getPullMock.mockResolvedValueOnce(<any>{
|
||||
data: {
|
||||
labels: [{name: 'manually-added'}]
|
||||
}
|
||||
});
|
||||
|
||||
getPullMock.mockResolvedValueOnce(<any>{
|
||||
data: {
|
||||
labels: []
|
||||
}
|
||||
});
|
||||
|
||||
it('adds multiple labels based on branch names that match different regexp patterns', async () => {
|
||||
github.context.payload.pull_request!.head = {
|
||||
ref: 'test/feature/123'
|
||||
};
|
||||
usingLabelerConfigYaml('branches.yml');
|
||||
await run();
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(2);
|
||||
expect(setLabelsMock).toHaveBeenCalledWith({
|
||||
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 104,
|
||||
labels: ['manually-added', 'touched-a-pdf-file']
|
||||
issue_number: 123,
|
||||
labels: ['test-branch', 'feature-branch']
|
||||
});
|
||||
expect(setLabelsMock).toHaveBeenCalledWith({
|
||||
});
|
||||
|
||||
it('can support multiple branches by batching', async () => {
|
||||
github.context.payload.pull_request!.head = {ref: 'fix/123'};
|
||||
usingLabelerConfigYaml('branches.yml');
|
||||
await run();
|
||||
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 150,
|
||||
labels: ['touched-a-pdf-file']
|
||||
issue_number: 123,
|
||||
labels: ['bug-branch']
|
||||
});
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'new-labels',
|
||||
'touched-a-pdf-file'
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'all-labels',
|
||||
'manually-added,touched-a-pdf-file'
|
||||
);
|
||||
});
|
||||
|
||||
it('does not add labels to PRs that have no changed files', async () => {
|
||||
usingLabelerConfigYaml('only_pdfs.yml');
|
||||
mockGitHubResponseChangedFiles();
|
||||
|
||||
it('can support multiple branches by providing an array', async () => {
|
||||
github.context.payload.pull_request!.head = {ref: 'array/123'};
|
||||
usingLabelerConfigYaml('branches.yml');
|
||||
await run();
|
||||
|
||||
expect(setLabelsMock).toHaveBeenCalledTimes(0);
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 123,
|
||||
labels: ['array-branch']
|
||||
});
|
||||
});
|
||||
|
||||
it('should use local configuration file if it exists', async () => {
|
||||
const configFile = 'only_pdfs.yml';
|
||||
const configFilePath = path.join(__dirname, 'fixtures', configFile);
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
const readFileSyncOptions = {encoding: 'utf8'};
|
||||
|
||||
configureInput({
|
||||
'configuration-path': configFilePath
|
||||
});
|
||||
it('adds a label when matching any and all patterns are provided', async () => {
|
||||
usingLabelerConfigYaml('any_and_all.yml');
|
||||
mockGitHubResponseChangedFiles('tests/test.ts');
|
||||
await run();
|
||||
|
||||
expect(existsSyncMock).toHaveBeenCalledWith(configFilePath);
|
||||
expect(readFileSyncMock).toHaveBeenCalledWith(
|
||||
configFilePath,
|
||||
readFileSyncOptions
|
||||
);
|
||||
expect(reposMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should fetch configuration file from API if it does not exist locally', async () => {
|
||||
const configFilePath = 'non_existed_path/labeler.yml';
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
configureInput({
|
||||
'configuration-path': configFilePath
|
||||
});
|
||||
await run();
|
||||
expect(existsSyncMock).toHaveBeenCalledWith(configFilePath);
|
||||
expect(readFileSyncMock).not.toHaveBeenCalled();
|
||||
expect(reposMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
each([
|
||||
[new HttpError('Error message')],
|
||||
[new NotFound('Error message')]
|
||||
]).test(
|
||||
'should warn if configuration file could not be fetched through the API, log error and fail the action',
|
||||
async error => {
|
||||
const configFilePath = 'non_existed_path/labeler.yml';
|
||||
reposMock.mockImplementation(() => {
|
||||
throw error;
|
||||
});
|
||||
const warningMessage = `The config file was not found at ${configFilePath}. Make sure it exists and that this action has the correct access rights.`;
|
||||
mockGitHubResponseChangedFiles('foo.pdf');
|
||||
configureInput({
|
||||
'configuration-path': configFilePath
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(1);
|
||||
expect(addLabelsMock).toHaveBeenCalledWith({
|
||||
owner: 'monalisa',
|
||||
repo: 'helloworld',
|
||||
issue_number: 123,
|
||||
labels: ['tests']
|
||||
});
|
||||
});
|
||||
|
||||
it('does not add a label when not all any and all patterns are matched', async () => {
|
||||
usingLabelerConfigYaml('any_and_all.yml');
|
||||
mockGitHubResponseChangedFiles('tests/requirements.txt');
|
||||
await run();
|
||||
|
||||
expect(coreWarningMock).toHaveBeenCalledWith(warningMessage);
|
||||
expect(coreErrorMock).toHaveBeenCalledWith(error);
|
||||
expect(coreSetFailedMock).toHaveBeenCalledWith(error.message);
|
||||
}
|
||||
);
|
||||
expect(addLabelsMock).toHaveBeenCalledTimes(0);
|
||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
function usingLabelerConfigYaml(fixtureName: keyof typeof yamlFixtures): void {
|
||||
|
||||
12
action.yml
12
action.yml
@@ -14,19 +14,7 @@ inputs:
|
||||
description: 'Whether or not to remove labels when matching files are reverted'
|
||||
default: false
|
||||
required: false
|
||||
dot:
|
||||
description: 'Whether or not to auto-include paths starting with dot (e.g. `.github`)'
|
||||
default: false
|
||||
required: false
|
||||
pr-number:
|
||||
description: 'The pull request number(s)'
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
new-labels:
|
||||
description: 'A comma-separated list of all new labels'
|
||||
all-labels:
|
||||
description: 'A comma-separated list of all labels that the PR contains'
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
|
||||
2439
dist/index.js
vendored
2439
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
932
package-lock.json
generated
932
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "labeler",
|
||||
"version": "4.1.0",
|
||||
"version": "4.0.1",
|
||||
"description": "Labels pull requests by files altered",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
@@ -26,8 +26,6 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/github": "^5.1.1",
|
||||
"@octokit/plugin-retry": "^5.0.5",
|
||||
"jest-each": "^29.6.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"minimatch": "^7.4.3"
|
||||
},
|
||||
@@ -36,13 +34,12 @@
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/minimatch": "^5.1.2",
|
||||
"@types/node": "^16.11.7",
|
||||
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
||||
"@typescript-eslint/parser": "^5.61.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||
"@typescript-eslint/parser": "^5.59.7",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.44.0",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-jest": "^27.2.2",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"jest": "^27.5.1",
|
||||
"prettier": "^2.8.8",
|
||||
"ts-jest": "^27.1.3",
|
||||
|
||||
98
src/branch.ts
Normal file
98
src/branch.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
|
||||
export interface BranchMatchConfig {
|
||||
headBranch?: string[];
|
||||
baseBranch?: string[];
|
||||
}
|
||||
|
||||
type BranchBase = 'base' | 'head';
|
||||
|
||||
export function toBranchMatchConfig(config: any): BranchMatchConfig {
|
||||
if (!config['head-branch'] && !config['base-branch']) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const branchConfig = {
|
||||
headBranch: config['head-branch'],
|
||||
baseBranch: config['base-branch']
|
||||
};
|
||||
|
||||
for (const branchName in branchConfig) {
|
||||
if (typeof branchConfig[branchName] === 'string') {
|
||||
branchConfig[branchName] = [branchConfig[branchName]];
|
||||
}
|
||||
}
|
||||
|
||||
return branchConfig;
|
||||
}
|
||||
|
||||
export function getBranchName(branchBase: BranchBase): string | undefined {
|
||||
const pullRequest = github.context.payload.pull_request;
|
||||
if (!pullRequest) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (branchBase === 'base') {
|
||||
return pullRequest.base?.ref;
|
||||
} else {
|
||||
return pullRequest.head?.ref;
|
||||
}
|
||||
}
|
||||
|
||||
export function checkAnyBranch(
|
||||
regexps: string[],
|
||||
branchBase: BranchBase
|
||||
): boolean {
|
||||
const branchName = getBranchName(branchBase);
|
||||
if (!branchName) {
|
||||
core.debug(` no branch name`);
|
||||
return false;
|
||||
}
|
||||
|
||||
core.debug(` checking "branch" pattern against ${branchName}`);
|
||||
const matchers = regexps.map(regexp => new RegExp(regexp));
|
||||
for (const matcher of matchers) {
|
||||
if (matchBranchPattern(matcher, branchName)) {
|
||||
core.debug(` "branch" patterns matched against ${branchName}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` "branch" patterns did not match against ${branchName}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
export function checkAllBranch(
|
||||
regexps: string[],
|
||||
branchBase: BranchBase
|
||||
): boolean {
|
||||
const branchName = getBranchName(branchBase);
|
||||
if (!branchName) {
|
||||
core.debug(` cannot fetch branch name from the pull request`);
|
||||
return false;
|
||||
}
|
||||
|
||||
core.debug(` checking "branch" pattern against ${branchName}`);
|
||||
const matchers = regexps.map(regexp => new RegExp(regexp));
|
||||
for (const matcher of matchers) {
|
||||
if (!matchBranchPattern(matcher, branchName)) {
|
||||
core.debug(` "branch" patterns did not match against ${branchName}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` "branch" patterns matched against ${branchName}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
function matchBranchPattern(matcher: RegExp, branchName: string): boolean {
|
||||
core.debug(` - ${matcher}`);
|
||||
if (matcher.test(branchName)) {
|
||||
core.debug(` "branch" pattern matched`);
|
||||
return true;
|
||||
}
|
||||
|
||||
core.debug(` ${matcher} did not match`);
|
||||
return false;
|
||||
}
|
||||
353
src/changedFiles.ts
Normal file
353
src/changedFiles.ts
Normal file
@@ -0,0 +1,353 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import {Minimatch} from 'minimatch';
|
||||
|
||||
export interface ChangedFilesMatchConfig {
|
||||
changedFiles?: ChangedFilesGlobPatternsConfig[];
|
||||
}
|
||||
|
||||
interface ChangedFilesGlobPatternsConfig {
|
||||
AnyGlobToAnyFile?: string[];
|
||||
AnyGlobToAllFiles?: string[];
|
||||
AllGlobsToAnyFile?: string[];
|
||||
AllGlobsToAllFiles?: string[];
|
||||
}
|
||||
|
||||
type ClientType = ReturnType<typeof github.getOctokit>;
|
||||
|
||||
const ALLOWED_FILES_CONFIG_KEYS = [
|
||||
'AnyGlobToAnyFile',
|
||||
'AnyGlobToAllFiles',
|
||||
'AllGlobsToAnyFile',
|
||||
'AllGlobsToAllFiles'
|
||||
];
|
||||
|
||||
export async function getChangedFiles(
|
||||
client: ClientType,
|
||||
prNumber: number
|
||||
): Promise<string[]> {
|
||||
const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
pull_number: prNumber
|
||||
});
|
||||
|
||||
const listFilesResponse = await client.paginate(listFilesOptions);
|
||||
const changedFiles = listFilesResponse.map((f: any) => f.filename);
|
||||
|
||||
core.debug('found changed files:');
|
||||
for (const file of changedFiles) {
|
||||
core.debug(' ' + file);
|
||||
}
|
||||
|
||||
return changedFiles;
|
||||
}
|
||||
|
||||
export function toChangedFilesMatchConfig(
|
||||
config: any
|
||||
): ChangedFilesMatchConfig {
|
||||
if (!config['changed-files'] || !config['changed-files'].length) {
|
||||
return {};
|
||||
}
|
||||
const changedFilesConfigs = Array.isArray(config['changed-files'])
|
||||
? config['changed-files']
|
||||
: [config['changed-files']];
|
||||
|
||||
const validChangedFilesConfigs: ChangedFilesGlobPatternsConfig[] = [];
|
||||
|
||||
changedFilesConfigs.forEach(changedFilesConfig => {
|
||||
if (!isObject(changedFilesConfig)) {
|
||||
throw new Error(
|
||||
`The "changed-files" section must have a valid config structure. Please read the action documentation for more information`
|
||||
);
|
||||
}
|
||||
|
||||
const changedFilesConfigKeys = Object.keys(changedFilesConfig);
|
||||
const invalidKeys = changedFilesConfigKeys.filter(
|
||||
key => !ALLOWED_FILES_CONFIG_KEYS.includes(key)
|
||||
);
|
||||
|
||||
if (invalidKeys.length) {
|
||||
throw new Error(
|
||||
`Unknown config options were under "changed-files": ${invalidKeys.join(
|
||||
', '
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
changedFilesConfigKeys.forEach(key => {
|
||||
validChangedFilesConfigs.push({
|
||||
[key]: Array.isArray(changedFilesConfig[key])
|
||||
? changedFilesConfig[key]
|
||||
: [changedFilesConfig[key]]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
changedFiles: validChangedFilesConfigs
|
||||
};
|
||||
}
|
||||
|
||||
function isObject(obj: unknown): obj is object {
|
||||
return obj !== null && typeof obj === 'object' && !Array.isArray(obj);
|
||||
}
|
||||
|
||||
function printPattern(matcher: Minimatch): string {
|
||||
return (matcher.negate ? '!' : '') + matcher.pattern;
|
||||
}
|
||||
|
||||
export function checkAnyChangedFiles(
|
||||
changedFiles: string[],
|
||||
globPatternsConfigs: ChangedFilesGlobPatternsConfig[]
|
||||
): boolean {
|
||||
core.debug(` checking "changed-files" patterns`);
|
||||
|
||||
for (const globPatternsConfig of globPatternsConfigs) {
|
||||
if (globPatternsConfig.AnyGlobToAnyFile) {
|
||||
if (
|
||||
checkIfAnyGlobMatchesAnyFile(
|
||||
changedFiles,
|
||||
globPatternsConfig.AnyGlobToAnyFile
|
||||
)
|
||||
) {
|
||||
core.debug(` "changed-files" matched`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (globPatternsConfig.AnyGlobToAllFiles) {
|
||||
if (
|
||||
checkIfAnyGlobMatchesAllFiles(
|
||||
changedFiles,
|
||||
globPatternsConfig.AnyGlobToAllFiles
|
||||
)
|
||||
) {
|
||||
core.debug(` "changed-files" matched`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (globPatternsConfig.AllGlobsToAnyFile) {
|
||||
if (
|
||||
checkIfAllGlobsMatchAnyFile(
|
||||
changedFiles,
|
||||
globPatternsConfig.AllGlobsToAnyFile
|
||||
)
|
||||
) {
|
||||
core.debug(` "changed-files" matched`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (globPatternsConfig.AllGlobsToAllFiles) {
|
||||
if (
|
||||
checkIfAllGlobsMatchAllFiles(
|
||||
changedFiles,
|
||||
globPatternsConfig.AllGlobsToAllFiles
|
||||
)
|
||||
) {
|
||||
core.debug(` "changed-files" matched`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` "changed-files" did not match`);
|
||||
return false;
|
||||
}
|
||||
|
||||
export function checkAllChangedFiles(
|
||||
changedFiles: string[],
|
||||
globPatternsConfigs: ChangedFilesGlobPatternsConfig[]
|
||||
): boolean {
|
||||
core.debug(` checking "changed-files" patterns`);
|
||||
|
||||
for (const globPatternsConfig of globPatternsConfigs) {
|
||||
if (globPatternsConfig.AnyGlobToAnyFile) {
|
||||
if (
|
||||
!checkIfAnyGlobMatchesAnyFile(
|
||||
changedFiles,
|
||||
globPatternsConfig.AnyGlobToAnyFile
|
||||
)
|
||||
) {
|
||||
core.debug(` "changed-files" did not match`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (globPatternsConfig.AnyGlobToAllFiles) {
|
||||
if (
|
||||
!checkIfAnyGlobMatchesAllFiles(
|
||||
changedFiles,
|
||||
globPatternsConfig.AnyGlobToAllFiles
|
||||
)
|
||||
) {
|
||||
core.debug(` "changed-files" did not match`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (globPatternsConfig.AllGlobsToAnyFile) {
|
||||
if (
|
||||
!checkIfAllGlobsMatchAnyFile(
|
||||
changedFiles,
|
||||
globPatternsConfig.AllGlobsToAnyFile
|
||||
)
|
||||
) {
|
||||
core.debug(` "changed-files" did not match`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (globPatternsConfig.AllGlobsToAllFiles) {
|
||||
if (
|
||||
!checkIfAllGlobsMatchAllFiles(
|
||||
changedFiles,
|
||||
globPatternsConfig.AllGlobsToAllFiles
|
||||
)
|
||||
) {
|
||||
core.debug(` "changed-files" did not match`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` "changed-files" patterns matched`);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function checkIfAnyGlobMatchesAnyFile(
|
||||
changedFiles: string[],
|
||||
globs: string[]
|
||||
): boolean {
|
||||
core.debug(` checking "AnyGlobToAnyFile" config patterns`);
|
||||
const matchers = globs.map(g => new Minimatch(g));
|
||||
|
||||
for (const matcher of matchers) {
|
||||
const matchedFile = changedFiles.find(changedFile => {
|
||||
core.debug(
|
||||
` checking "${printPattern(
|
||||
matcher
|
||||
)}" pattern against ${changedFile}`
|
||||
);
|
||||
|
||||
return matcher.match(changedFile);
|
||||
});
|
||||
|
||||
if (matchedFile) {
|
||||
core.debug(
|
||||
` "${printPattern(matcher)}" pattern matched ${matchedFile}`
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` none of the patterns matched any of the files`);
|
||||
return false;
|
||||
}
|
||||
|
||||
export function checkIfAllGlobsMatchAnyFile(
|
||||
changedFiles: string[],
|
||||
globs: string[]
|
||||
): boolean {
|
||||
core.debug(` checking "AllGlobsToAnyFile" config patterns`);
|
||||
const matchers = globs.map(g => new Minimatch(g));
|
||||
|
||||
for (const changedFile of changedFiles) {
|
||||
const mismatchedGlob = matchers.find(matcher => {
|
||||
core.debug(
|
||||
` checking "${printPattern(
|
||||
matcher
|
||||
)}" pattern against ${changedFile}`
|
||||
);
|
||||
|
||||
return !matcher.match(changedFile);
|
||||
});
|
||||
|
||||
if (mismatchedGlob) {
|
||||
core.debug(
|
||||
` "${printPattern(
|
||||
mismatchedGlob
|
||||
)}" pattern did not match ${changedFile}`
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
core.debug(` all patterns matched ${changedFile}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
core.debug(` none of the files matched all patterns`);
|
||||
return false;
|
||||
}
|
||||
|
||||
export function checkIfAnyGlobMatchesAllFiles(
|
||||
changedFiles: string[],
|
||||
globs: string[]
|
||||
): boolean {
|
||||
core.debug(` checking "AnyGlobToAllFiles" config patterns`);
|
||||
const matchers = globs.map(g => new Minimatch(g));
|
||||
|
||||
for (const matcher of matchers) {
|
||||
const mismatchedFile = changedFiles.find(changedFile => {
|
||||
core.debug(
|
||||
` checking "${printPattern(
|
||||
matcher
|
||||
)}" pattern against ${changedFile}`
|
||||
);
|
||||
|
||||
return !matcher.match(changedFile);
|
||||
});
|
||||
|
||||
if (mismatchedFile) {
|
||||
core.debug(
|
||||
` "${printPattern(
|
||||
matcher
|
||||
)}" pattern did not match ${mismatchedFile}`
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
core.debug(` "${printPattern(matcher)}" pattern matched all files`);
|
||||
return true;
|
||||
}
|
||||
|
||||
core.debug(` none of the patterns matched all files`);
|
||||
return false;
|
||||
}
|
||||
|
||||
export function checkIfAllGlobsMatchAllFiles(
|
||||
changedFiles: string[],
|
||||
globs: string[]
|
||||
): boolean {
|
||||
core.debug(` checking "AllGlobsToAllFiles" config patterns`);
|
||||
const matchers = globs.map(g => new Minimatch(g));
|
||||
|
||||
for (const changedFile of changedFiles) {
|
||||
const mismatchedGlob = matchers.find(matcher => {
|
||||
core.debug(
|
||||
` checking "${printPattern(
|
||||
matcher
|
||||
)}" pattern against ${changedFile}`
|
||||
);
|
||||
|
||||
return !matcher.match(changedFile);
|
||||
});
|
||||
|
||||
if (mismatchedGlob) {
|
||||
core.debug(
|
||||
` "${printPattern(
|
||||
mismatchedGlob
|
||||
)}" pattern did not match ${changedFile}`
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` all patterns matched all files`);
|
||||
return true;
|
||||
}
|
||||
437
src/labeler.ts
437
src/labeler.ts
@@ -1,113 +1,76 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import * as pluginRetry from '@octokit/plugin-retry';
|
||||
import * as yaml from 'js-yaml';
|
||||
import fs from 'fs';
|
||||
import {Minimatch} from 'minimatch';
|
||||
|
||||
interface MatchConfig {
|
||||
all?: string[];
|
||||
any?: string[];
|
||||
}
|
||||
import {
|
||||
ChangedFilesMatchConfig,
|
||||
getChangedFiles,
|
||||
toChangedFilesMatchConfig,
|
||||
checkAllChangedFiles,
|
||||
checkAnyChangedFiles
|
||||
} from './changedFiles';
|
||||
import {
|
||||
checkAnyBranch,
|
||||
checkAllBranch,
|
||||
toBranchMatchConfig,
|
||||
BranchMatchConfig
|
||||
} from './branch';
|
||||
|
||||
export type BaseMatchConfig = BranchMatchConfig & ChangedFilesMatchConfig;
|
||||
|
||||
export type MatchConfig = {
|
||||
any?: BaseMatchConfig[];
|
||||
all?: BaseMatchConfig[];
|
||||
};
|
||||
|
||||
type StringOrMatchConfig = string | MatchConfig;
|
||||
type ClientType = ReturnType<typeof github.getOctokit>;
|
||||
|
||||
// GitHub Issues cannot have more than 100 labels
|
||||
const GITHUB_MAX_LABELS = 100;
|
||||
const ALLOWED_CONFIG_KEYS = ['changed-files', 'head-branch', 'base-branch'];
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
const token = core.getInput('repo-token');
|
||||
const configPath = core.getInput('configuration-path', {required: true});
|
||||
const syncLabels = !!core.getInput('sync-labels');
|
||||
const dot = core.getBooleanInput('dot');
|
||||
const syncLabels = core.getBooleanInput('sync-labels');
|
||||
|
||||
const prNumbers = getPrNumbers();
|
||||
if (!prNumbers.length) {
|
||||
core.warning('Could not get pull request number(s), exiting');
|
||||
const prNumber = getPrNumber();
|
||||
if (!prNumber) {
|
||||
core.info('Could not get pull request number from context, exiting');
|
||||
return;
|
||||
}
|
||||
|
||||
const client: ClientType = github.getOctokit(token, {}, pluginRetry.retry);
|
||||
const client: ClientType = github.getOctokit(token);
|
||||
|
||||
for (const prNumber of prNumbers) {
|
||||
core.debug(`looking for pr #${prNumber}`);
|
||||
let pullRequest: any;
|
||||
try {
|
||||
const result = await client.rest.pulls.get({
|
||||
const {data: pullRequest} = await client.rest.pulls.get({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
pull_number: prNumber
|
||||
});
|
||||
pullRequest = result.data;
|
||||
} catch (error: any) {
|
||||
core.warning(`Could not find pull request #${prNumber}, skipping`);
|
||||
continue;
|
||||
}
|
||||
|
||||
core.debug(`fetching changed files for pr #${prNumber}`);
|
||||
const changedFiles: string[] = await getChangedFiles(client, prNumber);
|
||||
if (!changedFiles.length) {
|
||||
core.warning(
|
||||
`Pull request #${prNumber} has no changed files, skipping`
|
||||
const labelConfigs: Map<string, MatchConfig[]> = await getMatchConfigs(
|
||||
client,
|
||||
configPath
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
const labelGlobs: Map<string, StringOrMatchConfig[]> =
|
||||
await getLabelGlobs(client, configPath);
|
||||
|
||||
const preexistingLabels = pullRequest.labels.map(l => l.name);
|
||||
const allLabels: Set<string> = new Set<string>(preexistingLabels);
|
||||
|
||||
for (const [label, globs] of labelGlobs.entries()) {
|
||||
const labels: string[] = [];
|
||||
const labelsToRemove: string[] = [];
|
||||
for (const [label, configs] of labelConfigs.entries()) {
|
||||
core.debug(`processing ${label}`);
|
||||
if (checkGlobs(changedFiles, globs, dot)) {
|
||||
allLabels.add(label);
|
||||
} else if (syncLabels) {
|
||||
allLabels.delete(label);
|
||||
if (checkMatchConfigs(changedFiles, configs)) {
|
||||
labels.push(label);
|
||||
} else if (pullRequest.labels.find(l => l.name === label)) {
|
||||
labelsToRemove.push(label);
|
||||
}
|
||||
}
|
||||
|
||||
const labelsToAdd = [...allLabels].slice(0, GITHUB_MAX_LABELS);
|
||||
const excessLabels = [...allLabels].slice(GITHUB_MAX_LABELS);
|
||||
|
||||
try {
|
||||
let newLabels: string[] = [];
|
||||
|
||||
if (!isListEqual(labelsToAdd, preexistingLabels)) {
|
||||
await setLabels(client, prNumber, labelsToAdd);
|
||||
newLabels = labelsToAdd.filter(l => !preexistingLabels.includes(l));
|
||||
if (labels.length > 0) {
|
||||
await addLabels(client, prNumber, labels);
|
||||
}
|
||||
|
||||
core.setOutput('new-labels', newLabels.join(','));
|
||||
core.setOutput('all-labels', labelsToAdd.join(','));
|
||||
|
||||
if (excessLabels.length) {
|
||||
core.warning(
|
||||
`Maximum of ${GITHUB_MAX_LABELS} labels allowed. Excess labels: ${excessLabels.join(
|
||||
', '
|
||||
)}`,
|
||||
{title: 'Label limit for a PR exceeded'}
|
||||
);
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (
|
||||
error.name === 'HttpError' &&
|
||||
error.message === 'Resource not accessible by integration'
|
||||
) {
|
||||
core.warning(
|
||||
`The action requires write permission to add labels to pull requests. For more information please refer to the action documentation: https://github.com/actions/labeler#permissions`,
|
||||
{
|
||||
title: `${process.env['GITHUB_ACTION_REPOSITORY']} running under '${github.context.eventName}' is misconfigured`
|
||||
}
|
||||
);
|
||||
core.setFailed(error.message);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
if (syncLabels && labelsToRemove.length) {
|
||||
await removeLabels(client, prNumber, labelsToRemove);
|
||||
}
|
||||
} catch (error: any) {
|
||||
core.error(error);
|
||||
@@ -115,85 +78,29 @@ export async function run() {
|
||||
}
|
||||
}
|
||||
|
||||
function getPrNumbers(): number[] {
|
||||
const pullRequestNumbers = core.getMultilineInput('pr-number');
|
||||
if (pullRequestNumbers && pullRequestNumbers.length) {
|
||||
const prNumbers: number[] = [];
|
||||
|
||||
for (const prNumber of pullRequestNumbers) {
|
||||
const prNumberInt = parseInt(prNumber, 10);
|
||||
if (isNaN(prNumberInt) || prNumberInt <= 0) {
|
||||
core.warning(`'${prNumber}' is not a valid pull request number`);
|
||||
} else {
|
||||
prNumbers.push(prNumberInt);
|
||||
}
|
||||
}
|
||||
|
||||
return prNumbers;
|
||||
}
|
||||
|
||||
function getPrNumber(): number | undefined {
|
||||
const pullRequest = github.context.payload.pull_request;
|
||||
if (!pullRequest) {
|
||||
return [];
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return [pullRequest.number];
|
||||
return pullRequest.number;
|
||||
}
|
||||
|
||||
async function getChangedFiles(
|
||||
client: ClientType,
|
||||
prNumber: number
|
||||
): Promise<string[]> {
|
||||
const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
pull_number: prNumber
|
||||
});
|
||||
|
||||
const listFilesResponse = await client.paginate(listFilesOptions);
|
||||
const changedFiles = listFilesResponse.map((f: any) => f.filename);
|
||||
|
||||
core.debug('found changed files:');
|
||||
for (const file of changedFiles) {
|
||||
core.debug(' ' + file);
|
||||
}
|
||||
|
||||
return changedFiles;
|
||||
}
|
||||
|
||||
async function getLabelGlobs(
|
||||
async function getMatchConfigs(
|
||||
client: ClientType,
|
||||
configurationPath: string
|
||||
): Promise<Map<string, StringOrMatchConfig[]>> {
|
||||
let configurationContent: string;
|
||||
try {
|
||||
if (!fs.existsSync(configurationPath)) {
|
||||
core.info(
|
||||
`The configuration file (path: ${configurationPath}) isn't not found locally, fetching via the api`
|
||||
): Promise<Map<string, MatchConfig[]>> {
|
||||
const configurationContent: string = await fetchContent(
|
||||
client,
|
||||
configurationPath
|
||||
);
|
||||
configurationContent = await fetchContent(client, configurationPath);
|
||||
} else {
|
||||
core.info(
|
||||
`The configuration file (path: ${configurationPath}) is found locally, reading from the file`
|
||||
);
|
||||
configurationContent = fs.readFileSync(configurationPath, {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (e.name == 'HttpError' || e.name == 'NotFound') {
|
||||
core.warning(
|
||||
`The config file was not found at ${configurationPath}. Make sure it exists and that this action has the correct access rights.`
|
||||
);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
// loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`:
|
||||
// loads (hopefully) a `{[label:string]: MatchConfig[]}`, but is `any`:
|
||||
const configObject: any = yaml.load(configurationContent);
|
||||
|
||||
// transform `any` => `Map<string,StringOrMatchConfig[]>` or throw if yaml is malformed:
|
||||
return getLabelGlobMapFromObject(configObject);
|
||||
// transform `any` => `Map<string,MatchConfig[]>` or throw if yaml is malformed:
|
||||
return getLabelConfigMapFromObject(configObject);
|
||||
}
|
||||
|
||||
async function fetchContent(
|
||||
@@ -210,139 +117,221 @@ async function fetchContent(
|
||||
return Buffer.from(response.data.content, response.data.encoding).toString();
|
||||
}
|
||||
|
||||
function getLabelGlobMapFromObject(
|
||||
export function getLabelConfigMapFromObject(
|
||||
configObject: any
|
||||
): Map<string, StringOrMatchConfig[]> {
|
||||
const labelGlobs: Map<string, StringOrMatchConfig[]> = new Map();
|
||||
): Map<string, MatchConfig[]> {
|
||||
const labelMap: Map<string, MatchConfig[]> = new Map();
|
||||
for (const label in configObject) {
|
||||
if (typeof configObject[label] === 'string') {
|
||||
labelGlobs.set(label, [configObject[label]]);
|
||||
} else if (configObject[label] instanceof Array) {
|
||||
labelGlobs.set(label, configObject[label]);
|
||||
} else {
|
||||
const configOptions = configObject[label];
|
||||
if (
|
||||
!Array.isArray(configOptions) ||
|
||||
!configOptions.every(opts => typeof opts === 'object')
|
||||
) {
|
||||
throw Error(
|
||||
`found unexpected type for label ${label} (should be string or array of globs)`
|
||||
`found unexpected type for label '${label}' (should be array of config options)`
|
||||
);
|
||||
}
|
||||
const matchConfigs = configOptions.reduce<MatchConfig[]>(
|
||||
(updatedConfig, configValue) => {
|
||||
if (!configValue) {
|
||||
return updatedConfig;
|
||||
}
|
||||
|
||||
return labelGlobs;
|
||||
Object.entries(configValue).forEach(([key, value]) => {
|
||||
// If the top level `any` or `all` keys are provided then set them, and convert their values to
|
||||
// our config objects.
|
||||
if (key === 'any' || key === 'all') {
|
||||
if (Array.isArray(value)) {
|
||||
const newConfigs = value.map(toMatchConfig);
|
||||
updatedConfig.push({[key]: newConfigs});
|
||||
}
|
||||
} else if (ALLOWED_CONFIG_KEYS.includes(key)) {
|
||||
const newMatchConfig = toMatchConfig({[key]: value});
|
||||
// Find or set the `any` key so that we can add these properties to that rule,
|
||||
// Or create a new `any` key and add that to our array of configs.
|
||||
const indexOfAny = updatedConfig.findIndex(mc => !!mc['any']);
|
||||
if (indexOfAny >= 0) {
|
||||
updatedConfig[indexOfAny].any?.push(newMatchConfig);
|
||||
} else {
|
||||
updatedConfig.push({any: [newMatchConfig]});
|
||||
}
|
||||
} else {
|
||||
// Log the key that we don't know what to do with.
|
||||
core.info(`An unknown config option was under ${label}: ${key}`);
|
||||
}
|
||||
});
|
||||
|
||||
return updatedConfig;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
if (matchConfigs.length) {
|
||||
labelMap.set(label, matchConfigs);
|
||||
}
|
||||
}
|
||||
|
||||
function toMatchConfig(config: StringOrMatchConfig): MatchConfig {
|
||||
if (typeof config === 'string') {
|
||||
return labelMap;
|
||||
}
|
||||
|
||||
export function toMatchConfig(config: any): BaseMatchConfig {
|
||||
const changedFilesConfig = toChangedFilesMatchConfig(config);
|
||||
const branchConfig = toBranchMatchConfig(config);
|
||||
|
||||
return {
|
||||
any: [config]
|
||||
...changedFilesConfig,
|
||||
...branchConfig
|
||||
};
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
function printPattern(matcher: Minimatch): string {
|
||||
return (matcher.negate ? '!' : '') + matcher.pattern;
|
||||
}
|
||||
|
||||
export function checkGlobs(
|
||||
export function checkMatchConfigs(
|
||||
changedFiles: string[],
|
||||
globs: StringOrMatchConfig[],
|
||||
dot: boolean
|
||||
matchConfigs: MatchConfig[]
|
||||
): boolean {
|
||||
for (const glob of globs) {
|
||||
core.debug(` checking pattern ${JSON.stringify(glob)}`);
|
||||
const matchConfig = toMatchConfig(glob);
|
||||
if (checkMatch(changedFiles, matchConfig, dot)) {
|
||||
for (const config of matchConfigs) {
|
||||
core.debug(` checking config ${JSON.stringify(config)}`);
|
||||
if (!checkMatch(changedFiles, config)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function checkMatch(changedFiles: string[], matchConfig: MatchConfig): boolean {
|
||||
if (!Object.keys(matchConfig).length) {
|
||||
core.debug(` no "any" or "all" patterns to check`);
|
||||
return false;
|
||||
}
|
||||
|
||||
function isMatch(changedFile: string, matchers: Minimatch[]): boolean {
|
||||
core.debug(` matching patterns against file ${changedFile}`);
|
||||
for (const matcher of matchers) {
|
||||
core.debug(` - ${printPattern(matcher)}`);
|
||||
if (!matcher.match(changedFile)) {
|
||||
core.debug(` ${printPattern(matcher)} did not match`);
|
||||
if (matchConfig.all) {
|
||||
if (!checkAll(matchConfig.all, changedFiles)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchConfig.any) {
|
||||
if (!checkAny(matchConfig.any, changedFiles)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` all patterns matched`);
|
||||
return true;
|
||||
}
|
||||
|
||||
// equivalent to "Array.some()" but expanded for debugging and clarity
|
||||
function checkAny(
|
||||
changedFiles: string[],
|
||||
globs: string[],
|
||||
dot: boolean
|
||||
export function checkAny(
|
||||
matchConfigs: BaseMatchConfig[],
|
||||
changedFiles: string[]
|
||||
): boolean {
|
||||
const matchers = globs.map(g => new Minimatch(g, {dot}));
|
||||
core.debug(` checking "any" patterns`);
|
||||
for (const changedFile of changedFiles) {
|
||||
if (isMatch(changedFile, matchers)) {
|
||||
core.debug(` "any" patterns matched against ${changedFile}`);
|
||||
if (
|
||||
!matchConfigs.length ||
|
||||
!matchConfigs.some(configOption => Object.keys(configOption).length)
|
||||
) {
|
||||
core.debug(` no "any" patterns to check`);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const matchConfig of matchConfigs) {
|
||||
if (matchConfig.baseBranch) {
|
||||
if (checkAnyBranch(matchConfig.baseBranch, 'base')) {
|
||||
core.debug(` "any" patterns matched`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` "any" patterns did not match any files`);
|
||||
if (matchConfig.changedFiles) {
|
||||
if (checkAnyChangedFiles(changedFiles, matchConfig.changedFiles)) {
|
||||
core.debug(` "any" patterns matched`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchConfig.headBranch) {
|
||||
if (checkAnyBranch(matchConfig.headBranch, 'head')) {
|
||||
core.debug(` "any" patterns matched`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` "any" patterns did not match any configs`);
|
||||
return false;
|
||||
}
|
||||
|
||||
// equivalent to "Array.every()" but expanded for debugging and clarity
|
||||
function checkAll(
|
||||
changedFiles: string[],
|
||||
globs: string[],
|
||||
dot: boolean
|
||||
export function checkAll(
|
||||
matchConfigs: BaseMatchConfig[],
|
||||
changedFiles: string[]
|
||||
): boolean {
|
||||
const matchers = globs.map(g => new Minimatch(g, {dot}));
|
||||
core.debug(` checking "all" patterns`);
|
||||
for (const changedFile of changedFiles) {
|
||||
if (!isMatch(changedFile, matchers)) {
|
||||
core.debug(` "all" patterns did not match against ${changedFile}`);
|
||||
if (
|
||||
!matchConfigs.length ||
|
||||
!matchConfigs.some(configOption => Object.keys(configOption).length)
|
||||
) {
|
||||
core.debug(` no "all" patterns to check`);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const matchConfig of matchConfigs) {
|
||||
if (matchConfig.baseBranch) {
|
||||
if (!checkAllBranch(matchConfig.baseBranch, 'base')) {
|
||||
core.debug(` "all" patterns did not match`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` "all" patterns matched all files`);
|
||||
if (matchConfig.changedFiles) {
|
||||
if (!changedFiles.length) {
|
||||
core.debug(` no files to check "changed-files" patterns against`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checkAllChangedFiles(changedFiles, matchConfig.changedFiles)) {
|
||||
core.debug(` "all" patterns did not match`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchConfig.headBranch) {
|
||||
if (!checkAllBranch(matchConfig.headBranch, 'head')) {
|
||||
core.debug(` "all" patterns did not match`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(` "all" patterns matched all configs`);
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkMatch(
|
||||
changedFiles: string[],
|
||||
matchConfig: MatchConfig,
|
||||
dot: boolean
|
||||
): boolean {
|
||||
if (matchConfig.all !== undefined) {
|
||||
if (!checkAll(changedFiles, matchConfig.all, dot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchConfig.any !== undefined) {
|
||||
if (!checkAny(changedFiles, matchConfig.any, dot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function isListEqual(listA: string[], listB: string[]): boolean {
|
||||
return listA.length === listB.length && listA.every(el => listB.includes(el));
|
||||
}
|
||||
|
||||
async function setLabels(
|
||||
async function addLabels(
|
||||
client: ClientType,
|
||||
prNumber: number,
|
||||
labels: string[]
|
||||
) {
|
||||
await client.rest.issues.setLabels({
|
||||
await client.rest.issues.addLabels({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
labels: labels
|
||||
});
|
||||
}
|
||||
|
||||
async function removeLabels(
|
||||
client: ClientType,
|
||||
prNumber: number,
|
||||
labels: string[]
|
||||
) {
|
||||
await Promise.all(
|
||||
labels.map(label =>
|
||||
client.rest.issues.removeLabel({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
name: label
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user