szkiba / xk6-chai

Embed Chai.js (k6chaijs) into the k6 binary
Apache License 2.0
0 stars 0 forks source link

xk6 build error when combining some extensions with xk6-chai #3

Open ts-sean-foley opened 1 week ago

ts-sean-foley commented 1 week ago

EDIT: See comment as this was also reproduced with simple xk6 build command.

I am working to test this extension out in a custom docker image alongside another xk6 extension ( https://github.com/leonyork/xk6-output-timestream ) and when it tries to build the image with both extensions it inevitably complains about compiler options strict and method compile in xk6-chai/chai/module.go

This may not be an issue with your extension but with the other I am trying to build it with but I am looking for answers, and thought you may have some ideas.

I have been racking my brain trying to figure out the cause of the below error with my docker build command:

13.06 2024/10/29 19:50:52 [INFO] Building k6
13.06 2024/10/29 19:50:52 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
13.18 2024/10/29 19:50:52 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /k6 -ldflags=-w -s -trimpath
50.10 # github.com/szkiba/xk6-chai/chai
50.10 /go/pkg/mod/github.com/szkiba/xk6-chai@v0.1.2/chai/module.go:89:15: comp.Options.Strict undefined (type compiler.Options has no field or method Strict)
50.10 /go/pkg/mod/github.com/szkiba/xk6-chai@v0.1.2/chai/module.go:91:23: comp.Compile undefined (type *compiler.Compiler has no field or method Compile)
54.87 2024/10/29 19:51:34 [INFO] Cleaning up temporary folder: /tmp/buildenv_2024-10-29-1950.765675577
54.87 2024/10/29 19:51:34 [FATAL] exit status 1
------
Dockerfile:8
--------------------
   7 |     # Feel free to add other extensions using the '--with ...'.
   8 | >>> RUN xk6 build \
   9 | >>> --with github.com/szkiba/xk6-chai@latest \
  10 | >>> --with github.com/leonyork/xk6-output-timestream@latest \
  11 | >>> --output /k6
  12 |
--------------------
ERROR: failed to solve: process "/bin/sh -c xk6 build --with github.com/szkiba/xk6-chai@latest --with github.com/leonyork/xk6-output-timestream@latest --output /k6" did not complete successfully: exit code: 1

This is my Dockerfile:

# Build the k6 binary with the extension
FROM golang:1.21.5 AS builder

RUN go install go.k6.io/xk6/cmd/xk6@latest

# For our example, we'll add support for output of test metrics to InfluxDB v2.
# Feel free to add other extensions using the '--with ...'.
RUN xk6 build \
--with github.com/szkiba/xk6-chai@latest \
--with github.com/leonyork/xk6-output-timestream@latest \
--output /k6

# Use the operator's base image and override the k6 binary
FROM grafana/k6:latest
COPY --from=builder /k6 /usr/bin/k6
ts-sean-foley commented 1 week ago

You can see some additional troubleshooting info in the issue with mentions noted here, as I also filed a proactive issue with the other extension dev.

I can add that I can reproduce this issue with simple xk6 build commands on my workstation environment outside of docker and that the issue is observed when k6 is built with xk6-chai along with other but not all output xk6 extensions. Another similar failure was observed when I tried the following:

xk6 build --with github.com/szkiba/xk6-chai@latest --with github.com/grafana/xk6-output-opentelemetry

<snip>
2024/10/29 18:03:16 [INFO] Build environment ready
2024/10/29 18:03:16 [INFO] Building k6
2024/10/29 18:03:16 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
2024/10/29 18:03:16 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /Users/sean.foley/wip/k6-extended/k6 -ldflags=-w -s -trimpath
# github.com/szkiba/xk6-chai/chai
../../../go/pkg/mod/github.com/szkiba/xk6-chai@v0.1.2/chai/module.go:89:15: comp.Options.Strict undefined (type compiler.Options has no field or method Strict)
../../../go/pkg/mod/github.com/szkiba/xk6-chai@v0.1.2/chai/module.go:91:23: comp.Compile undefined (type *compiler.Compiler has no field or method Compile)
2024/10/29 18:03:25 [INFO] Cleaning up temporary folder: /Users/sean.foley/wip/k6-extended/buildenv_2024-10-29-1803.2329456817
2024/10/29 18:03:25 [FATAL] exit status 1