This file contains hidden or 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: static-analysis | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - '*' | |
| concurrency: | |
| group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| gofmt: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v3 | |
| with: | |
| go-version-file: go.mod | |
| - name: Run gofmt (goimports) | |
| run: | | |
| OUT=$(go run golang.org/x/tools/cmd/goimports -d --format-only .) | |
| [ -z "$OUT" ] || (echo "Not gofmt'ed: $OUT" && exit 1) | |
| vet: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v3 | |
| with: | |
| go-version-file: go.mod | |
| - name: Run go vet | |
| run: go vet ./... | |
| staticcheck: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| goos: [linux, windows, darwin] | |
| goarch: [amd64] | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v3 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install staticcheck | |
| run: "GOBIN=~/.local/bin go install honnef.co/go/tools/cmd/staticcheck" | |
| - name: Print staticcheck version | |
| run: "staticcheck -version" | |
| - name: "Run staticcheck (${{ matrix.goos }}/${{ matrix.goarch }})" | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| run: "staticcheck ./..." |