Skip to content

Commit

Permalink
Checks with annotations (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Codex- authored Nov 3, 2023
2 parents 3e23316 + eb95fd5 commit 8423b1e
Show file tree
Hide file tree
Showing 26 changed files with 17,511 additions and 710 deletions.
16 changes: 4 additions & 12 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": ["@typescript-eslint"],
"plugins": ["@typescript-eslint", "simple-import-sort"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
Expand All @@ -13,13 +13,7 @@
"sourceType": "module",
"project": "./tsconfig.json"
},
"ignorePatterns": [
"coverage",
"dist",
"esbuild.config.mjs",
"knip.ts",
"vitest.config.ts"
],
"ignorePatterns": ["coverage", "dist", "esbuild.config.mjs", "knip.ts", "vitest.config.ts"],
"env": {
"node": true,
"es6": true
Expand All @@ -35,10 +29,7 @@
],
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{ "argsIgnorePattern": "^_" }
],
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"camelcase": "off",
"eslint-comments/no-use": "off",
"filenames/match-regex": "off",
Expand Down Expand Up @@ -66,6 +57,7 @@
"prefer-template": "off",
"prettier/prettier": "warn",
"radix": ["error", "as-needed"],
"simple-import-sort/imports": "error",
"sort-imports": "off"
}
}
3 changes: 3 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Pull Request
on:
pull_request:

permissions:
checks: write

jobs:
test:
runs-on: ubuntu-latest
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ This action runs [knip](https://github.com/webpro/knip), parses the results, and

## Usage

The execution of `knip` requires you to have followed the general `knip` setup and have a command script present in your `package.json` file, `knip`, by default but this can be of any name. If this script name deviates from the standard `knip` setup, please provide the script name in the config.

`knip-reporter` appends a reporter to the `knip` command used, `--reporter jsonExt`, to output a parseable report with information needed for annotations where supported.

```yaml
name: Pull Request
on:
pull_request:

# This permissions config is only required if you are not providing
# own permissive token or if you disable annotations.
permissions:
checks: write

steps:
- name: Post the knip results
uses: codex-/knip-reporter@v1
Expand All @@ -27,6 +36,8 @@ The following inputs are supported
| `token` | GitHub Personal Access Token for making API requests. | `false` | `${{ github.token }}` |
| `command_script_name` | The package script that runs knip. | `false` | `knip` |
| `comment_id` | ID to use when updating the PR comment. Spaces will be replaced with dashes. | `false` | `${{ github.workflow }}-knip-reporter` |
| `annotations` | Annotate the project code with the knip results. | `false` | `true` |
| `verbose` | Include annotated items in the comment report. | `false` | `false` |
| `ignore_result` | Do not fail the action run if knip results are found. | `false` | `false` |

### Issues
Expand All @@ -35,6 +46,12 @@ If you encounter a case where comments are not being posted, or known sections a

### APIs Used

- `Checks`
- `Check Runs`
- [`Create a check run`](https://docs.github.com/en/rest/checks/runs#create-a-check-run)
- POST `/repos/{owner}/{repo}/check-runs`
- [`Update a check run`](https://docs.github.com/en/rest/checks/runs#update-a-check-run)
- PATCH `/repos/{owner}/{repo}/check-runs/{check_run_id}`
- `Issues`
- `Comments`
- [`Create an issue comment`](https://docs.github.com/en/rest/issues/comments#create-an-issue-comment)
Expand Down
10 changes: 9 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ inputs:
description: ID to use when updating the PR comment.
default: "${{ github.workflow }}-knip-reporter"
required: false
annotations:
description: Annotate the project code with the knip results.
default: true
required: false
verbose:
description: Include annotated items in the comment report.
default: false
required: false
ignore_results:
description: Do not fail the action run if knip results are found
description: Do not fail the action run if knip results are found.
default: false
required: false
runs:
Expand Down
Loading

0 comments on commit 8423b1e

Please sign in to comment.