Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed May 21, 2022
0 parents commit 227f3eb
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Takeshi KOMIYA

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# GitHub Action: Run erb-lint with reviewdog 🐶

This action runs [erb-lint](https://github.com/Shopify/erb-lint) with
[reviewdog](https://github.com/reviewdog/reviewdog) on pull requests to improve
code review experience.

## Inputs

### `github_token`

`GITHUB_TOKEN`. Default is `${{ github.token }}`.

### `level`

Optional. Report level for reviewdog [`info`, `warning`, `error`].
The default is `error`.

### `reporter`

Optional. Reporter of reviewdog command [`github-pr-check`, `github-check`, `github-pr-review`].
The default is `github-pr-review`.

### `filter_mode`

Optional. Filtering mode for the reviewdog command [`added`, `diff_context`, `file`, `nofilter`].
Default is `added`.

### `skip_install`

Optional. Do not install Rubocop or its extensions. Default: `false`.

### `use_bundler`

Optional. Run Rubocop with bundle exec. Default: `false`.

## Example usage

```yml
name: reviewdog
on: [pull_request]
jobs:
erb-lint:
name: runner / erb-lint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.0
- name: erb-lint
uses: reviewdog/action-erblint@v1
```
## License
[MIT](https://choosealicense.com/licenses/mit)
34 changes: 34 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Run erb-lint with reviewdog'
description: '🐶 Run erb-lint with reviewdog on pull requests to improve code review experience.'
author: 'tk0miya'
inputs:
github_token:
description: 'GITHUB_TOKEN'
default: ${{ github.token }}
level:
description: 'Report level for reviewdog [info,warning,error]'
default: 'error'
reporter:
description: |
Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].
Default is github-pr-review.
default: 'github-pr-review'
filter_mode:
description: |
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
default: 'added'
use_bundler:
description: "Run erb-lint with bundle exec. Default: `false`"
default: 'false'
runs:
using: 'composite'
steps:
- run: $GITHUB_ACTION_PATH/script.sh
shell: sh
env:
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_LEVEL: ${{ inputs.level }}
INPUT_REPORTER: ${{ inputs.reporter }}
INPUT_FILTER_MODE: ${{ inputs.filter_mode }}
INPUT_USE_BUNDLER: ${{ inputs.use_bundler }}
30 changes: 30 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh -e
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"

echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" 2>&1
echo '::endgroup::'

if [ "${INPUT_USE_BUNDLER}" = "true" ]; then
echo '::group:: Installing erb-lint via bundler'
bundle install
echo '::endgroup::'
fi

if [ "${INPUT_USE_BUNDLER}" = "false" ]; then
BUNDLE_EXEC=""
else
BUNDLE_EXEC="bundle exec "
fi

echo '::group:: Running erb-lint with reviewdog 🐶 ...'
${BUNDLE_EXEC}erblint --lint-all --format compact \
| reviewdog \
-efm="%f:%l:%c: %m" \
-reporter="${INPUT_REPORTER}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-level="${INPUT_LEVEL}"
echo '::endgroup::'

0 comments on commit 227f3eb

Please sign in to comment.