Skip to content

Commit

Permalink
chore(deps): Bump golangci-lint to 1.60.2
Browse files Browse the repository at this point in the history
  • Loading branch information
silvestre committed Aug 29, 2024
1 parent 8a47e60 commit 56bac46
Show file tree
Hide file tree
Showing 26 changed files with 132 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ direnv 2.34.0
gcloud 473.0.0
ginkgo 2.20.0
golang 1.22.2
golangci-lint 1.59.1
golangci-lint 1.60.2
java temurin-21.0.3+9.0.LTS
make 4.4
maven 3.8.6
Expand Down
6 changes: 3 additions & 3 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"bundix": "latest",
"cloudfoundry-cli": "8.7.11",
"coreutils": "latest",
"credhub-cli": "2.9.35",
"delve": "latest",
"direnv": "2.34.0",
"fly": "7.10.0",
Expand All @@ -20,7 +19,6 @@
"gnumake": "4.4",
"gnutar": "latest",
"go-tools": "latest",
"golangci-lint": "1.59.1",
"gopls": "latest",
"gum": "0.13.0",
"jq": "latest",
Expand All @@ -37,8 +35,10 @@
"swagger-cli": "latest",
"which": "latest",
"yq-go": "4.44.2",
"google-cloud-sdk": "latest",
"go": "1.22.2",
"golangci-lint": "1.60.2",
"credhub-cli": "2.9.29",
"google-cloud-sdk": "latest",
"temurin-bin-21": "latest",
"ruby": "latest"
},
Expand Down
49 changes: 24 additions & 25 deletions devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -313,51 +313,51 @@
}
}
},
"[email protected].35": {
"last_modified": "2024-08-14T11:41:26Z",
"resolved": "github:NixOS/nixpkgs/0cb2fd7c59fed0cd82ef858cbcbdb552b9a33465#credhub-cli",
"[email protected].29": {
"last_modified": "2024-05-29T10:04:41Z",
"resolved": "github:NixOS/nixpkgs/ac82a513e55582291805d6f09d35b6d8b60637a1#credhub-cli",
"source": "devbox-search",
"version": "2.9.35",
"version": "2.9.29",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/2xkv0vlafk8zgzjpz3yjagbgyv5kawkn-credhub-cli-2.9.35",
"path": "/nix/store/20xi78w44q6wn4847jrrlmxddyjycbrn-credhub-cli-2.9.29",
"default": true
}
],
"store_path": "/nix/store/2xkv0vlafk8zgzjpz3yjagbgyv5kawkn-credhub-cli-2.9.35"
"store_path": "/nix/store/20xi78w44q6wn4847jrrlmxddyjycbrn-credhub-cli-2.9.29"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/r0kkggv2kbdma8l2n177nl0sw4lwvqr5-credhub-cli-2.9.35",
"path": "/nix/store/5hv8vj4dhy521m49sc4wwmaz2q319z9a-credhub-cli-2.9.29",
"default": true
}
],
"store_path": "/nix/store/r0kkggv2kbdma8l2n177nl0sw4lwvqr5-credhub-cli-2.9.35"
"store_path": "/nix/store/5hv8vj4dhy521m49sc4wwmaz2q319z9a-credhub-cli-2.9.29"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/wkgc414d175cv1pa3h257pm264ayk8if-credhub-cli-2.9.35",
"path": "/nix/store/c5d2ggn5c819spywi74pzksbzds9ryym-credhub-cli-2.9.29",
"default": true
}
],
"store_path": "/nix/store/wkgc414d175cv1pa3h257pm264ayk8if-credhub-cli-2.9.35"
"store_path": "/nix/store/c5d2ggn5c819spywi74pzksbzds9ryym-credhub-cli-2.9.29"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/zkmy2g042p75p3i6qib6s1589qymrg3k-credhub-cli-2.9.35",
"path": "/nix/store/3y6r6lgrbaq8521hk3zbalf3gz3albcg-credhub-cli-2.9.29",
"default": true
}
],
"store_path": "/nix/store/zkmy2g042p75p3i6qib6s1589qymrg3k-credhub-cli-2.9.35"
"store_path": "/nix/store/3y6r6lgrbaq8521hk3zbalf3gz3albcg-credhub-cli-2.9.29"
}
}
},
Expand Down Expand Up @@ -853,51 +853,51 @@
}
}
},
"golangci-lint@1.59.1": {
"last_modified": "2024-07-31T08:48:38Z",
"resolved": "github:NixOS/nixpkgs/c3392ad349a5227f4a3464dce87bcc5046692fce#golangci-lint",
"golangci-lint@1.60.2": {
"last_modified": "2024-08-21T11:30:02Z",
"resolved": "github:NixOS/nixpkgs/f132a77a82530de0d10216f09857090d324fee05#golangci-lint",
"source": "devbox-search",
"version": "1.59.1",
"version": "1.60.2",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/k3rnfx753gnx5v8l3i4sx1g1al2ds0di-golangci-lint-1.59.1",
"path": "/nix/store/zl8l769wimy5bsvrlcvq9f6b7465z4hx-golangci-lint-1.60.2",
"default": true
}
],
"store_path": "/nix/store/k3rnfx753gnx5v8l3i4sx1g1al2ds0di-golangci-lint-1.59.1"
"store_path": "/nix/store/zl8l769wimy5bsvrlcvq9f6b7465z4hx-golangci-lint-1.60.2"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/29908ar68rrr9jzdhzcrlkbfk30gnihf-golangci-lint-1.59.1",
"path": "/nix/store/drgzg08jxcc50azd6bchxy6gcym2kwav-golangci-lint-1.60.2",
"default": true
}
],
"store_path": "/nix/store/29908ar68rrr9jzdhzcrlkbfk30gnihf-golangci-lint-1.59.1"
"store_path": "/nix/store/drgzg08jxcc50azd6bchxy6gcym2kwav-golangci-lint-1.60.2"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/v7882fqgdy46a7l432q11f3xmbln80rc-golangci-lint-1.59.1",
"path": "/nix/store/my7afydss5zsi4z30mzshj31bm2v5chd-golangci-lint-1.60.2",
"default": true
}
],
"store_path": "/nix/store/v7882fqgdy46a7l432q11f3xmbln80rc-golangci-lint-1.59.1"
"store_path": "/nix/store/my7afydss5zsi4z30mzshj31bm2v5chd-golangci-lint-1.60.2"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/1m1i9zhrgdw2192803n6wf2k7g86y6d5-golangci-lint-1.59.1",
"path": "/nix/store/rp23zfccxkvzqphhrx0sp2pz682v89r8-golangci-lint-1.60.2",
"default": true
}
],
"store_path": "/nix/store/1m1i9zhrgdw2192803n6wf2k7g86y6d5-golangci-lint-1.59.1"
"store_path": "/nix/store/rp23zfccxkvzqphhrx0sp2pz682v89r8-golangci-lint-1.60.2"
}
}
},
Expand Down Expand Up @@ -1666,7 +1666,6 @@
},
"ruby@latest": {
"last_modified": "2024-08-14T11:41:26Z",
"plugin_version": "0.0.2",
"resolved": "github:NixOS/nixpkgs/0cb2fd7c59fed0cd82ef858cbcbdb552b9a33465#ruby_3_3",
"source": "devbox-search",
"version": "3.3.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/golangapiserver/spec
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,7 @@ files:
- autoscaler/vendor/google.golang.org/protobuf/runtime/protoiface/* # gosub
- autoscaler/vendor/google.golang.org/protobuf/runtime/protoimpl/* # gosub
- autoscaler/vendor/google.golang.org/protobuf/types/known/timestamppb/* # gosub
- autoscaler/vendor/gopkg.in/errgo.v2/errors/* # gosub
- autoscaler/vendor/gopkg.in/errgo.v2/fmt/errors/* # gosub
- autoscaler/vendor/gopkg.in/yaml.v2/* # gosub
- autoscaler/vendor/gopkg.in/yaml.v3/* # gosub
14 changes: 7 additions & 7 deletions src/acceptance/assets/app/go_app/internal/app/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

//counterfeiter:generate . CPUWaster
type CPUWaster interface {
UseCPU(utilisation uint64, duration time.Duration)
UseCPU(utilisation int64, duration time.Duration)
IsRunning() bool
StopTest()
}
Expand All @@ -31,15 +31,15 @@ func CPUTests(logger logr.Logger, r *gin.RouterGroup, cpuTest CPUWaster) *gin.Ro
Error(c, http.StatusConflict, "CPU test is already running")
return
}
var utilization uint64
var minutes uint64
var utilization int64
var minutes int64
var err error
utilization, err = strconv.ParseUint(c.Param("utilization"), 10, 64)
utilization, err = strconv.ParseInt(c.Param("utilization"), 10, 64)
if err != nil {
Error(c, http.StatusBadRequest, "invalid utilization: %s", err.Error())
return
}
if minutes, err = strconv.ParseUint(c.Param("minutes"), 10, 64); err != nil {
if minutes, err = strconv.ParseInt(c.Param("minutes"), 10, 64); err != nil {
Error(c, http.StatusBadRequest, "invalid minutes: %s", err.Error())
return
}
Expand All @@ -62,7 +62,7 @@ func CPUTests(logger logr.Logger, r *gin.RouterGroup, cpuTest CPUWaster) *gin.Ro
return r
}

func (m *ConcurrentBusyLoopCPUWaster) UseCPU(utilisation uint64, duration time.Duration) {
func (m *ConcurrentBusyLoopCPUWaster) UseCPU(utilisation int64, duration time.Duration) {
m.startTest()

for utilisation > 0 {
Expand All @@ -71,7 +71,7 @@ func (m *ConcurrentBusyLoopCPUWaster) UseCPU(utilisation uint64, duration time.D
utilisation = utilisation - perGoRoutineUtilisation

// the core cpu wasting goroutine
go func(util uint64) {
go func(util int64) {
// to achieve a desired utilisation, we run a busy loop for a certain percentage of time and then wait for the remainder
// concretely, we split a second into two parts: one busy loop and one sleep
// we repeat this "second" until the test is stopped
Expand Down
22 changes: 11 additions & 11 deletions src/acceptance/assets/app/go_app/internal/app/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ var _ = Describe("CPU tests", func() {
Get("/cpu/invalid/4").
Expect(GinkgoT()).
Status(http.StatusBadRequest).
Body(`{"error":{"description":"invalid utilization: strconv.ParseUint: parsing \"invalid\": invalid syntax"}}`).
Body(`{"error":{"description":"invalid utilization: strconv.ParseInt: parsing \"invalid\": invalid syntax"}}`).
End()
})
It("should err if cpu out of bounds", func() {
apiTest(nil, nil, fakeCPUWaster, nil).
Get("/cpu/100001010101010249032897287298719874687936483275648273632429479827398798271/4").
Expect(GinkgoT()).
Status(http.StatusBadRequest).
Body(`{"error":{"description":"invalid utilization: strconv.ParseUint: parsing \"100001010101010249032897287298719874687936483275648273632429479827398798271\": value out of range"}}`).
Body(`{"error":{"description":"invalid utilization: strconv.ParseInt: parsing \"100001010101010249032897287298719874687936483275648273632429479827398798271\": value out of range"}}`).
End()
})
It("should err if cpu not an int", func() {
apiTest(nil, nil, fakeCPUWaster, nil).
Get("/cpu/5/invalid").
Expect(GinkgoT()).
Status(http.StatusBadRequest).
Body(`{"error":{"description":"invalid minutes: strconv.ParseUint: parsing \"invalid\": invalid syntax"}}`).
Body(`{"error":{"description":"invalid minutes: strconv.ParseInt: parsing \"invalid\": invalid syntax"}}`).
End()
})
It("should return ok and sleep correctDuration", func() {
Expand All @@ -51,15 +51,15 @@ var _ = Describe("CPU tests", func() {
Eventually(func() int { return fakeCPUWaster.UseCPUCallCount() }).Should(Equal(1))
utilization, duration := fakeCPUWaster.UseCPUArgsForCall(0)
Expect(duration).Should(Equal(4 * time.Minute))
Expect(utilization).Should(Equal(uint64(5)))
Expect(utilization).Should(Equal(int64(5)))
})
})

// This test is timing sensitive and may fail on GitHub workers, which is why it is marked as flaky
Context("ConcurrentBusyLoopCPUWaster", func() {
Context("UseCPU", FlakeAttempts(3), func() {
DescribeTable("should use cpu",
func(utilisation uint64, duration time.Duration) {
func(utilisation int64, duration time.Duration) {
oldCpu := getTotalCPUUsage("before test")

By("wasting cpu time")
Expand All @@ -86,11 +86,11 @@ var _ = Describe("CPU tests", func() {
}
Expect(newCpu - oldCpu).To(BeNumerically("~", expectedCPUUsage, tolerance))
},
Entry("25% for 10 seconds", uint64(25), time.Second*10),
Entry("50% for 10 seconds", uint64(50), time.Second*10),
Entry("100% for 10 seconds", uint64(100), time.Second*10),
Entry("200% for 10 seconds", uint64(200), time.Second*10),
Entry("400% for 10 seconds", uint64(400), time.Second*10),
Entry("25% for 10 seconds", int64(25), time.Second*10),
Entry("50% for 10 seconds", int64(50), time.Second*10),
Entry("100% for 10 seconds", int64(100), time.Second*10),
Entry("200% for 10 seconds", int64(200), time.Second*10),
Entry("400% for 10 seconds", int64(400), time.Second*10),
)
})
})
Expand All @@ -107,6 +107,6 @@ func getTotalCPUUsage(action string) time.Duration {
return cpuTotalDuration
}

func multiplyDurationByPercentage(duration time.Duration, percentage uint64) time.Duration {
func multiplyDurationByPercentage(duration time.Duration, percentage int64) time.Duration {
return time.Duration(float64(duration) * float64(percentage) / 100)
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ func getCFInstanceIdentityCertificateClient() (*http.Client, error) {
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCertBytes)

/* #nosec G402 -- test app that shall run on dev foundations without proper certs */
//nolint:gosec // #nosec G402 -- due to https://github.com/securego/gosec/issues/1105
//#nosec G402 -- test app that shall run on dev foundations without proper certs
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
InsecureSkipVerify: true,
Expand Down
14 changes: 7 additions & 7 deletions src/acceptance/assets/app/go_app/internal/app/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (

//counterfeiter:generate . MemoryGobbler
type MemoryGobbler interface {
UseMemory(numBytes uint64)
UseMemory(numBytes int64)
Sleep(sleepTime time.Duration)
IsRunning() bool
StopTest()
Expand All @@ -44,15 +44,15 @@ func MemoryTests(logger logr.Logger, r *gin.RouterGroup, memoryTest MemoryGobble
Error(c, http.StatusConflict, "memory test is already running")
return
}
var memoryMiB uint64
var minutes uint64
var memoryMiB int64
var minutes int64
var err error
memoryMiB, err = strconv.ParseUint(c.Param("memoryMiB"), 10, 64)
memoryMiB, err = strconv.ParseInt(c.Param("memoryMiB"), 10, 64)
if err != nil {
Error(c, http.StatusBadRequest, "invalid memoryMiB: %s", err.Error())
return
}
if minutes, err = strconv.ParseUint(c.Param("minutes"), 10, 64); err != nil {
if minutes, err = strconv.ParseInt(c.Param("minutes"), 10, 64); err != nil {
Error(c, http.StatusBadRequest, "invalid minutes: %s", err.Error())
return
}
Expand Down Expand Up @@ -97,12 +97,12 @@ func Error(c *gin.Context, status int, descriptionf string, args ...any) {

const chunkSize = 4 * Kibi

func (m *ListBasedMemoryGobbler) UseMemory(numBytes uint64) {
func (m *ListBasedMemoryGobbler) UseMemory(numBytes int64) {
m.mu.Lock()
defer m.mu.Unlock()
m.isRunning = true
m.used = list.New()
used := uint64(0)
used := int64(0)
for used <= numBytes {
m.used.PushBack(bytes.Repeat([]byte("X"), chunkSize)) // The bytes need to be non-zero to force memory allocation
used += chunkSize
Expand Down
Loading

0 comments on commit 56bac46

Please sign in to comment.