Skip to content

Commit cc01d07

Browse files
committed
ci: add golangci-lint and -race; fix git-restore regression; wire lint to CI
1 parent db8b1e5 commit cc01d07

46 files changed

Lines changed: 253 additions & 255 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ on:
2020
default: false
2121

2222
jobs:
23+
lint:
24+
name: lint
25+
runs-on: macos-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-go@v5
29+
with:
30+
go-version-file: "go.mod"
31+
- name: golangci-lint
32+
uses: golangci/golangci-lint-action@v6
33+
with:
34+
version: latest
35+
2336
unit:
2437
name: unit (L1)
2538
runs-on: macos-latest

.golangci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: "2"
2+
3+
formatters:
4+
enable:
5+
- gofmt
6+
- goimports
7+
8+
linters:
9+
default: none
10+
enable:
11+
- errcheck
12+
- govet
13+
- staticcheck
14+
- unused
15+
- misspell
16+
- unconvert
17+
- exhaustive
18+
settings:
19+
exhaustive:
20+
default-signifies-exhaustive: true
21+
errcheck:
22+
exclude-functions:
23+
- (net/http.Response).Body.Close
24+
- (net/http.ResponseWriter).Write
25+
- (*encoding/json.Encoder).Encode
26+
- os.WriteFile
27+
- (*os.File).Close
28+
exclusions:
29+
rules:
30+
- path: "_test\\.go"
31+
linters:
32+
- errcheck

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ COVERAGE_FILE=coverage.out
1010
COVERAGE_HTML=coverage.html
1111

1212
test-unit:
13-
go test -v -timeout 5m ./...
13+
go test -v -race -timeout 5m ./...
14+
15+
lint:
16+
golangci-lint run ./...
1417

1518
test-integration:
1619
go test -v -timeout 5m -tags=integration ./...

cmd/openboot/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func main() {
1313
// or exits without proper cleanup (e.g., when invoked via curl|bash).
1414
if fd := int(os.Stdin.Fd()); term.IsTerminal(fd) {
1515
if oldState, err := term.GetState(fd); err == nil {
16-
defer term.Restore(fd, oldState)
16+
defer term.Restore(fd, oldState) //nolint:errcheck // best-effort terminal restore on exit
1717
}
1818
}
1919

internal/auth/auth.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,3 @@ func IsAuthenticated() bool {
8787
auth, err := LoadToken()
8888
return err == nil && auth != nil
8989
}
90-

internal/auth/auth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func TestDeleteToken_PermissionError(t *testing.T) {
267267

268268
require.NoError(t, os.Chmod(authDir, 0500))
269269
t.Cleanup(func() {
270-
os.Chmod(authDir, 0700)
270+
os.Chmod(authDir, 0700) //nolint:errcheck // cleanup restore; failure is non-critical in tests
271271
})
272272

273273
t.Setenv("HOME", tmpDir)
@@ -386,7 +386,7 @@ func TestLoadToken_ReadPermissionError(t *testing.T) {
386386
require.NoError(t, os.WriteFile(authFile, []byte("{}"), 0000))
387387

388388
t.Cleanup(func() {
389-
os.Chmod(authFile, 0600)
389+
os.Chmod(authFile, 0600) //nolint:errcheck // cleanup restore; failure is non-critical in tests
390390
})
391391

392392
t.Setenv("HOME", tmpDir)

internal/auth/login.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func startAuthSession(apiBase string) (codeID, code string, err error) {
111111
if err != nil {
112112
return "", "", fmt.Errorf("start auth session: %w", err)
113113
}
114-
defer resp.Body.Close()
114+
defer resp.Body.Close() //nolint:errcheck // best-effort; body already read
115115

116116
if resp.StatusCode != http.StatusOK {
117117
return "", "", fmt.Errorf("auth start failed with status %d", resp.StatusCode)
@@ -162,7 +162,7 @@ func pollOnce(pollURL string) (*cliPollResponse, bool, error) {
162162
if err != nil {
163163
return nil, false, nil
164164
}
165-
defer resp.Body.Close()
165+
defer resp.Body.Close() //nolint:errcheck // best-effort; body already read
166166

167167
var result cliPollResponse
168168
if err := json.NewDecoder(io.LimitReader(resp.Body, 1<<20)).Decode(&result); err != nil {

0 commit comments

Comments
 (0)