mirror of
https://github.com/giraffate/clippy-action.git
synced 2024-11-24 08:59:32 +01:00
Merge pull request #25 from giraffate/catch_error_type
Catch error level from Clippy
This commit is contained in:
commit
3009e30c95
4 changed files with 28 additions and 4 deletions
12
README.md
12
README.md
|
@ -34,6 +34,7 @@ jobs:
|
||||||
### `clippy_flags`
|
### `clippy_flags`
|
||||||
|
|
||||||
Optional. clippy flags. (cargo clippy --color never -q --message-format json `<clippy_flags>`)
|
Optional. clippy flags. (cargo clippy --color never -q --message-format json `<clippy_flags>`)
|
||||||
|
For example, `clippy_flags: -- -Dwarnings`.
|
||||||
|
|
||||||
### `tool_name`
|
### `tool_name`
|
||||||
|
|
||||||
|
@ -53,6 +54,17 @@ Optional. Working directory relative to the root directory.
|
||||||
Optional. Reporter of reviewdog command [github-pr-check,github-pr-review].
|
Optional. Reporter of reviewdog command [github-pr-check,github-pr-review].
|
||||||
It's same as `-reporter` flag of reviewdog.
|
It's same as `-reporter` flag of reviewdog.
|
||||||
|
|
||||||
|
#### github-pr-review
|
||||||
|
|`cargo clippy`|`cargo clippy -- -Dwarnings`|
|
||||||
|
|---|---|
|
||||||
|
|<img width="913" alt="github-pr-review_warning" src="https://user-images.githubusercontent.com/17407489/205067105-4511a31e-9e95-407c-ae44-c8699e46d780.png">|<img width="911" alt="github-pr-review_error" src="https://user-images.githubusercontent.com/17407489/205067361-f22254a8-7211-457e-82a1-006a4cfc3c22.png">|
|
||||||
|
|
||||||
|
#### github-pr-check
|
||||||
|
|`cargo clippy`|`cargo clippy -- -Dwarnings`|
|
||||||
|
|---|---|
|
||||||
|
|<img width="855" alt="github-pr-check_warning" src="https://user-images.githubusercontent.com/17407489/205067697-029aceba-a143-4183-85de-a4ff22c2ed27.png">|<img width="867" alt="github-pr-check_error" src="https://user-images.githubusercontent.com/17407489/205067734-fc7decb6-21df-49b0-9cd6-83bc40cd26ec.png">|
|
||||||
|
|
||||||
|
|
||||||
### `filter_mode`
|
### `filter_mode`
|
||||||
|
|
||||||
Optional. Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
|
Optional. Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
|
||||||
|
|
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
20
src/main.ts
20
src/main.ts
|
@ -13,7 +13,7 @@ async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const reviewdogVersion = core.getInput('reviewdog_version') || 'latest'
|
const reviewdogVersion = core.getInput('reviewdog_version') || 'latest'
|
||||||
const toolName = core.getInput('tool_name') || 'clippy'
|
const toolName = core.getInput('tool_name') || 'clippy'
|
||||||
const clippyFlags = core.getInput('clippy_flags');
|
const clippyFlags = core.getInput('clippy_flags')
|
||||||
const level = core.getInput('level') || 'error'
|
const level = core.getInput('level') || 'error'
|
||||||
const reporter = core.getInput('reporter') || 'github-pr-check'
|
const reporter = core.getInput('reporter') || 'github-pr-check'
|
||||||
const filterMode = core.getInput('filter_mode') || 'added'
|
const filterMode = core.getInput('filter_mode') || 'added'
|
||||||
|
@ -38,7 +38,15 @@ async function run(): Promise<void> {
|
||||||
const output: string[] = []
|
const output: string[] = []
|
||||||
await exec.exec(
|
await exec.exec(
|
||||||
'cargo',
|
'cargo',
|
||||||
['clippy', '--color', 'never', '-q', '--message-format', 'json', ...parse(clippyFlags)],
|
[
|
||||||
|
'clippy',
|
||||||
|
'--color',
|
||||||
|
'never',
|
||||||
|
'-q',
|
||||||
|
'--message-format',
|
||||||
|
'json',
|
||||||
|
...parse(clippyFlags)
|
||||||
|
],
|
||||||
{
|
{
|
||||||
cwd,
|
cwd,
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
|
@ -64,11 +72,13 @@ async function run(): Promise<void> {
|
||||||
|
|
||||||
core.debug('this is a compiler-message!')
|
core.debug('this is a compiler-message!')
|
||||||
const span = content.message.spans[0]
|
const span = content.message.spans[0]
|
||||||
|
const messageLevel =
|
||||||
|
content.message.level === 'warning' ? 'w' : 'e'
|
||||||
const rendered =
|
const rendered =
|
||||||
reporter === 'github-pr-review'
|
reporter === 'github-pr-review'
|
||||||
? ` \n<pre><code>${content.message.rendered}</code></pre>\n__END__`
|
? ` \n<pre><code>${content.message.rendered}</code></pre>\n__END__`
|
||||||
: `${content.message.rendered}\n__END__`
|
: `${content.message.rendered}\n__END__`
|
||||||
const ret = `${span.file_name}:${span.line_start}:${span.column_start}:${rendered}`
|
const ret = `${span.file_name}:${span.line_start}:${span.column_start}:${messageLevel}:${rendered}`
|
||||||
output.push(ret)
|
output.push(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,8 +90,10 @@ async function run(): Promise<void> {
|
||||||
return await exec.exec(
|
return await exec.exec(
|
||||||
reviewdog,
|
reviewdog,
|
||||||
[
|
[
|
||||||
'-efm=%E%f:%l:%c:%m',
|
'-efm=<pre><code>%E%f:%l:%c:%t:%m',
|
||||||
|
'-efm=%E%f:%l:%c:%t:%m',
|
||||||
'-efm=%Z__END__',
|
'-efm=%Z__END__',
|
||||||
|
'-efm=%C%m</code></pre>',
|
||||||
'-efm=%C%m',
|
'-efm=%C%m',
|
||||||
'-efm=%C',
|
'-efm=%C',
|
||||||
`-name=${toolName}`,
|
`-name=${toolName}`,
|
||||||
|
|
Loading…
Reference in a new issue