Skip to content

Commit cdaf170

Browse files
chore(ci): refresh
Signed-off-by: Thomas Fossati <[email protected]>
1 parent 3305dd1 commit cdaf170

File tree

11 files changed

+95
-86
lines changed

11 files changed

+95
-86
lines changed

.github/workflows/ci-go-cover.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# 2. Update README.md to use the new path to badge.svg because the path includes the workflow name.
1616

1717
name: cover ≥82.9%
18-
on: [push]
18+
on: [push, pull_request]
1919
jobs:
2020

2121
# Verify minimum coverage is reached using `go test -short -cover` on latest-ubuntu with default version of Go.
@@ -24,8 +24,11 @@ jobs:
2424
name: Coverage
2525
runs-on: ubuntu-latest
2626
steps:
27+
- uses: actions/setup-go@v5
28+
with:
29+
go-version: "1.23.0"
2730
- name: Checkout code
28-
uses: actions/checkout@v2
31+
uses: actions/checkout@v4
2932
- name: Go Coverage
3033
run: |
3134
go version

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
# GitHub Actions - CI for Go to build & test. See ci-go-cover.yml and linters.yml for code coverage and linters.
22
# Taken from: https://github.com/fxamacker/cbor/workflows/ci.yml (thanks!)
33
name: ci
4-
on: [push]
4+
on: [push, pull_request]
55
jobs:
66

77
# Test on Ubuntu
88
tests:
99
name: Test on Ubuntu
1010
runs-on: ubuntu-latest
1111
steps:
12+
- uses: actions/setup-go@v5
13+
with:
14+
go-version: "1.23.0"
1215
- name: Checkout code
13-
uses: actions/checkout@v1
16+
uses: actions/checkout@v4
1417
with:
1518
fetch-depth: 1
1619
- name: Run tests
1720
run: |
1821
go version
19-
make test
22+
make test

.github/workflows/linters.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
# Go Linters - GitHub Actions
22
name: linters
3-
on: [push]
3+
on: [push, pull_request]
44
jobs:
55

66
# Check linters on latest-ubuntu with default version of Go.
77
lint:
88
name: Lint
99
runs-on: ubuntu-latest
10-
env:
11-
GO111MODULE: on
1210
steps:
13-
- name: Setup go
14-
uses: actions/setup-go@v3
11+
- uses: actions/setup-go@v3
1512
with:
16-
go-version: "1.19"
13+
go-version: "1.23"
1714
- name: Checkout code
1815
uses: actions/checkout@v2
1916
- name: Install golangci-lint
2017
run: |
2118
go version
22-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.48.0
19+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.1.6
2320
- name: Run required linters in .golangci.yml plus hard-coded ones here
2421
run: make -w GOLINT=$(go env GOPATH)/bin/golangci-lint lint
25-
- name: Run optional linters (not required to pass)
26-
run: make GOLINT=$(go env GOPATH)/bin/golangci-lint lint-extra

.golangci.yml

Lines changed: 67 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,69 @@
11
# Do not delete linter settings. Linters like gocritic can be enabled on the command line.
22

3-
linters-settings:
4-
dupl:
5-
threshold: 100
6-
funlen:
7-
lines: 100
8-
statements: 50
9-
goconst:
10-
min-len: 2
11-
min-occurrences: 3
12-
gocritic:
13-
enabled-tags:
14-
- diagnostic
15-
- experimental
16-
- opinionated
17-
- performance
18-
- style
19-
disabled-checks:
20-
- dupImport # https://github.com/go-critic/go-critic/issues/845
21-
- ifElseChain
22-
- octalLiteral
23-
- paramTypeCombine
24-
- whyNoLint
25-
- wrapperFunc
26-
gofmt:
27-
simplify: false
28-
goimports:
29-
golint:
30-
min-confidence: 0
31-
govet:
32-
check-shadowing: true
33-
lll:
34-
line-length: 140
35-
maligned:
36-
suggest-new: true
37-
misspell:
38-
locale: US
39-
40-
linters:
41-
disable-all: true
3+
formatters:
424
enable:
43-
- deadcode
44-
- errcheck
45-
- goconst
46-
- gocyclo
475
- gofmt
486
- goimports
49-
- golint
50-
- gosec
51-
- govet
52-
- ineffassign
53-
- maligned
54-
- misspell
55-
- staticcheck
56-
- structcheck
57-
- typecheck
58-
- unconvert
59-
- unused
60-
- varcheck
7+
settings:
8+
gofmt:
9+
simplify: false
6110

11+
linters:
12+
default: none
13+
enable:
14+
- dupl # style
15+
- errcheck # bugs
16+
- funlen # complexity
17+
- goconst # style
18+
- gocritic # metalinter
19+
- gocyclo # complexity
20+
- gosec # bugs
21+
- govet # bugs
22+
- ineffassign
23+
- lll # style
24+
- misspell # comment
25+
- staticcheck # metalinter
26+
- unconvert # style
27+
- unused # unused
28+
exclusions:
29+
rules:
30+
- path: '(.+)_test\.go'
31+
linters:
32+
- dupl
33+
- funlen
34+
- lll
35+
- goconst
36+
settings:
37+
dupl:
38+
threshold: 100
39+
funlen:
40+
lines: 100
41+
statements: 50
42+
goconst:
43+
min-len: 2
44+
min-occurrences: 3
45+
gocritic:
46+
enabled-tags:
47+
- diagnostic
48+
- experimental
49+
- opinionated
50+
- performance
51+
- style
52+
disabled-checks:
53+
- dupImport # https://github.com/go-critic/go-critic/issues/845
54+
- ifElseChain
55+
- octalLiteral
56+
- paramTypeCombine
57+
- whyNoLint
58+
- wrapperFunc
59+
- hugeParam
60+
govet:
61+
enable:
62+
- shadow
63+
lll:
64+
line-length: 140
65+
misspell:
66+
locale: US
6267

6368
issues:
6469
# max-issues-per-linter default is 50. Set to 0 to disable limit.
@@ -72,14 +77,16 @@ issues:
7277
- goconst
7378
- dupl
7479
- gomnd
75-
- lll
80+
- lll
7681
- path: doc\.go
7782
linters:
7883
- goimports
7984
- gomnd
8085
- lll
86+
- path: psatoken_fuzz_test.go
87+
linters:
88+
# the Fuzz function is only invoked by go-fuzz, therefore golangci will
89+
# see it as unused
90+
- unused
8191

82-
# golangci.com configuration
83-
# https://github.com/golangci/golangci/wiki/Configuration
84-
service:
85-
golangci-lint-version: 1.23.x # use the fixed version to not introduce new linters unexpectedly
92+
version: "2"

auth/tls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func NewTLSTransport(certPaths []string) (*http.Transport, error) {
1919
}
2020

2121
for _, certPath := range certPaths {
22-
rawCert, err := os.ReadFile(certPath)
22+
rawCert, err := os.ReadFile(certPath) // nolint: gosec
2323
if err != nil {
2424
return nil, fmt.Errorf("could not read cert: %w", err)
2525
}

common/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func ResolveReference(baseURI, referenceURI string) (string, error) {
4343
}
4444

4545
func DecodeJSONBody(res *http.Response, j interface{}) error {
46-
defer res.Body.Close()
46+
defer res.Body.Close() // nolint: errcheck
4747

4848
return json.NewDecoder(res.Body).Decode(&j)
4949
}

provisioning/provisioning.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ func (cfg SubmitConfig) Run(endorsement []byte, mediaType string) error {
128128
// see whether the server is handling our request synchronously or not
129129
// (sync)
130130
if res.StatusCode == http.StatusOK {
131-
if j.Status == common.APIStatusSuccess {
131+
switch j.Status {
132+
case common.APIStatusSuccess:
132133
return nil
133-
} else if j.Status == common.APIStatusFailed {
134+
case common.APIStatusFailed:
134135
s := "submission failed"
135136
if j.FailureReason != nil {
136137
s += fmt.Sprintf(": %s", *j.FailureReason)

verification/challengeresponse.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (cfg *ChallengeResponseConfig) Run() ([]byte, error) {
175175
return cfg.ChallengeResponse(evidence, mediaType, sessionURI)
176176
}
177177

178-
func (cfg ChallengeResponseConfig) wrapEvidenceInCMW(evidence []byte, mt string) ([]byte, string, error) {
178+
func (cfg ChallengeResponseConfig) wrapEvidenceInCMW(evidence []byte, mt string) ([]byte, string, error) { // nolint: gocritic
179179
c, err := cmw.NewMonad(mt, evidence, cmw.Evidence)
180180
if err != nil {
181181
return nil, "", fmt.Errorf("CMW creation failed: %w", err)
@@ -185,13 +185,13 @@ func (cfg ChallengeResponseConfig) wrapEvidenceInCMW(evidence []byte, mt string)
185185
case WrapCBOR:
186186
cm, err := c.MarshalCBOR()
187187
if err != nil {
188-
return nil, "", fmt.Errorf("CMW CBOR marshalling failed: %w", err)
188+
return nil, "", fmt.Errorf("CMW CBOR marshaling failed: %w", err)
189189
}
190190
return cm, "application/vnd.veraison.cmw+cbor", nil
191191
case WrapJSON:
192192
cm, err := c.MarshalJSON()
193193
if err != nil {
194-
return nil, "", fmt.Errorf("CMW JSON marshalling failed: %w", err)
194+
return nil, "", fmt.Errorf("CMW JSON marshaling failed: %w", err)
195195
}
196196
return cm, "application/vnd.veraison.cmw+json", nil
197197
}

verification/challengeresponse_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func TestChallengeResponseConfig_ChallengeResponse_sync_ok(t *testing.T) {
378378
assert.Equal(t, http.MethodPost, r.Method)
379379
assert.Equal(t, "application/vnd.veraison.challenge-response-session+json", r.Header.Get("Accept"))
380380
assert.Equal(t, mediaType, r.Header.Get("Content-Type"))
381-
defer r.Body.Close()
381+
defer r.Body.Close() // nolint: errcheck
382382
reqBody, _ := io.ReadAll(r.Body)
383383
assert.Equal(t, evidence, reqBody)
384384

@@ -883,7 +883,7 @@ func TestChallengeResponseConfig_Run_async_CMWWrap(t *testing.T) {
883883
})
884884

885885
client, teardown := common.NewTestingHTTPClient(h)
886-
defer teardown()
886+
defer teardown() // nolint: gocritic
887887
cfg := ChallengeResponseConfig{
888888
Nonce: testNonce,
889889
NewSessionURI: testNewSessionURI,

verification/discovery.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (cfg *DiscoveryConfig) SetIsInsecure() {
5454

5555
// SetCerts sets the CA certificates to the specified paths
5656
func (cfg *DiscoveryConfig) SetCerts(paths []string) error {
57-
if paths == nil || len(paths) == 0 {
57+
if len(paths) == 0 {
5858
return errors.New("no CA certificate paths supplied")
5959
}
6060
cfg.caCerts = paths

0 commit comments

Comments
 (0)