Compare commits

..

1 Commits

Author SHA1 Message Date
Evgenii Korolevskii
4b5a5f236d Update CODEOWNERS 2022-12-23 00:00:24 +01:00
37 changed files with 3659 additions and 5772 deletions

View File

@@ -1,7 +0,0 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!__mocks__/
!src/

View File

@@ -1,50 +0,0 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-plugin-jest/recommended',
'eslint-config-prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-jest'],
rules: {
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
'yoda': 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}]
},
overrides: [
{
files: ['**/*{test,spec}.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'jest/no-standalone-expect': 'off',
'jest/no-conditional-expect': 'off',
'no-console': 'off',
}
}
],
env: {
node: true,
es6: true,
'jest/globals': true
}
};

2
.gitattributes vendored
View File

@@ -1,4 +1,4 @@
* text=auto eol=lf
* text=auto
.licenses/** -diff linguist-generated=true
# don't diff machine generated files

View File

@@ -1 +1 @@
blank_issues_enabled: false
blank_issues_enabled: false

View File

@@ -14,4 +14,4 @@ on:
jobs:
call-basic-validation:
name: Basic validation
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main

View File

@@ -14,4 +14,4 @@ on:
jobs:
call-check-dist:
name: Check dist/
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main

View File

@@ -2,13 +2,13 @@ name: CodeQL analysis
on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]
schedule:
- cron: '0 3 * * 0'
jobs:
call-codeQL-analysis:
name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main

View File

@@ -12,4 +12,4 @@ on:
jobs:
call-licensed:
name: Licensed
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main

View File

@@ -21,8 +21,8 @@ jobs:
name: releaseNewActionVersion
runs-on: ubuntu-latest
steps:
- name: Update the ${{ env.TAG_NAME }} tag
uses: actions/publish-action@v0.2.2
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
- name: Update the ${{ env.TAG_NAME }} tag
uses: actions/publish-action@v0.2.1
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View File

@@ -1,11 +0,0 @@
name: Update configuration files
on:
schedule:
- cron: '0 3 * * 0'
workflow_dispatch:
jobs:
call-update-configuration-files:
name: Update configuration files
uses: actions/reusable-workflows/.github/workflows/update-config-files.yml@main

View File

@@ -1,6 +1,6 @@
---
name: "@actions/github"
version: 5.1.1
version: 5.0.0
type: npm
summary: Actions github lib
homepage: https://github.com/actions/toolkit/tree/main/packages/github

View File

@@ -0,0 +1,32 @@
---
name: "@actions/http-client"
version: 1.0.11
type: npm
summary: Actions Http Client
homepage: https://github.com/actions/http-client#readme
license: mit
licenses:
- sources: LICENSE
text: |
Actions Http Client for Node.js
Copyright (c) GitHub, Inc.
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
notices: []

View File

@@ -1,9 +1,9 @@
---
name: "@octokit/auth-token"
version: 2.5.0
version: 2.4.5
type: npm
summary: GitHub API token authentication for browsers and Node.js
homepage:
homepage: https://github.com/octokit/auth-token.js#readme
license: mit
licenses:
- sources: LICENSE

View File

@@ -1,6 +1,6 @@
---
name: "@octokit/core"
version: 3.6.0
version: 3.5.1
type: npm
summary: Extendable client for GitHub's REST & GraphQL APIs
homepage:

View File

@@ -1,6 +1,6 @@
---
name: "@octokit/graphql"
version: 4.8.0
version: 4.6.4
type: npm
summary: GitHub GraphQL API client for browsers and Node
homepage:

View File

@@ -1,8 +1,8 @@
---
name: "@octokit/openapi-types"
version: 12.11.0
version: 7.3.2
type: npm
summary: Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com
summary: Generated TypeScript definitions based on GitHub's OpenAPI spec
homepage:
license: mit
licenses:

View File

@@ -1,6 +1,6 @@
---
name: "@octokit/plugin-paginate-rest"
version: 2.21.3
version: 2.13.5
type: npm
summary: Octokit plugin to paginate REST API endpoint responses
homepage:

View File

@@ -1,6 +1,6 @@
---
name: "@octokit/plugin-rest-endpoint-methods"
version: 5.16.2
version: 5.3.1
type: npm
summary: Octokit plugin adding one method for all of api.github.com REST API endpoints
homepage:

View File

@@ -1,9 +1,9 @@
---
name: "@octokit/request"
version: 5.6.3
version: 5.6.0
type: npm
summary: Send parameterized requests to GitHub's APIs with sensible defaults in browsers
and Node
summary: "Send parameterized requests to GitHubâ\x80\x99s APIs with sensible defaults
in browsers and Node"
homepage:
license: mit
licenses:

View File

@@ -1,6 +1,6 @@
---
name: "@octokit/types"
version: 6.41.0
version: 6.16.4
type: npm
summary: Shared TypeScript definitions for Octokit projects
homepage:

View File

@@ -1,6 +1,6 @@
---
name: balanced-match
version: 1.0.2
version: 1.0.0
type: npm
summary: Match balanced character pairs, like "{" and "}"
homepage: https://github.com/juliangruber/balanced-match

View File

@@ -1,6 +1,6 @@
---
name: before-after-hook
version: 2.2.3
version: 2.2.2
type: npm
summary: asynchronous before/error/after hooks for internal functionality
homepage:

View File

@@ -1,6 +1,6 @@
---
name: brace-expansion
version: 2.0.1
version: 1.1.11
type: npm
summary: Brace expansion as known from sh/bash
homepage: https://github.com/juliangruber/brace-expansion

31
.licenses/npm/concat-map.dep.yml generated Normal file
View File

@@ -0,0 +1,31 @@
---
name: concat-map
version: 0.0.1
type: npm
summary: concatenative mapdashery
homepage:
license: other
licenses:
- sources: LICENSE
text: |
This software is released under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- sources: README.markdown
text: MIT
notices: []

View File

@@ -1,6 +1,6 @@
---
name: minimatch
version: 7.4.3
version: 3.1.2
type: npm
summary: a glob matcher in javascript
homepage:
@@ -10,7 +10,7 @@ licenses:
text: |
The ISC License
Copyright (c) 2011-2022 Isaac Z. Schlueter and Contributors
Copyright (c) Isaac Z. Schlueter 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

View File

@@ -1,8 +0,0 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!__mocks__/
!.github/
!src/

View File

@@ -1,11 +0,0 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
module.exports = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
};

12
.prettierrc.json Normal file
View File

@@ -0,0 +1,12 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript",
"endOfLine": "auto"
}

View File

@@ -1 +1,3 @@
* @actions/setup-actions-team
* @actions/actions-runtime
* @actions/runner-images-team

View File

@@ -1,6 +1,13 @@
# Pull Request Labeler
[![Basic validation](https://github.com/actions/labeler/actions/workflows/basic-validation.yml/badge.svg?branch=main)](https://github.com/actions/labeler/actions/workflows/basic-validation.yml)
<p align="left">
<a href="https://github.com/actions/labeler/actions?query=workflow%3A%22Build+%26+Test%22++">
<img alt="build and test status" src="https://github.com/actions/labeler/actions/workflows/build_test.yml/badge.svg">
</a>
<a href="https://david-dm.org/actions/labeler">
<img alt="dependencies" src="https://status.david-dm.org/gh/actions/labeler.svg">
</a>
</p>
Automatically label new pull requests based on the paths of files being changed.
@@ -99,17 +106,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
```
_Note: This grants access to the `GITHUB_TOKEN` so the action can make calls to GitHub's rest API_
#### Inputs
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, with `contents:read` and `pull-requests:write` access | `github.token` |
| `repo-token` | Token to use to authorize label changes. Typically the GITHUB_TOKEN secret, with `contents:read` and `pull-requests:write` access | N/A |
| `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`|
| `sync-labels` | Whether or not to remove labels when matching files are reverted or no longer changed by the PR | `false`
# Contributions

View File

@@ -48,7 +48,7 @@ describe('run', () => {
});
it('(with sync-labels: true) it deletes preexisting PR labels that no longer match the glob pattern', async () => {
const mockInput = {
let mockInput = {
'repo-token': 'foo',
'configuration-path': 'bar',
'sync-labels': true
@@ -79,7 +79,7 @@ describe('run', () => {
});
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 () => {
const mockInput = {
let mockInput = {
'repo-token': 'foo',
'configuration-path': 'bar',
'sync-labels': false

View File

@@ -3,9 +3,7 @@ description: 'Automatically label new pull requests based on the paths of files
author: 'GitHub'
inputs:
repo-token:
description: 'The GitHub token used to manage labels'
required: false
default: ${{ github.token }}
description: 'The GITHUB_TOKEN secret'
configuration-path:
description: 'The path for the label configurations'
default: '.github/labeler.yml'

4654
dist/index.js vendored

File diff suppressed because one or more lines are too long

4486
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,10 +5,9 @@
"main": "lib/main.js",
"scripts": {
"build": "tsc && ncc build lib/main.js",
"format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"",
"format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check \"**/*.{ts,yml,yaml}\"",
"lint": "eslint --config ./.eslintrc.js \"**/*.ts\"",
"lint:fix": "eslint --config ./.eslintrc.js \"**/*.ts\" --fix",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "echo \"Fake command that does nothing. It is used in reusable workflows\"",
"test": "jest"
},
"repository": {
@@ -25,24 +24,19 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@actions/github": "^5.0.0",
"js-yaml": "^4.1.0",
"minimatch": "^7.4.3"
"minimatch": "^3.0.4"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/js-yaml": "^4.0.5",
"@types/minimatch": "^5.1.2",
"@types/node": "^16.11.7",
"@typescript-eslint/eslint-plugin": "^5.59.5",
"@typescript-eslint/parser": "^5.59.5",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-jest": "^27.2.1",
"@types/minimatch": "^3.0.5",
"@types/js-yaml": "^4.0.5",
"@vercel/ncc": "^0.34.0",
"jest": "^27.5.1",
"prettier": "^2.8.8",
"prettier": "^2.7.1",
"ts-jest": "^27.1.3",
"typescript": "^4.9.5"
"typescript": "^4.8.4"
}
}

View File

@@ -1,7 +1,7 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import * as yaml from 'js-yaml';
import {Minimatch} from 'minimatch';
import {Minimatch, IMinimatch} from 'minimatch';
interface MatchConfig {
all?: string[];
@@ -13,13 +13,13 @@ type ClientType = ReturnType<typeof github.getOctokit>;
export async function run() {
try {
const token = core.getInput('repo-token');
const token = core.getInput('repo-token', {required: true});
const configPath = core.getInput('configuration-path', {required: true});
const syncLabels = !!core.getInput('sync-labels', {required: false});
const prNumber = getPrNumber();
if (!prNumber) {
core.info('Could not get pull request number from context, exiting');
console.log('Could not get pull request number from context, exiting');
return;
}
@@ -151,7 +151,7 @@ function toMatchConfig(config: StringOrMatchConfig): MatchConfig {
return config;
}
function printPattern(matcher: Minimatch): string {
function printPattern(matcher: IMinimatch): string {
return (matcher.negate ? '!' : '') + matcher.pattern;
}
@@ -169,7 +169,7 @@ export function checkGlobs(
return false;
}
function isMatch(changedFile: string, matchers: Minimatch[]): boolean {
function isMatch(changedFile: string, matchers: IMinimatch[]): boolean {
core.debug(` matching patterns against file ${changedFile}`);
for (const matcher of matchers) {
core.debug(` - ${printPattern(matcher)}`);