From 41d079cb4ab2466a07853dc78eefbbe4de373a2d Mon Sep 17 00:00:00 2001 From: Takayuki Nakata Date: Thu, 1 Dec 2022 16:59:53 +0900 Subject: [PATCH 1/2] Catch error level from Clippy --- dist/index.js | Bin 239315 -> 239692 bytes dist/index.js.map | Bin 278227 -> 278670 bytes src/main.ts | 20 ++++++++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0a94336fe35eb5b38ec6b555d691fa75fa335313..056e5e54902c7ed36efb1ce76a2606ebaed78aca 100644 GIT binary patch delta 262 zcmcb7mha33z6~$rCx2EGV@uA-EGVd)?5Hlurkk9flV1d6O0edomZgGNl8l8Ql3zDB zwYWGjJyka?zbH4c1f+%~t2jRo$Pk}gqrnL?rcc9bbAf^?iyc(G573+(1zUyW{JfIX zyb?XAuwD*C+}2h>y*#lfFEcM)UBMp6R#&i6P)}9gT&R-7$b)Rg=JTrdjFL75MX7c+ z$@wX%cB-zbX;!K^R;tNXswGyF6Vw$Z^Q&_+L7A57n!GmpV1+jNAWhAV>g|r|j6lq^ K-BF!+Qau2a)m9b& delta 144 zcmX?ef$#EJz6~$rmDQ7TG7AbS)pZoqb#;^TbMlKo%)HdHR4_xgP+ezofr5yFf_heQ zejZRxPfxEPv8Xsz1ESF_Co#QPGgfDEVw1#V3oXgbe2S_po2RPUF>ZdWX3fZ}>Z+P% lrJ7@#^aKm1`=|M3};%vz|nFR%v(*-M-L?(aGXW>xS)lJUN$uEM7u&L*zmZc*2 z%<8&@aLLIJ^@OJjS1<{I^s=gF73b$6)gV5Oj*sy=z6k^J-p8yVR)HyXPz zqG;cI(8Qfl+NPi=)y^h4KPA;p)m1gkN;StyHQ7qF#7Z?6;T&Bv_Q{-P+$`v#hP*cV zV68U#AY)K8G)J4YN1HJMG1K;FGiKiI=?eRp&8M&DW#M48c62WD+CGts { try { const reviewdogVersion = core.getInput('reviewdog_version') || 'latest' 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 reporter = core.getInput('reporter') || 'github-pr-check' const filterMode = core.getInput('filter_mode') || 'added' @@ -38,7 +38,15 @@ async function run(): Promise { const output: string[] = [] await exec.exec( 'cargo', - ['clippy', '--color', 'never', '-q', '--message-format', 'json', ...parse(clippyFlags)], + [ + 'clippy', + '--color', + 'never', + '-q', + '--message-format', + 'json', + ...parse(clippyFlags) + ], { cwd, ignoreReturnCode: true, @@ -64,11 +72,13 @@ async function run(): Promise { core.debug('this is a compiler-message!') const span = content.message.spans[0] + const messageLevel = + content.message.level === 'warning' ? 'w' : 'e' const rendered = reporter === 'github-pr-review' ? ` \n
${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) } } @@ -80,8 +90,10 @@ async function run(): Promise { return await exec.exec( reviewdog, [ - '-efm=%E%f:%l:%c:%m', + '-efm=
%E%f:%l:%c:%t:%m',
+            '-efm=%E%f:%l:%c:%t:%m',
             '-efm=%Z__END__',
+            '-efm=%C%m
', '-efm=%C%m', '-efm=%C', `-name=${toolName}`, From 761f34f247af781c7f8ba75ae7f213ec82a8f59c Mon Sep 17 00:00:00 2001 From: Takayuki Nakata Date: Fri, 2 Dec 2022 22:24:38 +0900 Subject: [PATCH 2/2] Update README --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index f29b779..e7352fb 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ jobs: ### `clippy_flags` Optional. clippy flags. (cargo clippy --color never -q --message-format json ``) +For example, `clippy_flags: -- -Dwarnings`. ### `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]. It's same as `-reporter` flag of reviewdog. +#### github-pr-review +|`cargo clippy`|`cargo clippy -- -Dwarnings`| +|---|---| +|github-pr-review_warning|github-pr-review_error| + +#### github-pr-check +|`cargo clippy`|`cargo clippy -- -Dwarnings`| +|---|---| +|github-pr-check_warning|github-pr-check_error| + + ### `filter_mode` Optional. Filtering mode for the reviewdog command [added,diff_context,file,nofilter].