diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 830cf64..784df7e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,6 +16,11 @@ on: tags: - 'v*.*.*' +permissions: + contents: read + pull-requests: read + checks: write + jobs: # Pre jobs: Linter linters: diff --git a/.github/workflows/pre_linters.yaml b/.github/workflows/pre_linters.yaml index 954a54a..330577d 100644 --- a/.github/workflows/pre_linters.yaml +++ b/.github/workflows/pre_linters.yaml @@ -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: @@ -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/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 diff --git a/.reviewdog.yml b/.reviewdog.yml new file mode 100644 index 0000000..90f5640 --- /dev/null +++ b/.reviewdog.yml @@ -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 ./...)