|
3 | 3 | pull_request: |
4 | 4 | paths: ['**.go', 'go.mod', '.github/workflows/*'] |
5 | 5 | push: |
6 | | - branches: ['main', 'aix'] |
| 6 | + branches: ['main'] |
7 | 7 |
|
8 | 8 | jobs: |
9 | 9 | staticcheck: |
10 | 10 | name: 'staticcheck' |
11 | 11 | runs-on: 'ubuntu-latest' |
| 12 | + env: {cache: 'staticcheck-${{ github.ref }}'} |
12 | 13 | steps: |
13 | | - - uses: 'actions/setup-go@v5' |
| 14 | + # Setup |
| 15 | + - uses: 'actions/checkout@v4' |
| 16 | + - id: 'cache-restore' |
| 17 | + uses: 'actions/cache/restore@v4' |
14 | 18 | with: |
15 | | - go-version: '1.24' |
16 | | - |
| 19 | + key: '${{ env.cache }}' |
| 20 | + path: | |
| 21 | + ${{ runner.temp }}/staticcheck |
| 22 | + /home/runner/.cache/go-build |
| 23 | + restore-keys: | |
| 24 | + staticcheck-${{ github.ref }} |
| 25 | + staticcheck-refs/heads/main |
| 26 | + - uses: 'actions/setup-go@v5' |
| 27 | + with: {go-version: '1.24'} |
17 | 28 | - uses: 'actions/cache@v4' |
18 | 29 | with: |
19 | 30 | key: '${{ runner.os }}-staticcheck' |
20 | 31 | path: | |
21 | 32 | ${{ runner.temp }}/staticcheck |
22 | 33 | ${{ steps.install_go.outputs.GOCACHE || '' }} |
23 | 34 |
|
| 35 | + # Run |
24 | 36 | - run: | |
25 | 37 | export STATICCHECK_CACHE="${{ runner.temp }}/staticcheck" |
26 | 38 | go install honnef.co/go/tools/cmd/staticcheck@latest |
27 | 39 |
|
28 | | - $(go env GOPATH)/bin/staticcheck -matrix <<EOF |
29 | | - windows: GOOS=windows |
30 | | - linux: GOOS=linux |
31 | | - freebsd: GOOS=freebsd |
32 | | - openbsd: GOOS=openbsd |
33 | | - netbsd: GOOS=netbsd |
34 | | - darwin: GOOS=darwin |
35 | | - illumos: GOOS=illumos |
36 | | - EOF |
| 40 | + fail=0 |
| 41 | + for a in $(go tool dist list); do |
| 42 | + export GOOS=${a%%/*} |
| 43 | + export GOARCH=${a#*/} |
| 44 | +
|
| 45 | + case "$GOOS" in |
| 46 | + (android|ios) continue ;; # Requires cgo to link. |
| 47 | + (js|wasip1) continue ;; # No build tags in internal/ TODO: should maybe fix? |
| 48 | + (plan9) continue ;; # Errors out on some missing definitions like syscall.Errno. |
| 49 | + esac |
| 50 | +
|
| 51 | + echo $a |
| 52 | + go vet ./... || fail=1 |
| 53 | + staticcheck ./... || fail=1 |
| 54 | + done |
| 55 | + exit $fail |
| 56 | +
|
| 57 | + # Store cache |
| 58 | + - name: 'delete existing cache' |
| 59 | + if: '${{ steps.cache-restore.outputs.cache-hit }}' |
| 60 | + env: {GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'} |
| 61 | + continue-on-error: true |
| 62 | + run: | |
| 63 | + gh extension install actions/gh-actions-cache |
| 64 | + gh actions-cache delete "${{ env.cache }}" --confirm |
| 65 | + - uses: 'actions/cache/save@v4' |
| 66 | + with: |
| 67 | + key: '${{ env.cache }}' |
| 68 | + path: | |
| 69 | + ${{ runner.temp }}/staticcheck |
| 70 | + /home/runner/.cache/go-build |
0 commit comments