Skip to content

Commit 022acbb

Browse files
authored
Merge branch 'master' into fix/set-header-panic
2 parents ab5b1b2 + 1f0a2dc commit 022acbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3192
-398
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Summary code generation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
check-generated-code:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
22+
with:
23+
persist-credentials: false
24+
25+
- name: Install cog
26+
run: |
27+
COG_VERSION="v0.0.46"
28+
curl -sSL "https://github.com/grafana/cog/releases/download/${COG_VERSION}/cog_Linux_x86_64.tar.gz" \
29+
| sudo tar -xz -C /usr/local/bin
30+
cog --version
31+
32+
- name: Checkout schemas
33+
run: |
34+
./internal/lib/summary/machinereadable/checkout.sh
35+
36+
- name: Generate code
37+
run: |
38+
./internal/lib/summary/machinereadable/generate.sh
39+
40+
- name: Check for uncommitted changes
41+
run: |
42+
# Check if there are any changes in the Git working directory
43+
if ! git diff --exit-code; then
44+
echo "❌ Generated code is not up-to-date!"
45+
echo ""
46+
echo "The following files have uncommitted changes:"
47+
git diff --name-only
48+
echo ""
49+
echo "Please run the following commands to update the generated code:"
50+
echo " ./internal/lib/summary/machinereadable/checkout.sh"
51+
echo " ./internal/lib/summary/machinereadable/generate.sh"
52+
echo ""
53+
echo "Then commit the changes."
54+
exit 1
55+
fi
56+
57+
# Also check for untracked files
58+
if [ -n "$(git ls-files --others --exclude-standard internal/lib/summary/machinereadable/ | grep -v k6-summary/)" ]; then
59+
echo "❌ There are untracked generated files!"
60+
echo ""
61+
echo "Untracked files:"
62+
git ls-files --others --exclude-standard internal/lib/summary/machinereadable/ | grep -v k6-summary/
63+
echo ""
64+
echo "Please run the generation scripts and commit all generated files."
65+
exit 1
66+
fi
67+
68+
echo "✅ Generated code is up-to-date!"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/k6.exe
33
/dist
44
/pkg-build
5+
/internal/lib/summary/machinereadable/k6-summary
56
/internal/js/tc39/TestTC39
67
/internal/js/modules/k6/experimental/streams/tests/wpt
78
/internal/js/modules/k6/webcrypto/tests/wpt/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// k6 run --secret-source=mock=default,cool="cool secret" --secret-source=mock=name=another,cool="not cool secret" multi-source.test.js
2+
import secrets from "k6/secrets";
3+
4+
export default async () => {
5+
const my_secret = await secrets.get("cool"); // get secret from a source with the provided identifier
6+
const anothersource = secrets.source("another")
7+
const my_other_secret = await anothersource.get("cool");
8+
console.log("Secret from default source ", my_secret)
9+
console.log("Secret from another source ", my_other_secret)
10+
console.log("Are they equal? ", my_other_secret== my_secret)
11+
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ require (
5151
go.opentelemetry.io/otel/sdk v1.38.0
5252
go.opentelemetry.io/otel/sdk/metric v1.38.0
5353
go.opentelemetry.io/otel/trace v1.38.0
54-
go.opentelemetry.io/proto/otlp v1.8.0
54+
go.opentelemetry.io/proto/otlp v1.9.0
5555
go.uber.org/goleak v1.3.0
5656
golang.org/x/crypto v0.43.0
5757
golang.org/x/crypto/x509roots/fallback v0.0.0-20251028130051-c0531f9c3451
5858
golang.org/x/net v0.46.0
5959
golang.org/x/sync v0.18.0
6060
golang.org/x/term v0.36.0
6161
golang.org/x/time v0.14.0
62-
google.golang.org/grpc v1.75.0
62+
google.golang.org/grpc v1.75.1
6363
google.golang.org/protobuf v1.36.10
6464
gopkg.in/guregu/null.v3 v3.3.0
6565
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6
219219
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
220220
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
221221
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
222-
go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE=
223-
go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0=
222+
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
223+
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
224224
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
225225
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
226226
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
@@ -366,8 +366,8 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac
366366
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
367367
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
368368
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
369-
google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4=
370-
google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
369+
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
370+
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
371371
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
372372
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
373373
gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y=

internal/cmd/run.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"net/http"
99
"os"
10+
"slices"
1011
"strings"
1112
"sync"
1213
"syscall"
@@ -26,6 +27,7 @@ import (
2627
"go.k6.io/k6/internal/lib/summary"
2728
"go.k6.io/k6/internal/lib/trace"
2829
"go.k6.io/k6/internal/metrics/engine"
30+
"go.k6.io/k6/internal/output/cloud"
2931
summaryoutput "go.k6.io/k6/internal/output/summary"
3032
"go.k6.io/k6/internal/ui/pb"
3133
"go.k6.io/k6/js/common"
@@ -220,6 +222,14 @@ func (c *cmdRun) run(cmd *cobra.Command, args []string) (err error) {
220222
}
221223
}
222224

225+
summaryMeta := summary.Meta{
226+
Script: string(test.source.Data),
227+
IsCloud: slices.ContainsFunc(outputs, func(o output.Output) bool {
228+
_, isCloud := o.(*cloud.Output)
229+
return isCloud
230+
}),
231+
}
232+
223233
switch summaryMode {
224234
// TODO(@joanlopez): remove by k6 v2.0, once we completely drop the support for --summary-mode=legacy.
225235
case summary.ModeLegacy:
@@ -229,7 +239,7 @@ func (c *cmdRun) run(cmd *cobra.Command, args []string) (err error) {
229239
defer func() {
230240
logger.Debug("Generating the end-of-test summary...")
231241

232-
summaryResult, hsErr := test.initRunner.HandleSummary(globalCtx, legacySummary(), nil)
242+
summaryResult, hsErr := test.initRunner.HandleSummary(globalCtx, legacySummary(), nil, summaryMeta)
233243
if hsErr == nil {
234244
hsErr = handleSummaryResult(c.gs.FS, c.gs.Stdout, c.gs.Stderr, summaryResult)
235245
}
@@ -262,8 +272,10 @@ func (c *cmdRun) run(cmd *cobra.Command, args []string) (err error) {
262272
// likely as an additional argument like options.
263273
summary.NoColor = c.gs.Flags.NoColor
264274
summary.EnableColors = !summary.NoColor && c.gs.Stdout.IsTTY
275+
summary.NewMachineReadableSummary = testRunState.RuntimeOptions.NewMachineReadableSummary.Valid &&
276+
testRunState.RuntimeOptions.NewMachineReadableSummary.Bool
265277

266-
summaryResult, hsErr := test.initRunner.HandleSummary(globalCtx, legacySummary(), summary)
278+
summaryResult, hsErr := test.initRunner.HandleSummary(globalCtx, legacySummary(), summary, summaryMeta)
267279
if hsErr == nil {
268280
hsErr = handleSummaryResult(c.gs.FS, c.gs.Stdout, c.gs.Stderr, summaryResult)
269281
}

internal/cmd/runtime_options.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ extended: base + sets "global" as alias for "globalThis"
4343
"",
4444
"output the end-of-test summary report to JSON file",
4545
)
46+
// TODO(@joanlopez): remove by k6 v2.0, once the new summary model is the default and the only one.
47+
flags.Bool("new-machine-readable-summary", false, "enables the new machine-readable summary, "+
48+
"which is used for summary exports and as handleSummary() argument")
4649
flags.String("traces-output", "none",
4750
"set the output for k6 traces, possible values are none,otel[=host:port]")
4851
return flags
@@ -78,15 +81,16 @@ func getRuntimeOptions(
7881

7982
func runtimeOptionsFromFlags(flags *pflag.FlagSet) lib.RuntimeOptions {
8083
opts := lib.RuntimeOptions{
81-
TestType: getNullString(flags, "type"),
82-
IncludeSystemEnvVars: getNullBool(flags, "include-system-env-vars"),
83-
CompatibilityMode: getNullString(flags, "compatibility-mode"),
84-
NoThresholds: getNullBool(flags, "no-thresholds"),
85-
NoSummary: getNullBool(flags, "no-summary"),
86-
SummaryMode: getNullString(flags, "summary-mode"),
87-
SummaryExport: getNullString(flags, "summary-export"),
88-
TracesOutput: getNullString(flags, "traces-output"),
89-
Env: make(map[string]string),
84+
TestType: getNullString(flags, "type"),
85+
IncludeSystemEnvVars: getNullBool(flags, "include-system-env-vars"),
86+
CompatibilityMode: getNullString(flags, "compatibility-mode"),
87+
NoThresholds: getNullBool(flags, "no-thresholds"),
88+
NoSummary: getNullBool(flags, "no-summary"),
89+
SummaryMode: getNullString(flags, "summary-mode"),
90+
SummaryExport: getNullString(flags, "summary-export"),
91+
NewMachineReadableSummary: getNullBool(flags, "new-machine-readable-summary"),
92+
TracesOutput: getNullString(flags, "traces-output"),
93+
Env: make(map[string]string),
9094
}
9195
return opts
9296
}
@@ -133,6 +137,12 @@ func populateRuntimeOptionsFromEnv(opts lib.RuntimeOptions, environment map[stri
133137
opts.SummaryExport = null.StringFrom(envVar)
134138
}
135139

140+
if err := saveBoolFromEnv(
141+
environment, "K6_NEW_MACHINE_READABLE_SUMMARY", &opts.NewMachineReadableSummary,
142+
); err != nil {
143+
return opts, err
144+
}
145+
136146
if envVar, ok := environment["SSLKEYLOGFILE"]; !opts.KeyWriter.Valid && ok {
137147
opts.KeyWriter = null.StringFrom(envVar)
138148
}

0 commit comments

Comments
 (0)