Skip to content

chore: update to Go 1.24.6 [IDE-1377] #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ orbs:
executors:
default:
docker:
- image: cimg/go:1.21.1
- image: cimg/go:1.24.5

# Define the jobs we want to run for this project
jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
with:
token: ${{ github.token }}
branch: main
noVersionBumpBehavior: patch

- name: Create tag
run: git tag ${{ steps.semver.outputs.next }}
Expand Down
20 changes: 10 additions & 10 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ run:
- integration
concurrency: 4
issues-exit-code: 1
skip-dirs:
- "licenses"
- "pact"
- ".bin"
- ".github"
- ".vscode"
- "build"
tests: true
timeout: 5m

Expand Down Expand Up @@ -38,7 +31,6 @@ linters-settings:
gosimple:
checks: ['all']
govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment
Expand Down Expand Up @@ -110,7 +102,7 @@ linters:
# TODO(errorlint): revisit
#- errorlint
- exhaustive
- exportloopref
- copyloopvar
# TODO(forbidigo): revisit
#- forbidigo
# TODO(forcetypeassert): revisit this one! beware fragile asserts in this codebase
Expand Down Expand Up @@ -157,7 +149,6 @@ linters:
# TODO(stylecheck): revisit in a followup; some breaking API changes
#- stylecheck
# NOTE: removed tagliatelle as it conflicts too much with existing API wireformats
- tenv
# TODO(testpackage): improve open vs closed-box testing in a followup
#- testpackage
- thelper
Expand All @@ -166,12 +157,21 @@ linters:
# TODO(unparam): revisit
#- unparam
- usestdlibvars
- usetesting
- wastedassign
- whitespace
# TODO(wrapcheck): wrap errors in a followup
#- wrapcheck

issues:
exclude-dirs:
- "licenses"
- "pact"
- ".bin"
- ".github"
- ".vscode"
- "build"

exclude-rules:
- path: _test\.go
linters:
Expand Down
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ GOARCH = $(shell go env GOARCH)

TOOLS_BIN := $(shell pwd)/.bin

OVERRIDE_GOCI_LINT_V := v1.60.1
OVERRIDE_GOCI_LINT_V := v1.64.8
GOCI_LINT_TARGETS := $(TOOLS_BIN)/golangci-lint $(TOOLS_BIN)/.golangci-lint_$(OVERRIDE_GOCI_LINT_V)
SHELL:=env PATH=$(TOOLS_BIN)/go:$(TOOLS_BIN)/pact/bin:$(PATH) $(SHELL)

## tools: Install required tooling.
.PHONY: tools
tools: $(TOOLS_BIN)/golangci-lint $(TOOLS_BIN)/go
$(TOOLS_BIN)/golangci-lint:
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/$(OVERRIDE_GOCI_LINT_V)/install.sh | sh -s -- -b $(TOOLS_BIN)/ $(OVERRIDE_GOCI_LINT_V)
tools: $(GOCI_LINT_TARGETS) $(TOOLS_BIN)/go
$(GOCI_LINT_TARGETS):
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/$(OVERRIDE_GOCI_LINT_V)/install.sh | sh -s -- -b $(TOOLS_BIN) $(OVERRIDE_GOCI_LINT_V)
@rm -f $(TOOLS_BIN)/.golangci-lint_*
@touch $(TOOLS_BIN)/.golangci-lint_$(OVERRIDE_GOCI_LINT_V)

$(TOOLS_BIN)/pact-broker:
@cd $(TOOLS_BIN); curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | PACT_CLI_VERSION=v2.4.4 bash; cd ../
Expand All @@ -22,17 +25,17 @@ $(TOOLS_BIN)/go:
@GOBIN=${TOOLS_BIN}/go ${TOOLS_BIN}/go/pact-go -l DEBUG install -d /tmp

.PHONY: format
format:
format: $(GOCI_LINT_TARGETS)
@gofmt -w -l -e .
@$(TOOLS_BIN)/golangci-lint run --fix -v ./...
@$(TOOLS_BIN)/golangci-lint run --fix ./...

.PHONY: lint
lint: $(TOOLS_BIN)/golangci-lint
lint: $(GOCI_LINT_TARGETS)
ifdef CI
mkdir -p test/results
@$(TOOLS_BIN)/golangci-lint run --out-format junit-xml ./... > test/results/lint-tests.xml
else
@$(TOOLS_BIN)/golangci-lint run -v ./...
@$(TOOLS_BIN)/golangci-lint run ./...
endif

.PHONY: build
Expand All @@ -45,6 +48,7 @@ clean:
@echo "Cleaning up..."
@GOOS=$(GOOS) GOARCH=$(GOARCH) go clean -testcache
@rm -rf $(TOOLS_BIN)
@rm -f /tmp/libpact_ffi.*

.PHONY: test
test:
Expand Down
40 changes: 19 additions & 21 deletions bundle/bundle_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package bundle_test

import (
"bytes"
"context"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -69,7 +68,7 @@ func Test_Create(t *testing.T) {
require.NoError(t, err)

var bundleManager = bundle.NewBundleManager(mockSnykCodeClient, newLogger(t), mockInstrumentor, mockErrorReporter, mockTrackerFactory)
bundle, err := bundleManager.Create(context.Background(),
bundle, err := bundleManager.Create(t.Context(),
"testRequestId",
dir,
sliceToChannel([]string{file}),
Expand Down Expand Up @@ -109,7 +108,7 @@ func Test_Create(t *testing.T) {
require.NoError(t, err)

var bundleManager = bundle.NewBundleManager(mockSnykCodeClient, newLogger(t), mockInstrumentor, mockErrorReporter, mockTrackerFactory)
bundle, err := bundleManager.Create(context.Background(),
bundle, err := bundleManager.Create(t.Context(),
"testRequestId",
dir,
sliceToChannel([]string{file}),
Expand Down Expand Up @@ -153,7 +152,7 @@ func Test_Create(t *testing.T) {
require.NoError(t, err)

var bundleManager = bundle.NewBundleManager(mockSnykCodeClient, newLogger(t), mockInstrumentor, mockErrorReporter, mockTrackerFactory)
bundle, err := bundleManager.Create(context.Background(),
bundle, err := bundleManager.Create(t.Context(),
"testRequestId",
dir,
sliceToChannel([]string{file}),
Expand Down Expand Up @@ -196,7 +195,7 @@ func Test_Create(t *testing.T) {
)
require.NoError(t, err)
var bundleManager = bundle.NewBundleManager(mockSnykCodeClient, newLogger(t), mockInstrumentor, mockErrorReporter, mockTrackerFactory)
bundle, err := bundleManager.Create(context.Background(),
bundle, err := bundleManager.Create(t.Context(),
"testRequestId",
dir,
sliceToChannel([]string{file}),
Expand Down Expand Up @@ -234,7 +233,7 @@ func Test_Create(t *testing.T) {
assert.Nil(t, err)

var bundleManager = bundle.NewBundleManager(mockSnykCodeClient, newLogger(t), mockInstrumentor, mockErrorReporter, mockTrackerFactory)
bundle, err := bundleManager.Create(context.Background(),
bundle, err := bundleManager.Create(t.Context(),
"testRequestId",
tempDir,
sliceToChannel([]string{file}),
Expand Down Expand Up @@ -287,7 +286,7 @@ func Test_Create(t *testing.T) {
}

var bundleManager = bundle.NewBundleManager(mockSnykCodeClient, newLogger(t), mockInstrumentor, mockErrorReporter, mockTrackerFactory)
bundle, err := bundleManager.Create(context.Background(),
bundle, err := bundleManager.Create(t.Context(),
"testRequestId",
tempDir,
sliceToChannel(filesFullPaths),
Expand Down Expand Up @@ -340,7 +339,7 @@ func Test_Create(t *testing.T) {
}

var bundleManager = bundle.NewBundleManager(mockSnykCodeClient, newLogger(t), mockInstrumentor, mockErrorReporter, mockTrackerFactory)
bundle, err := bundleManager.Create(context.Background(),
bundle, err := bundleManager.Create(t.Context(),
"testRequestId",
tempDir,
sliceToChannel(filesFullPaths),
Expand Down Expand Up @@ -391,7 +390,7 @@ func Test_Upload(t *testing.T) {
bundleFileMap[documentURI] = bundleFile

_, err := bundleManager.Upload(
context.Background(),
t.Context(),
"testRequestId",
bundle.NewBundle(mockSnykCodeClient, mockInstrumentor, mockErrorReporter, &logger, "rootPath", "bundleHash", bundleFileMap, []string{}, []string{documentURI}),
bundleFileMap)
Expand Down Expand Up @@ -440,7 +439,7 @@ func Test_Upload(t *testing.T) {
missingFiles = append(missingFiles, path)

_, err := bundleManager.Upload(
context.Background(),
t.Context(),
"testRequestId",
bundle.NewBundle(mockSnykCodeClient, mockInstrumentor, mockErrorReporter, &logger, "rootPath", "bundleHash", bundleFileMap, []string{}, missingFiles),
bundleFileMap)
Expand Down Expand Up @@ -470,19 +469,19 @@ func Test_IsSupported_Extensions(t *testing.T) {
bundler := bundle.NewBundleManager(mockSnykCodeClient, newLogger(t), mockInstrumentor, mockErrorReporter, mockTrackerFactory)

t.Run("should return true for supported languages", func(t *testing.T) {
supported, _ := bundler.IsSupported(context.Background(), "C:\\some\\path\\Test.java")
supported, _ := bundler.IsSupported(t.Context(), "C:\\some\\path\\Test.java")
assert.True(t, supported)
})

t.Run("should return false for unsupported languages", func(t *testing.T) {
supported, _ := bundler.IsSupported(context.Background(), "C:\\some\\path\\Test.rs")
supported, _ := bundler.IsSupported(t.Context(), "C:\\some\\path\\Test.rs")
assert.False(t, supported)
})

t.Run("should cache supported extensions", func(t *testing.T) {
path := "C:\\some\\path\\Test.rs"
_, _ = bundler.IsSupported(context.Background(), path)
_, _ = bundler.IsSupported(context.Background(), path)
_, _ = bundler.IsSupported(t.Context(), path)
_, _ = bundler.IsSupported(t.Context(), path)
})
}

Expand Down Expand Up @@ -514,34 +513,33 @@ func Test_IsSupported_ConfigFiles(t *testing.T) {
t.Run("should return true for supported config files", func(t *testing.T) {
for _, file := range expectedConfigFiles {
path := filepath.Join(dir, file)
supported, _ := bundler.IsSupported(context.Background(), path)
supported, _ := bundler.IsSupported(t.Context(), path)
assert.True(t, supported)
}
})
t.Run("should exclude .gitignore and .dcignore", func(t *testing.T) {
for _, file := range []string{".gitignore", ".dcignore"} {
path := filepath.Join(dir, file)
supported, _ := bundler.IsSupported(context.Background(), path)
supported, _ := bundler.IsSupported(t.Context(), path)
assert.False(t, supported)
}
})
t.Run("should return false for unsupported config files", func(t *testing.T) {
path := "C:\\some\\path\\.unsupported"
supported, _ := bundler.IsSupported(context.Background(), path)
supported, _ := bundler.IsSupported(t.Context(), path)
assert.False(t, supported)
})

t.Run("should cache supported extensions", func(t *testing.T) {
path := "C:\\some\\path\\Test.rs"
_, _ = bundler.IsSupported(context.Background(), path)
_, _ = bundler.IsSupported(context.Background(), path)
_, _ = bundler.IsSupported(t.Context(), path)
_, _ = bundler.IsSupported(t.Context(), path)
})
}

func setup(t *testing.T) string {
t.Helper()
dir, err := os.MkdirTemp("", "createFileOfSize")
require.NoError(t, err)
dir := t.TempDir()
return dir
}

Expand Down
13 changes: 6 additions & 7 deletions bundle/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ package bundle_test

import (
"bytes"
"context"
"crypto/sha256"
"encoding/hex"
"fmt"
"golang.org/x/net/html/charset"
"io"
"os"
"testing"
Expand All @@ -31,6 +29,7 @@ import (
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/html/charset"

"github.com/snyk/code-client-go/bundle"
"github.com/snyk/code-client-go/internal/deepcode"
Expand Down Expand Up @@ -83,7 +82,7 @@ func Test_UploadBatch(t *testing.T) {
b := bundle.NewBundle(mockSnykCodeClient, mockInstrumentor, mockErrorReporter, &testLogger, "testRootPath", "testBundleHash", map[string]deepcode.BundleFile{}, []string{}, []string{})

emptyBundle := &bundle.Batch{}
err := b.UploadBatch(context.Background(), "testRequestId", emptyBundle)
err := b.UploadBatch(t.Context(), "testRequestId", emptyBundle)
assert.NoError(t, err)
})

Expand All @@ -102,7 +101,7 @@ func Test_UploadBatch(t *testing.T) {
mockErrorReporter := mocks.NewMockErrorReporter(ctrl)
b := bundle.NewBundle(mockSnykCodeClient, mockInstrumentor, mockErrorReporter, &testLogger, "testRootPath", "testBundleHash", map[string]deepcode.BundleFile{}, []string{}, []string{})

err := b.UploadBatch(context.Background(), "testRequestId", bundleWithFiles)
err := b.UploadBatch(t.Context(), "testRequestId", bundleWithFiles)
assert.NoError(t, err)
})

Expand All @@ -125,10 +124,10 @@ func Test_UploadBatch(t *testing.T) {
mockErrorReporter := mocks.NewMockErrorReporter(ctrl)
b := bundle.NewBundle(mockSnykCodeClient, mockInstrumentor, mockErrorReporter, &testLogger, "testRootPath", "testBundleHash", map[string]deepcode.BundleFile{}, []string{}, []string{})

err := b.UploadBatch(context.Background(), "testRequestId", bundleWithFiles)
err := b.UploadBatch(t.Context(), "testRequestId", bundleWithFiles)
require.NoError(t, err)
oldHash := b.GetBundleHash()
err = b.UploadBatch(context.Background(), "testRequestId", bundleWithMultipleFiles)
err = b.UploadBatch(t.Context(), "testRequestId", bundleWithMultipleFiles)
require.NoError(t, err)
newHash := b.GetBundleHash()
assert.NotEqual(t, oldHash, newHash)
Expand All @@ -153,7 +152,7 @@ func Test_RawContentBatch(t *testing.T) {

require.NoError(t, batchErr)
oldHash := b.GetBundleHash()
err := b.UploadBatch(context.Background(), "testRequestId", bundleFromRawContent)
err := b.UploadBatch(t.Context(), "testRequestId", bundleFromRawContent)
require.NoError(t, err)
newHash := b.GetBundleHash()
assert.NotEqual(t, oldHash, newHash)
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/snyk/code-client-go

go 1.23.6
go 1.24.6

require (
github.com/go-git/go-git/v5 v5.14.0
Expand All @@ -9,7 +9,7 @@ require (
github.com/hexops/gotextdiff v1.0.3
github.com/oapi-codegen/oapi-codegen/v2 v2.4.1
github.com/oapi-codegen/runtime v1.1.1
github.com/pact-foundation/pact-go/v2 v2.0.5
github.com/pact-foundation/pact-go/v2 v2.4.1
github.com/pkg/errors v0.9.1
github.com/puzpuzpuz/xsync v1.5.2
github.com/rs/zerolog v1.32.0
Expand All @@ -33,7 +33,7 @@ require (
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/invopop/yaml v0.3.1 // indirect
Expand All @@ -50,9 +50,9 @@ require (
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/speakeasy-api/openapi-overlay v0.9.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
Expand All @@ -61,9 +61,9 @@ require (
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/grpc v1.71.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading