Skip to content

Commit

Permalink
Merge pull request #1 from okdas/init
Browse files Browse the repository at this point in the history
init action
  • Loading branch information
okdas authored Oct 12, 2023
2 parents 5c2bcec + d80049a commit 5a97a39
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
branches:
- master
pull_request:
permissions:
pull-requests: write

jobs:
shellcheck:
name: runner / shellcheck
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ on:
branches:
- master
pull_request:
permissions:
pull-requests: write

jobs:
test-check:
name: runner / <linter-name> (github-check)
name: runner / fail-on-found (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -15,11 +18,11 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
locale: "US"
pattern: "TODO_DISCUSS_IN_THIS_COMMIT|TODO_IN_THIS_COMMIT"

test-pr-check:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-check)
name: runner / fail-on-found (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -28,12 +31,12 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: warning
locale: "US"
pattern: "TODO_DISCUSS_IN_THIS_COMMIT|TODO_IN_THIS_COMMIT"
workdir: ./testdata/subdir/

test-pr-review:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-review)
name: runner / fail-on-found (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -42,5 +45,6 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
locale: "US"
pattern: "TODO_DISCUSS_IN_THIS_COMMIT|TODO_IN_THIS_COMMIT"
ignore: README.md
reviewdog_flags: -filter-mode=file -fail-on-error
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ ENV REVIEWDOG_VERSION=v0.15.0

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

# hadolint ignore=DL3006
RUN apk --no-cache add git
RUN apk --no-cache add git=2.40.1-r0 the_silver_searcher=2.2.0-r1

RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION}

# TODO: Install a linter and/or change docker image as you need.
RUN wget -O - -q https://git.io/misspell | sh -s -- -b /usr/local/bin/

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@
![github-pr-review demo](https://user-images.githubusercontent.com/3797062/73162963-4b8e2b00-4132-11ea-9a3f-f9c6f624c79f.png)
![github-pr-check demo](https://user-images.githubusercontent.com/3797062/73163032-70829e00-4132-11ea-8481-f213a37db354.png)

This is a template repository for [reviewdog](https://github.com/reviewdog/reviewdog) action with release automation.
Click `Use this template` button to create your reviewdog action :dog:!

If you want to create your own reviewdog action from scratch without using this
template, please check and copy release automation flow.
It's important to manage release workflow and sync reviewdog version for all
reviewdog actions.

This repo contains a sample action to run [misspell](https://github.com/client9/misspell).
This repo contains a sample action to run [ag](https://github.com/ggreer/the_silver_searcher).

## Input

Expand Down Expand Up @@ -52,9 +44,12 @@ inputs:
reviewdog_flags:
description: 'Additional reviewdog flags'
default: ''
### Flags for <linter-name> ###
locale:
description: '-locale flag of misspell. (US/UK)'
### Flags for fail-on-found ###
pattern:
description: 'AG search pattern (https://github.com/ggreer/the_silver_searcher)'
default: ''
ignore:
description: 'Ignore files/directories matching this pattern (literal file/directory names also allowed)'
default: ''
```
Expand All @@ -65,20 +60,21 @@ inputs:
name: reviewdog
on: [pull_request]
jobs:
# TODO: change `linter_name`.
linter_name:
name: runner / <linter-name>
name: runner / fail-on-found
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-template@v1
- uses: okdas/action-fail-on-found@v1
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
reporter: github-pr-review
# Change reporter level if you need.
# GitHub Status Check won't become failure with warning.
level: warning
pattern: TODO_DISCUSS_IN_THIS_COMMIT|TODO_IN_THIS_COMMIT

Check warning on line 76 in README.md

View workflow job for this annotation

GitHub Actions / runner / fail-on-found (github-check)

[linter-name (fail-on-found)] reported by reviewdog 🐶 pattern: TODO_DISCUSS_IN_THIS_COMMIT|TODO_IN_THIS_COMMIT Raw Output: README.md:76:20: pattern: TODO_DISCUSS_IN_THIS_COMMIT|TODO_IN_THIS_COMMIT

Check warning on line 76 in README.md

View workflow job for this annotation

GitHub Actions / runner / fail-on-found (github-check)

[linter-name (fail-on-found)] reported by reviewdog 🐶 pattern: TODO_DISCUSS_IN_THIS_COMMIT|TODO_IN_THIS_COMMIT Raw Output: README.md:76:48: pattern: TODO_DISCUSS_IN_THIS_COMMIT|TODO_IN_THIS_COMMIT
ignore: .git
```

## Development
Expand Down
15 changes: 9 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'TODO: Run <linter-name> with reviewdog'
description: 'TODO: 🐶 Run <linter-name> with reviewdog on pull requests to improve code review experience.'
author: 'TODO: <your-name>'
name: 'Run ag/the_silver_searcher with reviewdog'
description: '🐶 Run ag/the_silver_searcher with reviewdog on pull requests to improve code review experience.'
author: 'okdas'
inputs:
github_token:
description: 'GITHUB_TOKEN'
Expand Down Expand Up @@ -28,10 +28,13 @@ inputs:
reviewdog_flags:
description: 'Additional reviewdog flags'
default: ''
### Flags for <linter-name> ###
locale:
description: '-locale flag of misspell. (US/UK)'
### Flags for fail-on-found ###
pattern:
description: 'AG search pattern (https://github.com/ggreer/the_silver_searcher)'
default: ''
ignore:
description: 'Ignore files/directories matching this pattern (literal file/directory names also allowed)'
default: '.git'
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ fi

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

misspell -locale="${INPUT_LOCALE}" . \
ag --vimgrep "${INPUT_PATTERN}" --ignore "${INPUT_IGNORE}" \
| reviewdog -efm="%f:%l:%c: %m" \
-name="linter-name (misspell)" \
-name="linter-name (fail-on-found)" \
-reporter="${INPUT_REPORTER:-github-pr-check}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
Expand Down
5 changes: 4 additions & 1 deletion testdata/subdir/text.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Determinisitic result is important!
Good text

TODO_DISCUSS_IN_THIS_COMMIT

TODO_IN_THIS_COMMIT
6 changes: 3 additions & 3 deletions testdata/text.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Determinisitic result is important.
Good text

colour # <= Check -locale
TODO_DISCUSS_IN_THIS_COMMIT

langauge
TODO_IN_THIS_COMMIT

0 comments on commit 5a97a39

Please sign in to comment.