diff --git a/workhorse/_support/lint_last_known_acceptable_go1.21.txt b/workhorse/_support/lint_last_known_acceptable_go1.21.txt index f090f27f10407dea086f82f6957e360bd258a52d..239016c99e247d366b50f7c0e600c0a0809fac63 100644 --- a/workhorse/_support/lint_last_known_acceptable_go1.21.txt +++ b/workhorse/_support/lint_last_known_acceptable_go1.21.txt @@ -70,9 +70,6 @@ internal/api/api.go:153:2: var-naming: don't use ALL_CAPS in Go names; use Camel internal/api/block_test.go:61:34: response body must be closed (bodyclose) internal/api/channel_settings.go:57:28: G402: TLS MinVersion too low. (gosec) internal/api/channel_settings_test.go:125:22: SA1019: dialer.TLSClientConfig.RootCAs.Subjects has been deprecated since Go 1.18: if s was returned by SystemCertPool, Subjects will not include the system roots. (staticcheck) -internal/badgateway/roundtripper_test.go:76:3: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/badgateway/roundtripper_test.go:80:3: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/badgateway/roundtripper_test.go:81:3: go-require: require must only be used in the goroutine running the test function (testifylint) internal/builds/register.go:120: Function 'RegisterHandler' is too long (66 > 60) (funlen) internal/channel/channel.go:128:31: response body must be closed (bodyclose) internal/config/config.go:1:1: package-comments: should have a package comment (revive) @@ -139,8 +136,7 @@ internal/git/responsewriter.go:45:1: exported: exported function NewHTTPResponse internal/git/responsewriter.go:52:1: exported: exported method HTTPResponseWriter.Log should have comment or be unexported (revive) internal/git/snapshot.go:27:2: exported: exported var SendSnapshot should have comment or be unexported (revive) internal/git/upload-pack.go:37:16: Error return value of `cw.Flush` is not checked (errcheck) -internal/git/upload-pack_test.go:70:2: error-is-as: use require.ErrorIs (testifylint) -internal/git/upload-pack_test.go:85:3: go-require: require must only be used in the goroutine running the test function (testifylint) +internal/git/upload-pack_test.go:71:2: error-is-as: use require.ErrorIs (testifylint) internal/gitaly/blob.go:1:1: package-comments: should have a package comment (revive) internal/gitaly/blob.go:14:6: exported: exported type BlobClient should have comment or be unexported (revive) internal/gitaly/blob.go:18:1: exported: exported method BlobClient.SendBlob should have comment or be unexported (revive) @@ -206,13 +202,6 @@ internal/redis/keywatcher.go:150:1: exported: exported method KeyWatcher.Shutdow internal/redis/keywatcher.go:232:23: Error return value of `kw.conn.Unsubscribe` is not checked (errcheck) internal/redis/keywatcher.go:252:1: exported: exported method KeyWatcher.WatchKey should have comment or be unexported (revive) internal/redis/keywatcher_test.go:120:38: unnecessary leading newline (whitespace) -internal/redis/keywatcher_test.go:189:5: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:190:5: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:241:6: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:242:6: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:267:3: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:268:3: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:273:3: go-require: require must only be used in the goroutine running the test function (testifylint) internal/redis/redis.go:1:1: ST1000: at least one file in a package should have a package comment (stylecheck) internal/redis/redis.go:16:2: blank-imports: a blank import should be only in a main or test package, or have a comment justifying it (revive) internal/redis/redis.go:21:24: var-declaration: should omit type error from declaration of var errSentinelMasterAddr; it will be inferred from the right-hand side (revive) @@ -239,9 +228,6 @@ internal/upload/destination/destination.go:117: Function 'Upload' has too many s internal/upload/destination/multi_hash.go:4:2: G501: Blocklisted import crypto/md5: weak cryptographic primitive (gosec) internal/upload/destination/multi_hash.go:5:2: G505: Blocklisted import crypto/sha1: weak cryptographic primitive (gosec) internal/upload/destination/objectstore/object_test.go:127:4: go-require: do not use assert.FailNow in http handlers (testifylint) -internal/upload/destination/objectstore/s3_object_test.go:105:4: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/upload/destination/objectstore/s3_object_test.go:109:4: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/upload/destination/objectstore/s3_object_test.go:110:4: go-require: require must only be used in the goroutine running the test function (testifylint) internal/upload/destination/objectstore/test/objectstore_stub.go:4:2: G501: Blocklisted import crypto/md5: weak cryptographic primitive (gosec) internal/upload/destination/objectstore/test/objectstore_stub.go:169:13: G401: Use of weak cryptographic primitive (gosec) internal/upload/destination/objectstore/upload_strategy.go:29: internal/upload/destination/objectstore/upload_strategy.go:29: Line contains TODO/BUG/FIXME/NOTE/OPTIMIZE/HACK: "TODO: consider adding the context to the..." (godox) diff --git a/workhorse/_support/lint_last_known_acceptable_go1.22.txt b/workhorse/_support/lint_last_known_acceptable_go1.22.txt index 34c582e1c82aa6de11f4626e4cf17943cf2a3121..da7682c8e2709eb63e7c38b35f14a9ed903ba2e0 100644 --- a/workhorse/_support/lint_last_known_acceptable_go1.22.txt +++ b/workhorse/_support/lint_last_known_acceptable_go1.22.txt @@ -70,9 +70,6 @@ internal/api/api.go:153:2: var-naming: don't use ALL_CAPS in Go names; use Camel internal/api/block_test.go:61:34: response body must be closed (bodyclose) internal/api/channel_settings.go:57:28: G402: TLS MinVersion too low. (gosec) internal/api/channel_settings_test.go:125:22: SA1019: dialer.TLSClientConfig.RootCAs.Subjects has been deprecated since Go 1.18: if s was returned by [SystemCertPool], Subjects will not include the system roots. (staticcheck) -internal/badgateway/roundtripper_test.go:76:3: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/badgateway/roundtripper_test.go:80:3: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/badgateway/roundtripper_test.go:81:3: go-require: require must only be used in the goroutine running the test function (testifylint) internal/builds/register.go:120: Function 'RegisterHandler' is too long (66 > 60) (funlen) internal/channel/channel.go:128:31: response body must be closed (bodyclose) internal/config/config.go:1:1: package-comments: should have a package comment (revive) @@ -139,8 +136,7 @@ internal/git/responsewriter.go:45:1: exported: exported function NewHTTPResponse internal/git/responsewriter.go:52:1: exported: exported method HTTPResponseWriter.Log should have comment or be unexported (revive) internal/git/snapshot.go:27:2: exported: exported var SendSnapshot should have comment or be unexported (revive) internal/git/upload-pack.go:37:16: Error return value of `cw.Flush` is not checked (errcheck) -internal/git/upload-pack_test.go:70:2: error-is-as: use require.ErrorIs (testifylint) -internal/git/upload-pack_test.go:85:3: go-require: require must only be used in the goroutine running the test function (testifylint) +internal/git/upload-pack_test.go:71:2: error-is-as: use require.ErrorIs (testifylint) internal/gitaly/blob.go:1:1: package-comments: should have a package comment (revive) internal/gitaly/blob.go:14:6: exported: exported type BlobClient should have comment or be unexported (revive) internal/gitaly/blob.go:18:1: exported: exported method BlobClient.SendBlob should have comment or be unexported (revive) @@ -206,13 +202,6 @@ internal/redis/keywatcher.go:150:1: exported: exported method KeyWatcher.Shutdow internal/redis/keywatcher.go:232:23: Error return value of `kw.conn.Unsubscribe` is not checked (errcheck) internal/redis/keywatcher.go:252:1: exported: exported method KeyWatcher.WatchKey should have comment or be unexported (revive) internal/redis/keywatcher_test.go:120:38: unnecessary leading newline (whitespace) -internal/redis/keywatcher_test.go:189:5: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:190:5: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:241:6: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:242:6: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:267:3: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:268:3: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/redis/keywatcher_test.go:273:3: go-require: require must only be used in the goroutine running the test function (testifylint) internal/redis/redis.go:1:1: ST1000: at least one file in a package should have a package comment (stylecheck) internal/redis/redis.go:16:2: blank-imports: a blank import should be only in a main or test package, or have a comment justifying it (revive) internal/redis/redis.go:21:24: var-declaration: should omit type error from declaration of var errSentinelMasterAddr; it will be inferred from the right-hand side (revive) @@ -239,9 +228,6 @@ internal/upload/destination/destination.go:117: Function 'Upload' has too many s internal/upload/destination/multi_hash.go:4:2: G501: Blocklisted import crypto/md5: weak cryptographic primitive (gosec) internal/upload/destination/multi_hash.go:5:2: G505: Blocklisted import crypto/sha1: weak cryptographic primitive (gosec) internal/upload/destination/objectstore/object_test.go:127:4: go-require: do not use assert.FailNow in http handlers (testifylint) -internal/upload/destination/objectstore/s3_object_test.go:105:4: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/upload/destination/objectstore/s3_object_test.go:109:4: go-require: require must only be used in the goroutine running the test function (testifylint) -internal/upload/destination/objectstore/s3_object_test.go:110:4: go-require: require must only be used in the goroutine running the test function (testifylint) internal/upload/destination/objectstore/test/objectstore_stub.go:4:2: G501: Blocklisted import crypto/md5: weak cryptographic primitive (gosec) internal/upload/destination/objectstore/test/objectstore_stub.go:169:13: G401: Use of weak cryptographic primitive (gosec) internal/upload/destination/objectstore/upload_strategy.go:29: internal/upload/destination/objectstore/upload_strategy.go:29: Line contains TODO/BUG/FIXME/NOTE/OPTIMIZE/HACK: "TODO: consider adding the context to the..." (godox) diff --git a/workhorse/internal/badgateway/roundtripper_test.go b/workhorse/internal/badgateway/roundtripper_test.go index ed2de452f807ab7ded87e68954fec96bc6743451..0f895218cbfb6d130131bf78160abe2384766b88 100644 --- a/workhorse/internal/badgateway/roundtripper_test.go +++ b/workhorse/internal/badgateway/roundtripper_test.go @@ -8,6 +8,7 @@ import ( "net/http/httptest" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -73,12 +74,12 @@ func TestClientDisconnect499(t *testing.T) { go func() { req, err := http.NewRequestWithContext(clientContext, "GET", ts.URL, nil) - require.NoError(t, err, "build request") + assert.NoError(t, err, "build request") rt := NewRoundTripper(false, http.DefaultTransport) response, err := rt.RoundTrip(req) - require.NoError(t, err, "perform roundtrip") - require.NoError(t, response.Body.Close()) + assert.NoError(t, err, "perform roundtrip") + assert.NoError(t, response.Body.Close()) clientResponse <- response }() diff --git a/workhorse/internal/git/upload-pack_test.go b/workhorse/internal/git/upload-pack_test.go index 2cb0e7c4d8a83e3bd1851cd3aee55c7b95363a67..90aeac6276343a1a455bb8833edc66e31254f6bd 100644 --- a/workhorse/internal/git/upload-pack_test.go +++ b/workhorse/internal/git/upload-pack_test.go @@ -11,6 +11,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc" @@ -82,7 +83,7 @@ func startSmartHTTPServer(t testing.TB, s gitalypb.SmartHTTPServiceServer) strin srv := grpc.NewServer(testhelper.WithSidechannel()) gitalypb.RegisterSmartHTTPServiceServer(srv, s) go func() { - require.NoError(t, srv.Serve(ln)) + assert.NoError(t, srv.Serve(ln)) }() t.Cleanup(func() { diff --git a/workhorse/internal/redis/keywatcher_test.go b/workhorse/internal/redis/keywatcher_test.go index 0e3278f2d265be23e219dee08f765cb47efeb144..f6a830d5969a34189a3d819f2ffc3383129f1f1f 100644 --- a/workhorse/internal/redis/keywatcher_test.go +++ b/workhorse/internal/redis/keywatcher_test.go @@ -186,8 +186,8 @@ func TestKeyChangesWhenWatching(t *testing.T) { <-ready val, err := kw.WatchKey(ctx, runnerKey, tc.watchValue, time.Second) - require.NoError(t, err, "Expected no error") - require.Equal(t, tc.expectedStatus, val, "Expected value") + assert.NoError(t, err, "Expected no error") + assert.Equal(t, tc.expectedStatus, val, "Expected value") }() processMessages(t, kw, 1, tc.processedValue, ready, wg) @@ -238,8 +238,8 @@ func TestKeyChangesParallel(t *testing.T) { <-ready val, err := kw.WatchKey(ctx, runnerKey, tc.watchValue, time.Second) - require.NoError(t, err, "Expected no error") - require.Equal(t, tc.expectedStatus, val, "Expected value") + assert.NoError(t, err, "Expected no error") + assert.Equal(t, tc.expectedStatus, val, "Expected value") }() } @@ -264,13 +264,13 @@ func TestShutdown(t *testing.T) { defer wg.Done() val, err := kw.WatchKey(ctx, runnerKey, "something", 10*time.Second) - require.NoError(t, err, "Expected no error") - require.Equal(t, WatchKeyStatusNoChange, val, "Expected value not to change") + assert.NoError(t, err, "Expected no error") + assert.Equal(t, WatchKeyStatusNoChange, val, "Expected value not to change") }() go func() { defer wg.Done() - require.Eventually(t, func() bool { return countSubscribers(kw, runnerKey) == 1 }, 10*time.Second, time.Millisecond) + assert.Eventually(t, func() bool { return countSubscribers(kw, runnerKey) == 1 }, 10*time.Second, time.Millisecond) kw.Shutdown() }() diff --git a/workhorse/internal/upload/destination/objectstore/s3_object_test.go b/workhorse/internal/upload/destination/objectstore/s3_object_test.go index ea0dd0f84ba233ee86d9a6af9a5597c6bbcc83ca..1063257d494781fd8dc61160d12ee62db46d286d 100644 --- a/workhorse/internal/upload/destination/objectstore/s3_object_test.go +++ b/workhorse/internal/upload/destination/objectstore/s3_object_test.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab/workhorse/internal/config" @@ -102,12 +103,12 @@ func TestConcurrentS3ObjectUpload(t *testing.T) { defer cancel() object, err := NewS3Object(objectName, creds, config) - require.NoError(t, err) + assert.NoError(t, err) // copy data n, err := object.Consume(ctx, strings.NewReader(test.ObjectContent), deadline) - require.NoError(t, err) - require.Equal(t, test.ObjectSize, n, "Uploaded file mismatch") + assert.NoError(t, err) + assert.Equal(t, test.ObjectSize, n, "Uploaded file mismatch") test.S3ObjectExists(t, sess, config, objectName, test.ObjectContent) wg.Done()