Skip to content

Commit

Permalink
Merge pull request #95 from tsuyoshicho/feature/opt-update
Browse files Browse the repository at this point in the history
feat: update config and script
  • Loading branch information
tsuyoshicho authored Oct 31, 2020
2 parents 694ce74 + 83e172c commit 15c4e33
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ based on [reviewdog/action-vint](https://github.com/reviewdog/action-vint)

### `github_token`

**Required**. Must be in form of `github_token: ${{ secrets.github_token }}`'.
**Required**. Default is `${{ github.token }}`.

### `level`

Expand All @@ -32,11 +32,25 @@ It's same as `-level` flag of reviewdog.
### `reporter`

Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].
Default is github-pr-check.
Default is github-pr-review.
It's same as `-reporter` flag of reviewdog.

github-pr-review can use Markdown and add a link to rule page in reviewdog reports.

### `filter_mode`

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

### `fail_on_error`

Optional. Exit code for reviewdog when errors are found [true,false]
Default is `false`.

### `reviewdog_flags`

Optional. Additional reviewdog flags

### `textlint_flags`

textlint arguments (i.e. target dir:`doc/*`)
Expand Down
27 changes: 21 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,36 @@ inputs:
github_token:
description: 'GITHUB_TOKEN.'
required: true
default: ${{ github.token }}
level:
description: 'Report level for reviewdog [info,warning,error]'
default: 'error'
required: false
reporter:
description: |
Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].
Default is github-pr-check.
Reporter of reviewdog command [github-check,github-pr-review].
Default is github-pr-review.
github-pr-review can use Markdown and add a link to rule page in reviewdog reports.
default: 'github-pr-check'
required: false
default: 'github-pr-review'
filter_mode:
description: |
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
default: 'added'
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false]
Default is `false`.
default: 'false'
reviewdog_flags:
description: 'Additional reviewdog flags'
default: ''
textlint_flags:
description: "flags and args of textlint command. Default: '.'"
required: true
default: '.'
required: false
tool_name:
description: 'Tool name to use for reviewdog reporter'
default: 'textlint'
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
29 changes: 17 additions & 12 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ else
exit 1
fi

npx textlint -f checkstyle "${INPUT_TEXTLINT_FLAGS:-.}" \
| reviewdog -f=checkstyle -name="textlint" \
-reporter="${INPUT_REPORTER:-'github-pr-check'}" \
-level="${INPUT_LEVEL:-'error'}"
npx textlint -f checkstyle "${INPUT_TEXTLINT_FLAGS}" \
| reviewdog -f=checkstyle \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER:-github-pr-review}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}

# github-pr-review only diff adding
if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then
Expand All @@ -32,14 +36,15 @@ if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then
TMPFILE=$(mktemp)
git diff >"${TMPFILE}"

reviewdog \
-name="textlint-fix" \
-f=diff \
-f.diff.strip=1 \
-reporter="github-pr-review" \
-filter-mode="diff_context" \
-level="${INPUT_LEVEL:-'error'}" \
< "${TMPFILE}"
reviewdog \
-name="textlint-fix" \
-f=diff \
-f.diff.strip=1 \
-name="${INPUT_TOOL_NAME}-fix" \
-reporter="github-pr-review" \
-filter-mode="diff_context" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS} < "${TMPFILE}"

git restore . || true
rm -f "${TMPFILE}"
Expand Down

0 comments on commit 15c4e33

Please sign in to comment.