Skip to content

Commit

Permalink
chore: update go and golanci lint (#810)
Browse files Browse the repository at this point in the history
This PR updates go to 1.23.1 and updates golanci-lint to v1.61.1, while
fixing new lint errors.

---------

Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <32398091+ramonpetgrave64@users.noreply.github.com>
  • Loading branch information
ramonpetgrave64 authored Oct 10, 2024
1 parent 9093b4f commit 4cd7d48
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 170 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pre-submit.lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
go-version-file: "go.mod"
# not needed but gets rid of warnings
cache: false
- uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
name: golangci-lint
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.59.1
version: v1.61.0

yamllint:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ run:
concurrency: 2
deadline: 5m
# For generics.
go: 1.18
issues:
include:
- EXC0012
Expand Down Expand Up @@ -32,7 +31,7 @@ linters:
# - errcheck
- errorlint
- exhaustive
- exportloopref
- copyloopvar
# TODO(https://github.com/slsa-framework/slsa-verifier/issues/363): Restore linter
# - gci
- gochecknoinits
Expand Down
10 changes: 2 additions & 8 deletions cli/slsa-verifier/main_regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
// Avoid rate limiting by not running the tests in parallel.
// t.Parallel()
Expand Down Expand Up @@ -805,7 +804,6 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -866,7 +864,7 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {

outBuilderID, err := cmd.Exec(context.Background(), []string{image})
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}

if err != nil {
Expand Down Expand Up @@ -1267,7 +1265,6 @@ func Test_runVerifyGCBArtifactImage(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1335,7 +1332,7 @@ func Test_runVerifyGCBArtifactImage(t *testing.T) {
outBuilderID, err := cmd.Exec(context.Background(), []string{image})

if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}

if err != nil {
Expand Down Expand Up @@ -1432,7 +1429,6 @@ func Test_runVerifyGHAContainerBased(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1958,7 +1954,6 @@ func Test_runVerifyNpmPackage(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -2023,7 +2018,6 @@ func Test_runVerifyVSA(t *testing.T) {
}

for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/slsa-framework/slsa-verifier/v2

go 1.22.0
go 1.23.1

require (
github.com/docker/go v1.5.1-1
Expand Down
40 changes: 14 additions & 26 deletions verifiers/internal/gcb/provenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func Test_VerifyBuilder(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -216,7 +215,7 @@ func Test_VerifyBuilder(t *testing.T) {
}
outBuilderID, err := prov.VerifyBuilder(&builderOpts)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}

if err != nil {
Expand All @@ -228,7 +227,7 @@ func Test_VerifyBuilder(t *testing.T) {
}

if err := outBuilderID.MatchesLoose(tt.builderID, false); err != nil {
t.Errorf(fmt.Sprintf("matches failed: %v", err))
t.Errorf("matches failed: %v", err)
}
})
}
Expand Down Expand Up @@ -304,7 +303,6 @@ func Test_validateBuildType(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -315,7 +313,7 @@ func Test_validateBuildType(t *testing.T) {
}
err = validateBuildType(*builderID, tt.buildType)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -554,7 +552,6 @@ func Test_VerifySourceURI(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -582,7 +579,7 @@ func Test_VerifySourceURI(t *testing.T) {
}
err = prov.VerifySourceURI(tt.source, *builderID)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -692,7 +689,6 @@ func Test_VerifySignature(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -708,7 +704,7 @@ func Test_VerifySignature(t *testing.T) {

err = prov.VerifySignature()
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -739,7 +735,6 @@ func Test_ProvenanceFromBytes(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -750,7 +745,7 @@ func Test_ProvenanceFromBytes(t *testing.T) {

_, err = ProvenanceFromBytes(content)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -793,7 +788,6 @@ func Test_VerifySubjectDigest(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -816,7 +810,7 @@ func Test_VerifySubjectDigest(t *testing.T) {

err = prov.VerifySubjectDigest(tt.hash)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -870,7 +864,6 @@ func Test_VerifySummary(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -896,7 +889,7 @@ func Test_VerifySummary(t *testing.T) {
}
err = prov.VerifySummary(&provenanceOpts)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -952,7 +945,6 @@ func Test_VerifyMetadata(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -978,7 +970,7 @@ func Test_VerifyMetadata(t *testing.T) {
}
err = prov.VerifyMetadata(&provenanceOpts)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -1023,7 +1015,6 @@ func Test_VerifyTextProvenance(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -1047,7 +1038,7 @@ func Test_VerifyTextProvenance(t *testing.T) {
if !tt.alter {
err = prov.VerifyTextProvenance()
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
return
}
Expand Down Expand Up @@ -1119,7 +1110,7 @@ func Test_VerifyTextProvenance(t *testing.T) {

err = prov.VerifyTextProvenance()
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
// Start with the original string value.
patch = []byte(strings.Clone(string(cpy)))
Expand Down Expand Up @@ -1171,7 +1162,6 @@ func Test_VerifyBranch(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -1194,7 +1184,7 @@ func Test_VerifyBranch(t *testing.T) {

err = prov.VerifyBranch(tt.branch)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -1285,7 +1275,6 @@ func Test_VerifyTag(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -1308,7 +1297,7 @@ func Test_VerifyTag(t *testing.T) {

err = prov.VerifyTag(tt.tag)
if !cmp.Equal(err, tt.err, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -1485,7 +1474,6 @@ func Test_VerifyVersionedTag(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -1508,7 +1496,7 @@ func Test_VerifyVersionedTag(t *testing.T) {

err = prov.VerifyVersionedTag(tt.tag)
if !cmp.Equal(err, tt.err, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
})
}
Expand Down
8 changes: 3 additions & 5 deletions verifiers/internal/gcb/slsaprovenance/v0.1/provenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func Test_New(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -51,7 +50,7 @@ func Test_New(t *testing.T) {
fmt.Println(string(content))
_, err = New(content)
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.expected, cmpopts.EquateErrors()))
}
})
}
Expand Down Expand Up @@ -92,7 +91,6 @@ func Test_getSubstitutionsField(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -109,10 +107,10 @@ func Test_getSubstitutionsField(t *testing.T) {

value, err := getSubstitutionsField(internalParemeters, tt.field)
if !cmp.Equal(err, tt.err, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
if err == nil && !cmp.Equal(value, tt.value) {
t.Errorf(cmp.Diff(value, tt.value))
t.Error(cmp.Diff(value, tt.value))
}
})
}
Expand Down
5 changes: 2 additions & 3 deletions verifiers/internal/gcb/slsaprovenance/v1.0/provenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func Test_getSubstitutionsField(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -58,10 +57,10 @@ func Test_getSubstitutionsField(t *testing.T) {

value, err := getSubstitutionsField(internalParemeters, tt.field)
if !cmp.Equal(err, tt.err, cmpopts.EquateErrors()) {
t.Errorf(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
t.Error(cmp.Diff(err, tt.err, cmpopts.EquateErrors()))
}
if err == nil && !cmp.Equal(value, tt.value) {
t.Errorf(cmp.Diff(value, tt.value))
t.Error(cmp.Diff(value, tt.value))
}
})
}
Expand Down
Loading

0 comments on commit 4cd7d48

Please sign in to comment.