• Stars
    star
    217
  • Rank 182,446 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated 27 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Run golangci-lint with reviewdog

GitHub Action: Run golangci-lint with reviewdog

release GitHub release (latest SemVer) action-bumpr supported

This action runs golangci-lint with reviewdog on pull requests to improve code review experience.

annotation on diff tab example check tab example status check example

Migrating from v1 to v2

In many cases, you need to do nothing. Just use reviewdog/action-golangci-lint@v2 instead of reviewdog/action-golangci-lint@v1.

If your workflow have steps for setting up Go and caching go modules, they are no longer needed. reviewdog/action-golangci-lint@v2 now set up Go and cache modules automatically, so remove these steps.

on: [pull_request]
jobs:
  golangci-lint:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      # no need with v2
      # - name: Set up Go
      #   uses: actions/setup-go@v2
      #   with:
      #     go-version: '1.17'

      # no need with v2
      # - uses: actions/cache@v2
      #   with:
      #     path: |
      #         ~/.cache/golangci-lint
      #         ~/.cache/go-build
      #         ~/go/pkg/mod
      #     key: ${{ runner.os }}-golangcilint-${{ hashFiles('**/go.sum') }}
      #     restore-keys: |
      #       ${{ runner.os }}-golangcilint-

      - name: golangci-lint
        uses: reviewdog/action-golangci-lint@v2

Inputs

github_token

Required. Default is ${{ github.token }}.

golangci_lint_flags

Optional. golangci-lint flags. (golangci-lint run --out-format=line-number <golangci_lint_flags>)

Note that you can change golangci-lint behavior by configuration file too.

tool_name

Optional. Tool name to use for reviewdog reporter. Useful when running multiple actions with different config.

level

Optional. Report level for reviewdog [info,warning,error]. It's same as -level flag of reviewdog.

workdir

Optional. Working directory relative to the root directory.

reporter

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

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

go_version

Optional. Install a specific version of Go. By default, the latest version of Go 1.x is installed.

go_version_file

Optional. Install a specific version of Go from a file. It accepts a path to a go.mod file or a file containing only Go version. If both the go_version and the go_version_file inputs are provided then the go_version input is used.

cache

Optional. [true, false] It enables cache. The action caches ~/.cache/golangci-lint, ~/.cache/go-build, ~/go/pkg/mod. Default is true.

reviewdog_version

Optional. Install a specific version of reviewdog. By default, the latest version of reviewdog is installed.

golangci_lint_version

Optional. Install a specific version of golangci-lint. By default, the latest version of golangci-lint is installed.

Example usage

Minimum Usage Example

.github/workflows/reviewdog.yml

name: reviewdog
on: [pull_request]
jobs:
  golangci-lint:
    name: runner / golangci-lint
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: golangci-lint
        uses: reviewdog/action-golangci-lint@v2

Advanced Usage Example

.github/workflows/reviewdog.yml

name: reviewdog
on: [pull_request]
jobs:
  # NOTE: golangci-lint doesn't report multiple errors on the same line from
  # different linters and just report one of the errors?

  golangci-lint:
    name: runner / golangci-lint
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: golangci-lint
        uses: reviewdog/action-golangci-lint@v2
        with:
          # optionally use a specific version of Go rather than the latest one
          go_version: "1.17"

          # Can pass --config flag to change golangci-lint behavior and target
          # directory.
          golangci_lint_flags: "--config=.github/.golangci.yml ./testdata"
          workdir: subdirectory/

  # Use golint via golangci-lint binary with "warning" level.
  golint:
    name: runner / golint
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: golint
        uses: reviewdog/action-golangci-lint@v2
        with:
          golangci_lint_flags: "--disable-all -E golint"
          tool_name: golint # Change reporter name.
          level: warning # GitHub Status Check won't become failure with this level.

  # You can add more and more supported linters with different config.
  errcheck:
    name: runner / errcheck
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: errcheck
        uses: reviewdog/action-golangci-lint@v2
        with:
          golangci_lint_flags: "--disable-all -E errcheck"
          tool_name: errcheck
          level: info

  # Disable cache of golangci-lint result, go build and go dependencies
  with_cache:
    name: runner / errcheck
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: golangci-lint
        uses: reviewdog/action-golangci-lint@v2
        with:
          cache: false

All-in-one golangci-lint configuration without config file

.github/workflows/reviewdog.yml

name: reviewdog
on: [pull_request]
jobs:
  golangci-lint:
    name: runner / golangci-lint
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: golangci-lint
        uses: reviewdog/action-golangci-lint@v2
        with:
          golangci_lint_flags: "--enable-all --exclude-use-default=false"

More Repositories

1

reviewdog

🐶 Automated code review tool integrated with any code analysis tools regardless of programming language
Go
7,891
star
2

action-eslint

Run eslint with reviewdog
JavaScript
232
star
3

errorformat

Vim's quickfix errorformat implementation in Go
Go
108
star
4

action-tflint

Run tflint with reviewdog on pull requests to enforce best practices
Shell
105
star
5

action-rubocop

Run rubocop with reviewdog 🐶
Shell
99
star
6

action-shellcheck

Run shellcheck with reviewdog
Shell
91
star
7

action-misspell

Run misspell with reviewdog
Shell
88
star
8

action-suggester

🐶 Suggests any code changes based on diff through GitHub Multi-line code suggestions by using reviewdog
Shell
74
star
9

action-actionlint

run actionlint with reviewdog
Dockerfile
73
star
10

action-tfsec

Run tfsec with reviewdog on pull requests to enforce security best practices
Shell
70
star
11

action-stylelint

Run stylelint with reviewdog
Shell
47
star
12

action-setup

🐶 Setup reviewdog action
Shell
42
star
13

action-hadolint

Run hadolint with reviewdog 🐶
Shell
42
star
14

action-languagetool

Run languagetool with reviewdog 🐶
Shell
39
star
15

action-brakeman

Run brakeman with reviewdog 🐶
Shell
31
star
16

action-detect-secrets

GitHub Action: Run detect-secrets with reviewdog
Python
21
star
17

action-staticcheck

🐶 Run staticcheck with reviewdog on pull requests to improve code review experience.
Shell
19
star
18

action-depup

Action which updates dependencies automatically
Shell
18
star
19

action-template

🐶 Template to create your reviewdog actions
Shell
17
star
20

action-markdownlint

Run markdownlint with reviewdog
Shell
16
star
21

action-ansiblelint

Run ansible-lint with reviewdog 🐕
Shell
13
star
22

action-yamllint

Run yamllint with reviewdog
Shell
12
star
23

errorformat-playground

Playground of https://github.com/reviewdog/errorformat
JavaScript
11
star
24

action-cpplint

Run cpplint with reviewdog
Shell
11
star
25

action-vint

Run vint with reviewdog
Dockerfile
10
star
26

action-nimlint

Run nim check with reviewdog
Shell
9
star
27

action-trivy

Shell
9
star
28

action-alex

🐶 Runs alex with reviewdog 🐶
Shell
8
star
29

action-reek

Run reek with reviewdog 🐶
Shell
8
star
30

action-shfmt

Run shfmt with reviewdog
Shell
7
star
31

action-black

Run black with Reviewdog 🐶
Shell
7
star
32

inviter

Invite contributors to @reviewdog org automatically
Go
5
star
33

action-eclint

Run eclint with reviewdog
Shell
5
star
34

action-pyflakes

Run pyflakes with reviewdog 🐶
Dockerfile
4
star
35

action-remark-lint

Run remark-lint with Reviewdog 🐶
Shell
4
star
36

action-composite-template

🐶 Template to create your composite action based reviewdog actions
Shell
4
star
37

action-ast-grep

🐶 Run ast-grep(sg) with reviewdog
Shell
2
star
38

action-regal

🐶 Run regal with reviewdog
Shell
2
star
39

action-pytest

(WIP) Run pytest with Reviewdog 🐶
Shell
1
star
40

action-terraform-validate

🐶 Run terraform validate with reviewdog
Shell
1
star