Skip to content

Commit e7ec5f7

Browse files
committed
Fix staticcheck in CI
Looks like it wasn't really being run? Guess I didn't use that -matrix correctly? Just use a simple shell script. Also run go vet, and remove the build workflow: that's redundant now.
1 parent d321760 commit e7ec5f7

File tree

13 files changed

+72
-79
lines changed

13 files changed

+72
-79
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/staticcheck.yml

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,68 @@ on:
33
pull_request:
44
paths: ['**.go', 'go.mod', '.github/workflows/*']
55
push:
6-
branches: ['main', 'aix']
6+
branches: ['main']
77

88
jobs:
99
staticcheck:
1010
name: 'staticcheck'
1111
runs-on: 'ubuntu-latest'
12+
env: {cache: 'staticcheck-${{ github.ref }}'}
1213
steps:
13-
- uses: 'actions/setup-go@v5'
14+
# Setup
15+
- uses: 'actions/checkout@v4'
16+
- id: 'cache-restore'
17+
uses: 'actions/cache/restore@v4'
1418
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'}
1728
- uses: 'actions/cache@v4'
1829
with:
1930
key: '${{ runner.os }}-staticcheck'
2031
path: |
2132
${{ runner.temp }}/staticcheck
2233
${{ steps.install_go.outputs.GOCACHE || '' }}
2334
35+
# Run
2436
- run: |
2537
export STATICCHECK_CACHE="${{ runner.temp }}/staticcheck"
2638
go install honnef.co/go/tools/cmd/staticcheck@latest
2739
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

backend_inotify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (w *watches) removePath(path string) ([]uint32, error) {
100100
wds := make([]uint32, 0, 8)
101101
wds = append(wds, wd)
102102
for p, rwd := range w.path {
103-
if filepath.HasPrefix(p, path) {
103+
if strings.HasPrefix(p, path) {
104104
delete(w.path, p)
105105
delete(w.wd, rwd)
106106
wds = append(wds, rwd)

backend_kqueue.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,9 @@ func (w *kqueue) read(events []unix.Kevent_t) ([]unix.Kevent_t, error) {
694694
}
695695

696696
func (w *kqueue) xSupports(op Op) bool {
697-
if runtime.GOOS == "freebsd" {
698-
//return true // Supports everything.
699-
}
697+
//if runtime.GOOS == "freebsd" {
698+
// return true // Supports everything.
699+
//}
700700
if op.Has(xUnportableOpen) || op.Has(xUnportableRead) ||
701701
op.Has(xUnportableCloseWrite) || op.Has(xUnportableCloseRead) {
702702
return false

backend_windows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func TestRemoveState(t *testing.T) {
1212
// TODO: the Windows backend is too confusing; needs some serious attention.
13-
return
13+
t.Skip("broken test")
1414

1515
var (
1616
tmp = t.TempDir()

fsnotify.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ var (
244244

245245
// ErrUnsupported is returned by AddWith() when WithOps() specified an
246246
// Unportable event that's not supported on this platform.
247+
//lint:ignore ST1012 not relevant
247248
xErrUnsupported = errors.New("fsnotify: not supported with this backend")
248249
)
249250

fsnotify_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,10 @@ func TestAdd(t *testing.T) {
442442
if err == nil {
443443
t.Fatal("error is nil")
444444
}
445-
if !errors.Is(err, internal.UnixEACCES) {
445+
if !errors.Is(err, internal.ErrUnixEACCES) {
446446
t.Errorf("not unix.EACCESS: %T %#[1]v", err)
447447
}
448-
if !errors.Is(err, internal.SyscallEACCES) {
448+
if !errors.Is(err, internal.ErrSyscallEACCES) {
449449
t.Errorf("not syscall.EACCESS: %T %#[1]v", err)
450450
}
451451
})

internal/darwin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
)
1010

1111
var (
12-
SyscallEACCES = syscall.EACCES
13-
UnixEACCES = unix.EACCES
12+
ErrSyscallEACCES = syscall.EACCES
13+
ErrUnixEACCES = unix.EACCES
1414
)
1515

1616
var maxfiles uint64
1717

18-
// Go 1.19 will do this automatically: https://go-review.googlesource.com/c/go/+/393354/
1918
func SetRlimit() {
19+
// Go 1.19 will do this automatically: https://go-review.googlesource.com/c/go/+/393354/
2020
var l syscall.Rlimit
2121
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &l)
2222
if err == nil && l.Cur != l.Max {

internal/freebsd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
)
1010

1111
var (
12-
SyscallEACCES = syscall.EACCES
13-
UnixEACCES = unix.EACCES
12+
ErrSyscallEACCES = syscall.EACCES
13+
ErrUnixEACCES = unix.EACCES
1414
)
1515

1616
var maxfiles uint64

internal/unix.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !windows && !darwin && !freebsd
1+
//go:build !windows && !darwin && !freebsd && !plan9
22

33
package internal
44

@@ -9,8 +9,8 @@ import (
99
)
1010

1111
var (
12-
SyscallEACCES = syscall.EACCES
13-
UnixEACCES = unix.EACCES
12+
ErrSyscallEACCES = syscall.EACCES
13+
ErrUnixEACCES = unix.EACCES
1414
)
1515

1616
var maxfiles uint64

0 commit comments

Comments
 (0)