Skip to content

Commit

Permalink
🔀 Merge pull request #31 from reviewdog/add_formatting_option
Browse files Browse the repository at this point in the history
💥 Changes the remark-lint `remark_flags` argument to `remark_args` since it better decripes the input argument.
📝 Updates documentation.
  • Loading branch information
rickstaa authored Jan 10, 2021
2 parents 9afcd34 + d3c28ac commit 67b6b60
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 105 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
workdir: ./testdata/

test-pr-check:
if: github.event_name == 'pull_request'
Expand All @@ -27,6 +28,7 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: warning
workdir: ./testdata/

test-pr-review:
if: github.event_name == 'pull_request'
Expand All @@ -40,3 +42,4 @@ jobs:
reporter: github-pr-review
level: error
reviewdog_flags: -filter-mode=file -fail-on-error
workdir: ./testdata/
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ node_modules/

# Files to ignore
.package-lock.json
.package.json
.package.json

# IDE
.vscode/
*.code-workspace
32 changes: 16 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

> 13 December 2020
- :wrench: Updates dockerfile reviewdog install to nightly branch [`#5`](https://github.com/rickstaa/action-remark-lint/pull/5)
- Add --frail argument to remark to exit with 1 on warnings [`#3`](https://github.com/rickstaa/action-remark-lint/pull/3)
- Fix reviewdog exit code bug and error format syntax problem [`#4`](https://github.com/rickstaa/action-remark-lint/pull/4)
- Change version and reporter [`#1`](https://github.com/rickstaa/action-remark-lint/pull/1)
- :see_no_evil: Updates gitignore [`2b9ef56`](https://github.com/rickstaa/action-remark-lint/commit/2b9ef565dc342eb7b01170c22d0c8efbf26adda5)
- :sparkles: Adds reviewdog ci actions, testdata and removes github-pr-review warning [`3fe02eb`](https://github.com/rickstaa/action-remark-lint/commit/3fe02eb8f74cba56966ea63532354e99f5b23cb1)
- :sparkles: Adds additional reviewdog arguments and updates documentation [`a4425dc`](https://github.com/rickstaa/action-remark-lint/commit/a4425dccec04b3eb28d9756b49227aef7e630aed)
* :wrench: Updates dockerfile reviewdog install to nightly branch [`#5`](https://github.com/rickstaa/action-remark-lint/pull/5)
* Add --frail argument to remark to exit with 1 on warnings [`#3`](https://github.com/rickstaa/action-remark-lint/pull/3)
* Fix reviewdog exit code bug and error format syntax problem [`#4`](https://github.com/rickstaa/action-remark-lint/pull/4)
* Change version and reporter [`#1`](https://github.com/rickstaa/action-remark-lint/pull/1)
* :see_no_evil: Updates gitignore [`2b9ef56`](https://github.com/rickstaa/action-remark-lint/commit/2b9ef565dc342eb7b01170c22d0c8efbf26adda5)
* :sparkles: Adds reviewdog ci actions, testdata and removes github-pr-review warning [`3fe02eb`](https://github.com/rickstaa/action-remark-lint/commit/3fe02eb8f74cba56966ea63532354e99f5b23cb1)
* :sparkles: Adds additional reviewdog arguments and updates documentation [`a4425dc`](https://github.com/rickstaa/action-remark-lint/commit/a4425dccec04b3eb28d9756b49227aef7e630aed)

#### [v0.0.5](https://github.com/rickstaa/action-remark-lint/compare/v0.0.4...v0.0.5)

> 25 January 2020
- Re-fixed args passed to remark (what a painful piece of software) [`abb616b`](https://github.com/rickstaa/action-remark-lint/commit/abb616bd9d9ec698d38bb680e5caa4c16f6380ff)
- Revert "Added --no-stdout --no-color args to remark call" [`3c2e844`](https://github.com/rickstaa/action-remark-lint/commit/3c2e844aaa86e3bbe96a93bebd3f44b629c37e10)
* Re-fixed args passed to remark (what a painful piece of software) [`abb616b`](https://github.com/rickstaa/action-remark-lint/commit/abb616bd9d9ec698d38bb680e5caa4c16f6380ff)
* Revert "Added --no-stdout --no-color args to remark call" [`3c2e844`](https://github.com/rickstaa/action-remark-lint/commit/3c2e844aaa86e3bbe96a93bebd3f44b629c37e10)

#### [v0.0.4](https://github.com/rickstaa/action-remark-lint/compare/v0.0.3...v0.0.4)

> 25 January 2020
- Added --no-stdout --no-color args to remark call [`4d68733`](https://github.com/rickstaa/action-remark-lint/commit/4d687330c3b96a6261a3426878c584059bb7ff5d)
* Added --no-stdout --no-color args to remark call [`4d68733`](https://github.com/rickstaa/action-remark-lint/commit/4d687330c3b96a6261a3426878c584059bb7ff5d)

#### [v0.0.3](https://github.com/rickstaa/action-remark-lint/compare/v0.0.2...v0.0.3)

> 25 January 2020
- Revert "Added Makefile and release script" [`e078250`](https://github.com/rickstaa/action-remark-lint/commit/e0782504aad6bc4bd4970a6d236e13254d2a1fac)
- Added Makefile and release script [`f4ca24a`](https://github.com/rickstaa/action-remark-lint/commit/f4ca24a8b145313efa4c88e749fecc01e33b49f7)
- Fixed remark CLI usage [`09a9260`](https://github.com/rickstaa/action-remark-lint/commit/09a9260dcbc40e639ad089664070a6ea9be63e04)
* Revert "Added Makefile and release script" [`e078250`](https://github.com/rickstaa/action-remark-lint/commit/e0782504aad6bc4bd4970a6d236e13254d2a1fac)
* Added Makefile and release script [`f4ca24a`](https://github.com/rickstaa/action-remark-lint/commit/f4ca24a8b145313efa4c88e749fecc01e33b49f7)
* Fixed remark CLI usage [`09a9260`](https://github.com/rickstaa/action-remark-lint/commit/09a9260dcbc40e639ad089664070a6ea9be63e04)

#### [v0.0.2](https://github.com/rickstaa/action-remark-lint/compare/v0.0.1...v0.0.2)

Expand All @@ -53,6 +53,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

> 25 January 2020
- Initial Commit [`9427de7`](https://github.com/rickstaa/action-remark-lint/commit/9427de75ca49d1c667e37c01974f46391dea78f0)
- Revert "Added Makefile and release script" [`e078250`](https://github.com/rickstaa/action-remark-lint/commit/e0782504aad6bc4bd4970a6d236e13254d2a1fac)
- Added Makefile and release script [`f4ca24a`](https://github.com/rickstaa/action-remark-lint/commit/f4ca24a8b145313efa4c88e749fecc01e33b49f7)
* Initial Commit [`9427de7`](https://github.com/rickstaa/action-remark-lint/commit/9427de75ca49d1c667e37c01974f46391dea78f0)
* Revert "Added Makefile and release script" [`e078250`](https://github.com/rickstaa/action-remark-lint/commit/e0782504aad6bc4bd4970a6d236e13254d2a1fac)
* Added Makefile and release script [`f4ca24a`](https://github.com/rickstaa/action-remark-lint/commit/f4ca24a8b145313efa4c88e749fecc01e33b49f7)
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ FROM prologic/remark-lint:latest

ENV REVIEWDOG_VERSION=v0.11.0-nightly20201213+85edbc6

RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION}
RUN apk --no-cache add bash~=5.0

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh | sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION}

RUN apk --no-cache -U add git

Expand Down
85 changes: 27 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
[![reviewdog](https://github.com/reviewdog/action-remark-lint/workflows/reviewdog/badge.svg)](https://github.com/reviewdog/action-remark-lint/actions?query=workflow%3Areviewdog)
[![depup](https://github.com/reviewdog/action-remark-lint/workflows/depup/badge.svg)](https://github.com/reviewdog/action-remark-lint/actions?query=workflow%3Adepup)
[![release](https://github.com/reviewdog/action-remark-lint/workflows/release/badge.svg)](https://github.com/reviewdog/action-remark-lint/actions?query=workflow%3Arelease)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/reviewdog/action-remark-lint?logo=github&sort=semver)](https://github.com/reviewdog/action-remark-lint/releases)
[![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/reviewdog/action-remark-lint?logo=github\&sort=semver)](https://github.com/reviewdog/action-remark-lint/releases)
[![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github\&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr)

![action screenshot](https://user-images.githubusercontent.com/17570430/102060312-4ee5e000-3df2-11eb-8c82-767afeccd8db.png)
![action screenshot](https://user-images.githubusercontent.com/17570430/102059912-d3842e80-3df1-11eb-9b0a-2e04eab5e294.png)

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

## Quickstart
## Quick start

In it's simplest form this action can be used to annotate the changes that are suggested by the [remark-lint](https://github.com/remarkjs/remark-lint) linter.

```yml
name: reviewdog
Expand All @@ -28,83 +29,51 @@ jobs:
uses: reviewdog/action-remark-lint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check # Change reporter. (Only `github-pr-check` is supported at the moment).
reporter: github-pr-check
```
See the Inputs section below for details on the defaults and optional configuration settings.
## Inputs
### `github_token`

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

### workdir

**Optional**. The directory to run remark-lint in. Default is `.`.

### remark_flags
**Required**. The [GITHUB_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow). Must be in form of `github_token: ${{ secrets.github_token }}`. Defaults to `${{ github.token }}`.

**Optional**. Additional flags you want to pass to remark-lint. Default is ` `.
### `workdir`

### `level`

**Optional**. Report level for reviewdog \[info, warning, error\].
It's same as `-level` flag of reviewdog.
**Optional**. The directory to run remark-lint in. Defaults to `.`.

### `reporter`
#### `remark_args`

**Optional**. Reporter of reviewdog command \[github-pr-check, github-pr-review, github-check\].
Default is github-pr-check. github-pr-review can use Markdown and add a link to rule page in reviewdog reports.
**Optional**. Additional remark-lint input arguments. Defaults to `""`.

**NB:** Only `github-pr-check` is supported currently.
### `annotate`

#### `filter_mode`

**Optional**. Filtering mode for the reviewdog command \[added, diff_context, file, nofilter\]. Default = `"added"`.

#### `fail_on_error`

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

#### `reviewdog_flags`

**Optional**. Additional reviewdog flags. Default = `""`.
**Optional**. Annotate remark-lint changes using reviewdog. Defaults to `true`.

#### `tool_name`

**Optional**. Tool name to use for reviewdog reporter. Default = `remark-lint`.

## Development
**Optional**. Tool name to use for reviewdog reporter. Defaults to `remark-lint`.

### Release

#### [haya14busa/action-bumpr](https://github.com/haya14busa/action-bumpr)
### `level`

You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch).
Pushing tag manually by yourself also work.
**Optional**. Report level for reviewdog `[info, warning, error]`. It's same as `-level` flag of reviewdog. Defaults to `error`.

#### [haya14busa/action-update-semver](https://github.com/haya14busa/action-update-semver)
### `reporter`

This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3.
ref: <https://help.github.com/en/articles/about-actions#versioning-your-action>
**Optional**. Reporter of reviewdog command `[github-pr-check, github-pr-review, github-check]`. Default is `github-pr-check`.

### Lint - reviewdog integration
### `filter_mode`

This reviewdog action template itself is integrated with reviewdog to run lints
which is useful for Docker container based actions.
**Optional**. Filtering mode for the reviewdog command `[added, diff_context, file, nofilter]`. Defaults to `added`.

![reviewdog integration](https://user-images.githubusercontent.com/3797062/72735107-7fbb9600-3bde-11ea-8087-12af76e7ee6f.png)
#### `fail_on_error`

Supported linters:
**Optional**. Exit code for when reviewdog when errors are found `[true, false]`. Defaults to `false`.

- [reviewdog/action-shellcheck](https://github.com/reviewdog/action-shellcheck)
- [reviewdog/action-hadolint](https://github.com/reviewdog/action-hadolint)
- [reviewdog/action-misspell](https://github.com/reviewdog/action-misspell)
### `reviewdog_flags`

### Dependencies Update Automation
**Optional**. Additional reviewdog flags. Defaults to `""`.

This repository uses [reviewdog/action-depup](https://github.com/reviewdog/action-depup) to update
reviewdog version.
## Format your code

[![reviewdog depup demo](https://user-images.githubusercontent.com/3797062/73154254-170e7500-411a-11ea-8211-912e9de7c936.png)](https://github.com/reviewdog/action-template/pull/6)
This action is meant to annotate any possible changes that would need to be made to make your code adhere to the [remark-lint linting guidelines](https://github.com/remarkjs/remark-lint). It does not apply these changes to your codebase. If you also want to apply the changes to your repository, you can use the [reviewdog/action-suggester](https://github.com/reviewdog/action-suggester). You can find examples of how this is done can be found in [rickstaa/action-remark-lint](https://github.com/rickstaa/action-remark-lint/)
33 changes: 15 additions & 18 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,48 @@ name: "Run remark-lint with reviewdog"
description: "🐶 Run remark-lint with reviewdog on pull requests to improve code review experience."
author: "prologic"
inputs:
github_token:
description: "GITHUB_TOKEN."
required: true
workdir:
description: "Working directory relative to the root directory."
required: false
default: "."
remark_flags:
description: "Additional flags for remark-lint"
remark_args:
description: "Additional remark-lint input arguments."
required: false
default: ""
# Reviewdog related inputs
github_token:
description: "GITHUB_TOKEN."
required: true
default: ${{ github.token }}
tool_name:
description: "Tool name to use for reviewdog reporter"
description: "Tool name to use for reviewdog reporter."
required: false
default: "remark-lint"
level:
description: "Report level for reviewdog [info,warning,error]"
description: "Report level for reviewdog [info, warning, error]."
required: false
default: "error"
reporter:
description: |
Reporter of reviewdog command [github-pr-check,github-pr-review,github-check].
Default is github-pr-check.
github-pr-review can use Markdown and add a link to rule page in reviewdog reports.
description: "Reporter of reviewdog command [github-pr-check, github-pr-review, github-check]."
required: false
default: "github-pr-check"
filter_mode:
description: |
Filtering mode for the reviewdog command [added, diff_context, file, nofilter].
Default is added.
description: "Filtering mode for the reviewdog command [added, diff_context, file, nofilter]."
required: false
default: "added"
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true, false]
Default is `false`.
description: "Exit code for reviewdog when errors are found [true, false]."
required: false
default: "false"
reviewdog_flags:
description: "Additional reviewdog flags"
description: "Additional reviewdog flags."
required: false
default: ""
runs:
using: "docker"
image: "Dockerfile"

# Ref: https://haya14busa.github.io/github-action-brandings/
branding:
icon: "zoom-in"
color: "purple"
24 changes: 13 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/sh
set -e # Exit immediately if a command exits with a non-zero status
#!/bin/bash
set -eu # Increase bash error strictness

if [ -n "${GITHUB_WORKSPACE}" ] ; then
if [[ -n "${GITHUB_WORKSPACE}" ]]; then
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit
fi

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

remark --frail --quiet --use=remark-preset-lint-recommended . ${INPUT_REMARK_FLAGS} 2>&1 |
# NOTE: ${VAR,,} Is bash 4.0 syntax to make strings lowercase.
echo "[action-remark-lint] Checking markdown code with the remark-lint linter and reviewdog..."
remark --use=remark-preset-lint-recommended . ${INPUT_REMARK_ARGS} 2>&1 |
sed 's/\x1b\[[0-9;]*m//g' | # Removes ansi codes see https://github.com/reviewdog/errorformat/issues/51
reviewdog -f=remark-lint \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER:-github-pr-check}"\
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
-tee \
${INPUT_REVIEWDOG_FLAGS}
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
-tee \
${INPUT_REVIEWDOG_FLAGS}

0 comments on commit 67b6b60

Please sign in to comment.