Skip to content

Commit

Permalink
exp: add review assistant reviewdog on top of refact
Browse files Browse the repository at this point in the history
  • Loading branch information
mtulio committed Aug 7, 2024
1 parent 868ea9b commit 284d343
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ on:
tags:
- 'v*.*.*'

permissions:
contents: read
pull-requests: read
checks: write

jobs:
# Pre jobs: Linter
linters:
Expand Down
59 changes: 56 additions & 3 deletions .github/workflows/pre_linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ on:

# golangci-lint-action requires those permissions to annotate issues in the PR.
permissions:
# Required for analysis.
contents: read
# Used by `only-new-issues``.
pull-requests: read
# Allow access to checks to annotate code in the PR.
checks: write

env:
Expand Down Expand Up @@ -83,3 +80,59 @@ jobs:
args: --timeout=10m
working-directory: openshift-tests-plugin
only-new-issues: true

# https://github.com/reviewdog/reviewdog
# https://github.com/reviewdog/action-golangci-lint
reviewdog:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

# run staticcheck
- uses: reviewdog/action-staticcheck@v1
with:
github_token: ${{ github.token }}
# Change reviewdog reporter if you need
# [github-pr-check,github-check,github-pr-review].
reporter: github-pr-review
# Report all results.
filter_mode: nofilter
# Exit with 1 when it find at least one finding.
fail_on_error: true

- name: Run revive
run: go install github.com/mgechev/revive@latest

- name: Run golangci-lint
run: |-
go install \
github.com/golangci/golangci-lint/cmd/[email protected]
- name: Run misspell check spelling
run: go get -u github.com/client9/misspell/cmd/misspell

- name: Run unparam to check for unused params
run: go install mvdan.cc/unparam@latest

- name: Setup security linter
run: go install github.com/securego/gosec/v2/cmd/gosec@latest

- name: Run reviewdog github-check
continue-on-error: true
run: reviewdog -reporter=github-check

- name: Run reviewdog pr-review
continue-on-error: true
run: reviewdog -reporter=github-pr-review
25 changes: 25 additions & 0 deletions .reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
runner:
govet:
cmd: go vet $(go list ./...)
format: govet
staticcheck:
cmd: staticcheck $(go list ./...)
errorformat:
- "%f:%l:%c: %m"
revive:
cmd: revive -config=.revive.toml $(go list ./...)
format: golint
level: warning
golangci:
cmd: golangci-lint run --out-format=line-number ./...
errorformat:
- '%E%f:%l:%c: %m'
- '%E%f:%l: %m'
- '%C%.%#'
level: warning
misspell:
cmd: misspell $(git ls-files)
errorformat:
- "%f:%l:%c: %m"
gosec:
cmd: gosec $(go list ./...)

0 comments on commit 284d343

Please sign in to comment.