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 bf34c35
Show file tree
Hide file tree
Showing 4 changed files with 114 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 @@ -21,6 +21,10 @@ jobs:
linters:
uses: ./.github/workflows/pre_linters.yaml

# Pre jobs: unit tests and integration tests
reviewer:
uses: ./.github/workflows/reviewdog.yaml

# Pre jobs: unit tests and integration tests
test-openshift-tests-plugin:
uses: ./.github/workflows/pre_test-openshift-tests-plugin.yaml
Expand All @@ -31,6 +35,7 @@ jobs:
needs:
- linters
- test-openshift-tests-plugin
- reviewdog
env:
VERSION: "v0.0.0-devel-pr.${{ github.event.pull_request.number }}"
VERSION_TOOLS: v0.4.0
Expand Down
3 changes: 0 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
84 changes: 84 additions & 0 deletions .github/workflows/reviewer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
name: reviewer

on:
workflow_call: {}

# golangci-lint-action requires those permissions to annotate issues in the PR.
permissions:
contents: read
pull-requests: read
checks: write

env:
GO_VERSION: 1.22
GOLANGCI_LINT_VERSION: v1.59

jobs:
# 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/golangci-lint@v1.45.2
- 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

misspell:
name: runner / misspell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: warning
locale: "US"
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 bf34c35

Please sign in to comment.