Skip to content

Commit

Permalink
Merge pull request #24 from acrollet/master
Browse files Browse the repository at this point in the history
Add additional parameters for npm packages and reviewdog options
  • Loading branch information
haya14busa authored Dec 15, 2020
2 parents 8333d34 + 07e2ff3 commit c9d7110
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ 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]
It's the same as the `-filter-mode` flag of reviewdog.

### `github_token`

**Required**. Must be in form of `github_token: ${{ secrets.github_token }}`'.
Expand All @@ -24,6 +35,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].
Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@ 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'
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].
Expand Down
8 changes: 6 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ 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
# 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}" -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}"
| 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

0 comments on commit c9d7110

Please sign in to comment.