From f61ac1c7d009388cf148bc4f10ee4c2e0ac68d71 Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 10:23:52 -0700 Subject: [PATCH 01/12] Add packages parameter --- README.md | 6 ++++++ entrypoint.sh | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 9c66a98..125536e 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,12 @@ code review experience. Optional. Report level for reviewdog [info,warning,error]. It's same as `-level` flag of reviewdog. +### `packages` +Optional. Additional NPM packages to be installed, e.g.: +``` +packages: 'stylelint-config-sass-guidelines stylelint-order' +``` + ### `reporter` Reporter of reviewdog command [github-pr-check,github-pr-review,github-check]. diff --git a/entrypoint.sh b/entrypoint.sh index 37e57bd..61a9db3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,6 +10,10 @@ if [ ! -f "$(npm bin)/stylelint" ]; then npm install fi +if [ -n "${INPUT_PACKAGES}" ]; then + npm install ${INPUT_PACKAGES} +fi + $(npm bin)/stylelint --version if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then From fb3a3cc95c401dfbff772a949d01c8f6f4e37d7b Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 10:50:13 -0700 Subject: [PATCH 02/12] Add packages param --- action.yml | 3 +++ entrypoint.sh | 1 + 2 files changed, 4 insertions(+) diff --git a/action.yml b/action.yml index 4dc6363..e25f729 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,9 @@ inputs: name: description: 'Report name' default: 'stylelint' + packages: + description: 'Additional NPM packages' + default: '' reporter: description: | Reporter of reviewdog command [github-pr-check,github-pr-review,github-check]. diff --git a/entrypoint.sh b/entrypoint.sh index 61a9db3..c6d78f5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,6 +10,7 @@ if [ ! -f "$(npm bin)/stylelint" ]; then npm install fi +echo "Input packages: ${INPUT_PACKAGES}" if [ -n "${INPUT_PACKAGES}" ]; then npm install ${INPUT_PACKAGES} fi From 8070be65df0f915cca12f0ce216ce17d77e978c5 Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 11:13:38 -0700 Subject: [PATCH 03/12] Add debugging output --- entrypoint.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index c6d78f5..0fbe13f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,14 +10,21 @@ if [ ! -f "$(npm bin)/stylelint" ]; then npm install fi -echo "Input packages: ${INPUT_PACKAGES}" if [ -n "${INPUT_PACKAGES}" ]; then + echo "Installing packages: ${INPUT_PACKAGES}" npm install ${INPUT_PACKAGES} fi $(npm bin)/stylelint --version +echo "Input report: ${INPUT_REPORTER}" + +echo "Input stylelint input: ${INPUT_STYLELINT_INPUT}" + +echo "Input stylelint config: ${INPUT_STYLELINT_CONFIG}" + if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then + echo "Running github-pr-review" # Use jq and github-pr-review reporter to format result to include link to rule page. $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' \ From dcf9028b9b1d4872a52e5a5e3e91d8a802c5300c Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 11:26:41 -0700 Subject: [PATCH 04/12] More debug --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 0fbe13f..c889d4c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -25,6 +25,8 @@ echo "Input stylelint config: ${INPUT_STYLELINT_CONFIG}" if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then echo "Running github-pr-review" + $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ + | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' # Use jq and github-pr-review reporter to format result to include link to rule page. $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' \ From b00408cc9001cca69fa87832f06a1a23502db644 Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 12:10:42 -0700 Subject: [PATCH 05/12] Add filter-mode param --- action.yml | 3 +++ entrypoint.sh | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index e25f729..ecd8928 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,9 @@ inputs: level: description: 'Report level for reviewdog [info,warning,error]' default: 'error' + filter-mode: + description: 'Reviewdog filter mode [added, diff_context, file, nofilter]' + default: 'added' name: description: 'Report name' default: 'stylelint' diff --git a/entrypoint.sh b/entrypoint.sh index c889d4c..6278860 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -23,6 +23,8 @@ echo "Input stylelint input: ${INPUT_STYLELINT_INPUT}" echo "Input stylelint config: ${INPUT_STYLELINT_CONFIG}" +echo "Input filter-mode : ${INPUT_FILTER_MODE}" + if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then echo "Running github-pr-review" $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ @@ -30,8 +32,8 @@ if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then # Use jq and github-pr-review reporter to format result to include link to rule page. $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' \ - | reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name="${INPUT_NAME:-stylelint}" -reporter=github-pr-review -level="${INPUT_LEVEL}" + | reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name="${INPUT_NAME:-stylelint}" -reporter=github-pr-review -level="${INPUT_LEVEL} -filter-mode=${INPUT_FILTER_MODE:-'added'}" else $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" \ - | reviewdog -f="stylelint" -name="${INPUT_NAME:-stylelint}" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}" + | reviewdog -f="stylelint" -name="${INPUT_NAME:-stylelint}" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}" -filter-mode=${INPUT_FILTER_MODE:-'added'}" fi From 63b28aab327ca18bd8b8823b0ca34eeb769c062a Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 12:11:31 -0700 Subject: [PATCH 06/12] Update param --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ecd8928..5216ceb 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: level: description: 'Report level for reviewdog [info,warning,error]' default: 'error' - filter-mode: + filter_mode: description: 'Reviewdog filter mode [added, diff_context, file, nofilter]' default: 'added' name: From 2c94fec29c00a667c5cbec2c71c604f641ed31b4 Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 12:20:02 -0700 Subject: [PATCH 07/12] Fix quoting --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 6278860..2380642 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -32,8 +32,8 @@ if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then # Use jq and github-pr-review reporter to format result to include link to rule page. $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' \ - | reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name="${INPUT_NAME:-stylelint}" -reporter=github-pr-review -level="${INPUT_LEVEL} -filter-mode=${INPUT_FILTER_MODE:-'added'}" + | reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name="${INPUT_NAME:-stylelint}" -reporter=github-pr-review -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" else $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" \ - | reviewdog -f="stylelint" -name="${INPUT_NAME:-stylelint}" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}" -filter-mode=${INPUT_FILTER_MODE:-'added'}" + | reviewdog -f="stylelint" -name="${INPUT_NAME:-stylelint}" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" fi From 71b39e9750a1da8a230b7dd0a26c0a40252d5276 Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 12:22:17 -0700 Subject: [PATCH 08/12] Update README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 125536e..f29e84c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ code review experience. ## Inputs +### `filter_mode` + +Optional. Reviewdog filter mode [added, diff_context, file, nofilter] +It's the same as the `-filter-mode` flag of reviewdog. + ### `github_token` **Required**. Must be in form of `github_token: ${{ secrets.github_token }}`'. From e45a922f2a886e7235b666ecde61b90d4ec58d25 Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 12:30:23 -0700 Subject: [PATCH 09/12] Add fail-on-error param --- action.yml | 3 +++ entrypoint.sh | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 5216ceb..424384e 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,9 @@ inputs: level: description: 'Report level for reviewdog [info,warning,error]' default: 'error' + fail_on_error: + description: 'Whether reviewdog should fail when errors are found. [true,false] - This is useful for failing CI builds.' + default: 'false' filter_mode: description: 'Reviewdog filter mode [added, diff_context, file, nofilter]' default: 'added' diff --git a/entrypoint.sh b/entrypoint.sh index 2380642..29c635e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -25,6 +25,8 @@ echo "Input stylelint config: ${INPUT_STYLELINT_CONFIG}" echo "Input filter-mode : ${INPUT_FILTER_MODE}" +echo "Input fail-on-error : ${INPUT_FAIL_ON_ERROR}" + if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then echo "Running github-pr-review" $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ @@ -32,8 +34,8 @@ if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then # Use jq and github-pr-review reporter to format result to include link to rule page. $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' \ - | reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name="${INPUT_NAME:-stylelint}" -reporter=github-pr-review -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" + | reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name="${INPUT_NAME:-stylelint}" -reporter=github-pr-review -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" -fail-on-error="${INPUT_FAIL_ON_ERROR}" else $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" \ - | reviewdog -f="stylelint" -name="${INPUT_NAME:-stylelint}" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" + | reviewdog -f="stylelint" -name="${INPUT_NAME:-stylelint}" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" -fail-on-error="${INPUT_FAIL_ON_ERROR}" fi From 339c2039062bf5ddadb9ac0db0bc23f3b3b6dc1d Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 12:39:26 -0700 Subject: [PATCH 10/12] Update README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index f29e84c..c16d207 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,12 @@ code review experience. ## Inputs +### `fail_on_error` + +Whether reviewdog should fail when errors are found. [true,false] +This is useful for failing CI builds in addition to adding comments when errors are found. +It's the same as the `-fail-on-error` flag of reviewdog. + ### `filter_mode` Optional. Reviewdog filter mode [added, diff_context, file, nofilter] From c70422304d620beb2f8981bf316d81e276fab904 Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 12:40:12 -0700 Subject: [PATCH 11/12] Remove debug code --- entrypoint.sh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 29c635e..50661c3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,24 +11,12 @@ if [ ! -f "$(npm bin)/stylelint" ]; then fi if [ -n "${INPUT_PACKAGES}" ]; then - echo "Installing packages: ${INPUT_PACKAGES}" npm install ${INPUT_PACKAGES} fi $(npm bin)/stylelint --version -echo "Input report: ${INPUT_REPORTER}" - -echo "Input stylelint input: ${INPUT_STYLELINT_INPUT}" - -echo "Input stylelint config: ${INPUT_STYLELINT_CONFIG}" - -echo "Input filter-mode : ${INPUT_FILTER_MODE}" - -echo "Input fail-on-error : ${INPUT_FAIL_ON_ERROR}" - if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then - echo "Running github-pr-review" $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' # Use jq and github-pr-review reporter to format result to include link to rule page. From 07e2ff3b128037d88b2171be73eae69077a20a47 Mon Sep 17 00:00:00 2001 From: Adrian Rollett Date: Mon, 7 Dec 2020 12:40:46 -0700 Subject: [PATCH 12/12] Remove debug code --- entrypoint.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 50661c3..74b1b35 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,8 +17,6 @@ fi $(npm bin)/stylelint --version if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then - $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ - | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' # Use jq and github-pr-review reporter to format result to include link to rule page. $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \ | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' \