Skip to content

Commit

Permalink
Revert "Reimplement using k6foundry (#111)" (#113)
Browse files Browse the repository at this point in the history
This reverts commit 686292c.
  • Loading branch information
pablochacin authored Nov 15, 2024
1 parent 686292c commit 4c76f08
Show file tree
Hide file tree
Showing 40 changed files with 2,651 additions and 3,986 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
go-version: [ 1.22.x ]
go-version: [ 1.18.x, 1.19.x ]

# Set some variables per OS, usable via ${{ matrix.VAR }}
# XK6_BIN_PATH: the path to the compiled k6 binary, for artifact publishing
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
go-version: 1.19.x
check-latest: true
- name: Retrieve golangci-lint version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v1.59.1
# v1.50.1
# Please don't remove the first line. It uses in CI to determine the golangci version
linters-settings:
errcheck:
Expand Down
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ xk6 build [<k6_version>]
- `--with` can be used multiple times to add extensions by specifying the Go module name and optionally its version, similar to `go get`. Module name is required, but specific version and/or local replacement are optional. For an up-to-date list of k6 extensions, head to our [extensions page](https://k6.io/docs/extensions/).
- `--replace` can be used multiple times to add replacements by specifying the Go module name and the replacement module, similar to `go mod edit -replace=`. Version of the replacement can be specified with the `@version` suffix in the replacement path.

Versions can be anything compatible with `go get`.

Examples:

```bash
Expand Down Expand Up @@ -169,16 +167,36 @@ xk6 run -u 10 -d 10s test.js

The race detector can be enabled by setting the env variable `XK6_RACE_DETECTOR=1` or through the `XK6_BUILD_FLAGS` env variable.


## Library usage

```go
builder := xk6.Builder{
K6Version: "v0.35.0",
Extensions: []xk6.Dependency{
{
PackagePath: "github.com/grafana/xk6-browser",
Version: "v0.1.1",
},
},
}
err := builder.Build(context.Background(), "./k6")
```

Versions can be anything compatible with `go get`.


## Environment variables

Because the subcommands and flags are constrained to benefit rapid extension prototyping, xk6 does read some environment variables to take cues for its behavior and/or configuration when there is no room for flags.

- `K6_VERSION` sets the version of k6 to build.
- `XK6_BUILD_FLAGS` sets any go build flags if needed. Defaults to '-ldflags=-w -s -trim'.
- `XK6_RACE_DETECTOR=1` enables the Go race detector in the build. Forces `GCO_ENABLED=1`.
- `XK6_BUILD_FLAGS` sets any go build flags if needed. Defaults to '-ldflags=-w -s'.
- `XK6_RACE_DETECTOR=1` enables the Go race detector in the build.
- `XK6_SKIP_CLEANUP=1` causes xk6 to leave build artifacts on disk after exiting.
- `XK6_K6_REPO` optionally sets the path to the main k6 repository. This is useful when building with k6 forks.


## Keeping dependencies in sync

We recommend extension maintainers to keep dependencies in common with k6 core in the same version k6 core uses. This guarantees binary compatibility of the JS runtime, and ensures uses will not have to face unforeseen build-time errors when compiling several extensions together with xk6.
Expand All @@ -189,26 +207,6 @@ The [`go-depsync`](https://github.com/grafana/go-depsync/) tool can check for th
/your/extension$ go-depsync --parent go.k6.io/k6
```

## Library usage

> !Breaking change: since v0.14.0 `xk6.Builder.Build` function no longer reads environment variables to complete missing attributes. Use `xk6.FromOSEnv()` to create a builder from environment variables and then complete or override attributes as needed.
```go
// create builder with defaults from environment variables
builder := xk6.FromOSEnv()

// complete/override attributes
builder.K6Version = "v0.35.0",
builder.Extensions = []xk6.Dependency{
{
PackagePath: "github.com/grafana/xk6-browser",
Version: "v0.1.1",
},
}

err := builder.Build(context.Background(), log. "./k6")
```

---

> This project originally forked from the [xcaddy](https://github.com/caddyserver/xcaddy) project. **Thank you!**
Loading

0 comments on commit 4c76f08

Please sign in to comment.