RHOAIENG-8554: Add static-checks GitHub action for go code #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Code static analysis | |
"on": | |
push: | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pull-requests: read | |
jobs: | |
golangci: | |
name: golangci-lint | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
component: | |
- components/notebook-controller | |
- components/odh-notebook-controller | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
check-latest: true | |
go-version-file: components/notebook-controller/go.mod | |
cache-dependency-path: ${{ matrix.component }}/go.sum | |
- name: golangci-lint | |
if: "${{ !cancelled() }}" | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: v1.58 | |
only-new-issues: true | |
working-directory: ${{ matrix.component }} | |
# additional checks not part of golangci-lint | |
# https://github.com/golangci/golangci-lint/issues/4123 | |
- name: go mod verify | |
if: "${{ !cancelled() }}" | |
run: go mod verify | |
working-directory: ${{ matrix.component }} | |
# https://github.com/golang/go/issues/27005 | |
- name: go mod tidy -diff | |
if: "${{ !cancelled() }}" | |
run: | | |
set -x | |
go mod tidy | |
# if the above changed any files, report the differences and fail the step | |
if [[ $(git ls-files . -d -m -o --exclude-standard --full-name -v | wc -l) -gt 0 ]]; then | |
echo "There are changes:" | |
git diff | |
exit 1 | |
fi | |
working-directory: ${{ matrix.component }} | |
# https://github.com/golangci/golangci-lint/issues/3094 | |
- name: govulncheck | |
if: "${{ !cancelled() }}" | |
run: | | |
# https://go.googlesource.com/vuln | |
go install golang.org/x/vuln/cmd/govulncheck@latest | |
$(go env GOPATH)/bin/govulncheck ./... | |
working-directory: ${{ matrix.component }} |