Skip to content

Commit ad8f33f

Browse files
authored
Merge pull request #176 from grafana/175-update-dependencies
Update dependencies and switch to go 1.24
2 parents d5e921c + 7998cf0 commit ad8f33f

File tree

17 files changed

+251
-115
lines changed

17 files changed

+251
-115
lines changed

.devcontainer/devcontainer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"ghcr.io/devcontainers/features/github-cli:1": {},
2424
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
2525
"ghcr.io/devcontainers/features/go:1": {
26-
"version": "1.23",
27-
"golangciLintVersion": "2.0.2"
26+
"version": "1.24",
27+
"golangciLintVersion": "2.1.2"
2828
},
29-
"ghcr.io/guiyomh/features/goreleaser:0": { "version": "2.6.1" },
29+
"ghcr.io/guiyomh/features/goreleaser:0": { "version": "2.8.2" },
3030
"ghcr.io/guiyomh/features/gotestsum:0": { "version": "1.12.1" },
31-
"ghcr.io/szkiba/devcontainer-features/gosec:1": { "version": "2.22.2" },
31+
"ghcr.io/szkiba/devcontainer-features/gosec:1": { "version": "2.22.3" },
3232
"ghcr.io/szkiba/devcontainer-features/govulncheck:1": { "version": "1.1.4" },
3333
"ghcr.io/szkiba/devcontainer-features/bats:1": { "version": "1.11.1" },
3434
"ghcr.io/szkiba/devcontainer-features/cdo:1": { "version": "0.1.2" },

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
ARG GO_VERSION=1.23.7
2+
ARG GO_VERSION=1.24.2
33
ARG VARIANT=alpine3.21
44
FROM golang:${GO_VERSION}-${VARIANT} AS builder
55

Dockerfile.goreleaser

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GO_VERSION=1.23.7
1+
ARG GO_VERSION=1.24.2
22
ARG VARIANT=alpine3.21
33

44
FROM golang:${GO_VERSION}-${VARIANT}

docs/workflows/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,8 @@ The **Extension Release** ([`extension-release.yml`](../../.github/workflows/ext
343343
private:
344344
description: The repository is private
345345
type: boolean
346+
bats:
347+
description: The bats scripts to use for integration testing. Space-separated file names or patterns.
348+
type: string
349+
required: false
346350
```

go.mod

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
module go.k6.io/xk6
22

3-
go 1.23.0
4-
5-
toolchain go1.23.8
3+
go 1.24.0
64

75
require (
86
github.com/Masterminds/semver/v3 v3.3.1
97
github.com/fatih/color v1.18.0
108
github.com/go-enry/go-license-detector/v4 v4.3.1
11-
github.com/go-git/go-git/v5 v5.15.0
12-
github.com/grafana/k6foundry v0.4.5
9+
github.com/go-git/go-git/v5 v5.16.0
10+
github.com/grafana/k6foundry v0.4.6
1311
github.com/lmittmann/tint v1.0.7
1412
github.com/mattn/go-colorable v0.1.14
1513
github.com/mattn/go-isatty v0.0.20

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UN
4545
github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU=
4646
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
4747
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
48-
github.com/go-git/go-git/v5 v5.15.0 h1:f5Qn0W0F7ry1iN0ZwIU5m/n7/BKB4hiZfc+zlZx7ly0=
49-
github.com/go-git/go-git/v5 v5.15.0/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
48+
github.com/go-git/go-git/v5 v5.16.0 h1:k3kuOEpkc0DeY7xlL6NaaNg39xdgQbtH5mwCafHO9AQ=
49+
github.com/go-git/go-git/v5 v5.16.0/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
5050
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
5151
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
5252
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
5353
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
5454
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
55-
github.com/grafana/k6foundry v0.4.5 h1:wus8L3e1vTiECOoR5CCexCDHt9wGASyffF7iujZmh+U=
56-
github.com/grafana/k6foundry v0.4.5/go.mod h1:GDmBp/h370ZDMhjIhx54LpvGCIfmy/cMOLpeU+W+FOk=
55+
github.com/grafana/k6foundry v0.4.6 h1:fFgR72Pw0dzo8wVWyggu35SGGjdt31Dktil1bDE1MCM=
56+
github.com/grafana/k6foundry v0.4.6/go.mod h1:eLsr0whhH+5Y1y7YpDxJi3Jv5wHMuf+80vdRyMH10pg=
5757
github.com/hhatto/gorst v0.0.0-20181029133204-ca9f730cac5b h1:Jdu2tbAxkRouSILp2EbposIb8h4gO+2QuZEn3d9sKAc=
5858
github.com/hhatto/gorst v0.0.0-20181029133204-ca9f730cac5b/go.mod h1:HmaZGXHdSwQh1jnUlBGN2BeEYOHACLVGzYOXCbsLvxY=
5959
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=

internal/legacy/builder.go

+70-70
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,76 @@ func FromOSEnv() Builder {
5555
return parseEnv(env)
5656
}
5757

58+
// Build builds k6 at the configured version with the
59+
// configured extensions and writes a binary at outputFile.
60+
func (b Builder) Build(ctx context.Context, log *slog.Logger, outfile string) error {
61+
if outfile == "" {
62+
return errMissingOutputFile
63+
}
64+
65+
log.Info("Building k6")
66+
67+
opts := k6foundry.NativeFoundryOpts{
68+
GoOpts: k6foundry.GoOpts{
69+
GoGetTimeout: b.TimeoutGet,
70+
GOBuildTimeout: b.TimeoutBuild,
71+
CopyGoEnv: true,
72+
Env: b.newBuilderEnv(log),
73+
},
74+
K6Repo: b.K6Repo,
75+
SkipCleanup: b.SkipCleanup,
76+
Stdout: os.Stdout,
77+
Stderr: os.Stderr,
78+
Logger: log,
79+
}
80+
81+
k6b, err := k6foundry.NewNativeFoundry(ctx, opts)
82+
if err != nil {
83+
return err
84+
}
85+
86+
// the user's specified output file might be relative, and
87+
// because the `go build` command is executed in a different,
88+
// temporary folder, we convert the user's input to an
89+
// absolute path so it goes the expected place
90+
absOutputFile, err := filepath.Abs(outfile)
91+
if err != nil {
92+
return err
93+
}
94+
95+
const outFilePerm = 0o777
96+
97+
outFile, err := os.OpenFile(absOutputFile, os.O_WRONLY|os.O_CREATE, outFilePerm) // #nosec G302 G304
98+
if err != nil {
99+
return err
100+
}
101+
defer outFile.Close() //nolint:errcheck
102+
103+
platform, err := b.parsePlatform()
104+
if err != nil {
105+
return err
106+
}
107+
108+
mods, err := b.getModules()
109+
if err != nil {
110+
return err
111+
}
112+
113+
reps, err := b.getReplacements()
114+
if err != nil {
115+
return err
116+
}
117+
118+
k6Version := b.K6Version
119+
if k6Version == "" {
120+
k6Version = "latest"
121+
}
122+
123+
_, err = k6b.Build(ctx, platform, k6Version, mods, reps, buildCommandArgs(b.BuildFlags), outFile)
124+
125+
return err
126+
}
127+
58128
func parseEnv(env map[string]string) Builder {
59129
return Builder{
60130
Compile: Compile{
@@ -146,76 +216,6 @@ func (b Builder) parsePlatform() (k6foundry.Platform, error) {
146216
return k6foundry.ParsePlatform(os + "/" + arch)
147217
}
148218

149-
// Build builds k6 at the configured version with the
150-
// configured extensions and writes a binary at outputFile.
151-
func (b Builder) Build(ctx context.Context, log *slog.Logger, outfile string) error {
152-
if outfile == "" {
153-
return errMissingOutputFile
154-
}
155-
156-
log.Info("Building k6")
157-
158-
opts := k6foundry.NativeFoundryOpts{
159-
GoOpts: k6foundry.GoOpts{
160-
GoGetTimeout: b.TimeoutGet,
161-
GOBuildTimeout: b.TimeoutBuild,
162-
CopyGoEnv: true,
163-
Env: b.newBuilderEnv(log),
164-
},
165-
K6Repo: b.K6Repo,
166-
SkipCleanup: b.SkipCleanup,
167-
Stdout: os.Stdout,
168-
Stderr: os.Stderr,
169-
Logger: log,
170-
}
171-
172-
k6b, err := k6foundry.NewNativeFoundry(ctx, opts)
173-
if err != nil {
174-
return err
175-
}
176-
177-
// the user's specified output file might be relative, and
178-
// because the `go build` command is executed in a different,
179-
// temporary folder, we convert the user's input to an
180-
// absolute path so it goes the expected place
181-
absOutputFile, err := filepath.Abs(outfile)
182-
if err != nil {
183-
return err
184-
}
185-
186-
const outFilePerm = 0o777
187-
188-
outFile, err := os.OpenFile(absOutputFile, os.O_WRONLY|os.O_CREATE, outFilePerm) // #nosec G302 G304
189-
if err != nil {
190-
return err
191-
}
192-
defer outFile.Close() //nolint:errcheck
193-
194-
platform, err := b.parsePlatform()
195-
if err != nil {
196-
return err
197-
}
198-
199-
mods, err := b.getModules()
200-
if err != nil {
201-
return err
202-
}
203-
204-
reps, err := b.getReplacements()
205-
if err != nil {
206-
return err
207-
}
208-
209-
k6Version := b.K6Version
210-
if k6Version == "" {
211-
k6Version = "latest"
212-
}
213-
214-
_, err = k6b.Build(ctx, platform, k6Version, mods, reps, buildCommandArgs(b.BuildFlags), outFile)
215-
216-
return err
217-
}
218-
219219
func envOrDefaultValue(env map[string]string, name, defaultValue string) string {
220220
s, ok := env[name]
221221
if !ok {

releases/v0.19.0.md

+26
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
This release includes:
44
- reusable extension development workflows
5+
- update dependencies and switch to go 1.24
56

67
## New features
78

@@ -10,3 +11,28 @@ This release includes:
1011
The reusable extension development workflows have been moved from the [grafana/k6-extension-workflows](https://github.com/grafana/k6-extension-workflows) repository.
1112

1213
Check `docs/workflows/README.md` for more information.
14+
15+
### Update dependencies and switch to go 1.24 [#175](https://github.com/grafana/xk6/issues/175)
16+
17+
Switched to go 1.24 because some k6 extensions require it. Along with this, a general dependency update was made.
18+
19+
20+
In `go.mod`
21+
- remove unnecessary toolchain entry from `go.mod` file
22+
- update `k6foundry` to `v0.4.6`
23+
- update `go-git` to `v5.16.0`
24+
25+
In Dockerfiles:
26+
- update base image to go `1.24.2`
27+
28+
In Dev Containers config:
29+
- update `go` to `1.24.2`
30+
- update `golangci-lint` to `2.1.2`
31+
- update `goreleaser` to `2.8.2`
32+
- update `gosec` to `2.22.3`
33+
34+
In repository settings:
35+
- update `GO_VERSION` to `1.24`
36+
- update `GOLANGCI_LINT_VERSION` to `v2.1.2`
37+
- update `GORELEASER_VERSION` to `2.8.2`
38+
- update `GOSEC_VERSION` to `v2.22.3`

vendor/github.com/go-git/go-git/v5/options.go

+46-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-git/go-git/v5/plumbing/transport/common.go

+10-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)