Merge branch 'main' into dot-option

This commit is contained in:
Alexander Kachkaev
2023-03-12 22:13:26 +00:00
committed by GitHub
19 changed files with 2284 additions and 75 deletions

7
.eslintignore Normal file
View File

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

49
.eslintrc.js Normal file
View File

@@ -0,0 +1,49 @@
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
* text=auto eol=lf
.licenses/** -diff linguist-generated=true
# don't diff machine generated files

View File

@@ -2,9 +2,9 @@ name: CodeQL analysis
on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
schedule:
- cron: '0 3 * * 0'

View File

@@ -0,0 +1,11 @@
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

8
.prettierignore Normal file
View File

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

10
.prettierrc.js Normal file
View File

@@ -0,0 +1,10 @@
module.exports = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
};

View File

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

View File

@@ -1,13 +1,6 @@
# Pull Request Labeler
<p align="left">
<a href="https://github.com/actions/labeler/actions/workflows/basic-validation.yml">
<img alt="basic validation status" src="https://github.com/actions/labeler/actions/workflows/basic-validation.yml/badge.svg">
</a>
<a href="https://libraries.io/github/actions/labeler">
<img alt="dependencies" src="https://img.shields.io/librariesio/github/actions/labeler">
</a>
</p>
[![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)
Automatically label new pull requests based on the paths of files being changed.
@@ -110,22 +103,18 @@ 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 | N/A |
| `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`
| `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` |
When `dot` is disabled and you want to include _all_ files in a folder:

View File

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

4
dist/index.js vendored
View File

@@ -47,13 +47,13 @@ const minimatch_1 = __nccwpck_require__(3973);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const token = core.getInput('repo-token', { required: true });
const token = core.getInput('repo-token');
const configPath = core.getInput('configuration-path', { required: true });
const syncLabels = !!core.getInput('sync-labels', { required: false });
const dot = !!core.getInput('dot', { required: false });
const prNumber = getPrNumber();
if (!prNumber) {
console.log('Could not get pull request number from context, exiting');
core.info('Could not get pull request number from context, exiting');
return;
}
const client = github.getOctokit(token);

2181
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,9 +5,10 @@
"main": "lib/main.js",
"scripts": {
"build": "tsc && ncc build lib/main.js",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "echo \"Fake command that does nothing. It is used in reusable workflows\"",
"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",
"test": "jest"
},
"repository": {
@@ -30,13 +31,18 @@
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/node": "^16.11.7",
"@types/minimatch": "^5.1.2",
"@types/js-yaml": "^4.0.5",
"@vercel/ncc": "^0.36.0",
"@types/minimatch": "^5.1.2",
"@types/node": "^16.11.7",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-jest": "^27.2.1",
"jest": "^27.5.1",
"prettier": "^2.8.1",
"prettier": "^2.8.4",
"ts-jest": "^27.1.3",
"typescript": "^4.9.4"
"typescript": "^4.9.5"
}
}

View File

@@ -13,14 +13,14 @@ type ClientType = ReturnType<typeof github.getOctokit>;
export async function run() {
try {
const token = core.getInput('repo-token', {required: true});
const token = core.getInput('repo-token');
const configPath = core.getInput('configuration-path', {required: true});
const syncLabels = !!core.getInput('sync-labels', {required: false});
const dot = !!core.getInput('dot', {required: false});
const prNumber = getPrNumber();
if (!prNumber) {
console.log('Could not get pull request number from context, exiting');
core.info('Could not get pull request number from context, exiting');
return;
}