I was trying to build xk6 with an extension I’m developing in local but I’m not able to do it.
Having checked the documentation seems not to be possible: GitHub - grafana/xk6: Build k6 with extensions
I also tried this
xk6 build v0.33.0 --with github.com/simskij/xk6-chaos="/absolute/path/to/xk6-redis".
But no luck.
Does anyone tried it?
Hi! @0scar, this is possible. As long as your local set-up is correct for Golang.
Can you confirm the steps you took before the xk6 build…
Few picky things first. I noticed that you have “/absolute/path/to/xk6-redis” after your xk6-chaos, this looks incorrect to me and would be xk6 build --with github.com/grafana/xk6-chaos@latest
An example would be…
Given your Go env is set up correctly with the documented version,
go install go.k6.io/xk6/cmd/xk6@latest
xk6 build --with github.com/grafana/xk6-chaos@latest
you can then run the binary with
./k6 run .....
Many thanks for the answer. Maybe I didn’t explain properly: I’m trying to build using my “local extension”
The Build Bundler linked above only works for published extensions. If you’re developing your own extension or modifying one locally, you will need to build a custom binary of k6 using your local extension rather than the published version.
If you’re creating a new extension, run this:
xk6 build v0.32.0 --with /Users/nic/git/xk6-myextension
If you’re modifying a published extension:
xk6 build v0.32.0 --with github.com/simskij/xk6-chaos="/Users/nic/git/xk6-chaos"
Hi @0scar! Sorry for the extremely late response, but the easiest method would be to build from the directory containing your custom extension, then using the following command (updated for newer versions):
xk6 build v0.39.0 --with github.com/grafana/xk6-chaos=.
I just wanted to make note as well, I’m not sure if the “simskij/xk6-chaos” repository exists any longer. As of now, we do have that extension available as “grafana/xk6-chaos”.
Also, we’ve been updating our documentation for Extensions and have this scenario updated as Building from a local repository