Skip to content

Commit

Permalink
Merge pull request #14 from grafana/paul/bump-versions
Browse files Browse the repository at this point in the history
Updating extension to latest standard
  • Loading branch information
javaducky authored Apr 11, 2023
2 parents 9953360 + 0c01363 commit ec95c34
Show file tree
Hide file tree
Showing 7 changed files with 562 additions and 172 deletions.
58 changes: 45 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
- v*
pull_request:

defaults:
run:
shell: bash

jobs:
build-with-xk6:
runs-on: ubuntu-latest
Expand All @@ -19,24 +23,52 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.17.x
- name: Get module name
run: |
echo "::set-output name=Module::$(go list -m)"
id: module-name
- name: Verify builds with xk6
go-version: 1.20.x
- name: Check build
run: |
go version
pwd && ls -l
go install go.k6.io/xk6/cmd/xk6@latest
xk6 build --with ${{ steps.module-name.outputs.Module }}=.
MODULE_NAME=$(go list -m)
xk6 build \
--output ./k6ext \
--with $MODULE_NAME="."
./k6ext version
run-unit-tests:
runs-on: ubuntu-latest
test-go-versions:
strategy:
fail-fast: false
matrix:
go-version: [1.18.x, 1.19.x, 1.20.x, tip]
platform: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
- name: Install Go ${{ matrix.go-version }}
if: matrix.go-version != 'tip'
uses: actions/setup-go@v3
with:
go-version: 1.17.x
- name: Run unit tests
run: go test -v -cover -race ./...
go-version: ${{ matrix.go-version }}
- name: Install Go stable
if: matrix.go-version == 'tip'
uses: actions/setup-go@v3
with:
go-version: 1.x
- name: Install Go tip
shell: bash
if: matrix.go-version == 'tip'
run: |
go install golang.org/dl/gotip@latest
gotip download
echo "GOROOT=$HOME/sdk/gotip" >> "$GITHUB_ENV"
echo "GOPATH=$HOME/go" >> "$GITHUB_ENV"
echo "$HOME/go/bin" >> "$GITHUB_PATH"
echo "$HOME/sdk/gotip/bin" >> "$GITHUB_PATH"
- name: Run tests
run: |
which go
go version
go test -race -timeout 60s ./...
13 changes: 7 additions & 6 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,30 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.17.x
go-version: 1.20.x
- name: Check module dependencies
run: |
go version
test -z "$(go mod tidy && git status go.* --porcelain)"
go mod verify
# TODO: Enable linting and address linter errors, https://github.com/grafana/xk6-sql/issues/5
run-golangci:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.17.x
go-version: 1.20.x
- name: Retrieve golangci-lint version
run: |
echo "::set-output name=Version::$(head -n 1 "${GITHUB_WORKSPACE}/.golangci.yml" | tr -d '# ')"
echo "Version=$(head -n 1 "${GITHUB_WORKSPACE}/.golangci.yml" | tr -d '# ')" >> $GITHUB_OUTPUT
id: version
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: ${{ steps.version.outputs.Version }}
only-new-issues: true
126 changes: 90 additions & 36 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v1.43.0
# v1.52.2
# Please don't remove the first line. It is used in CI to determine the golangci version
run:
deadline: 5m
Expand All @@ -21,55 +21,109 @@ issues:
linters:
- cyclop
- dupl
- funlen
- gochecknoglobals
- gocognit
- funlen
- lll
- linters:
- paralleltest # false positive: https://github.com/kunwardeep/paralleltest/issues/8.
text: "does not use range value in test Run"
- linters:
- forbidigo
text: 'use of `os\.(SyscallError|Signal|Interrupt)` forbidden'

linters-settings:
nolintlint:
# Disable to ensure that nolint directives don't have a leading space. Default is true.
allow-leading-space: false
exhaustive:
default-signifies-exhaustive: true
govet:
check-shadowing: true
cyclop:
max-complexity: 25
maligned:
suggest-new: true
dupl:
threshold: 150
exhaustive:
default-signifies-exhaustive: true
funlen:
lines: 80
statements: 60
goconst:
min-len: 10
min-occurrences: 4
govet:
check-shadowing: true
maligned:
suggest-new: true
funlen:
lines: 80
statements: 60
forbidigo:
forbid:
- '^(fmt\\.Print(|f|ln)|print|println)$'
# Forbid everything in os, except os.Signal and os.SyscalError
- '^os\.(.*)$(# Using anything except Signal and SyscallError from the os package is forbidden )?'
# Forbid everything in syscall except the uppercase constants
- '^syscall\.[^A-Z_]+$(# Using anything except constants from the syscall package is forbidden )?'
- '^logrus\.Logger$'

linters:
enable-all: true
disable:
- exhaustivestruct
- gci
- gochecknoinits
- gocyclo # replaced by cyclop since it also calculates the package complexity
- godot
- godox
- goerr113 # most of the errors here are meant for humans
- goheader
- golint # this linter is deprecated
- gomnd
- gomodguard
- interfacer # deprecated
- ireturn
- maligned # replaced by govet 'fieldalignment'
- nlreturn
- scopelint # deprecated, replaced by exportloopref
- tagliatelle
- testpackage
- thelper
- varnamelen # disabled before the final decision in (https://github.com/grafana/k6/pull/2323)
- wrapcheck # a little bit too much for k6, maybe after https://github.com/tomarrell/wrapcheck/issues/2 is fixed
- wsl
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- contextcheck
- cyclop
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gocheckcompilerdirectives
- gochecknoglobals
- gocognit
- goconst
- gocritic
- gofmt
- gofumpt
- goimports
- gomoddirectives
- goprintffuncname
- gosec
- gosimple
- govet
- importas
- ineffassign
- lll
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- revive
- reassign
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- tenv
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
fast: false
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ make
```
Once built, you can run your newly extended `k6` using:
```shell
./k6 run example.js
./k6 run examples/script.js
```

## Example
Expand All @@ -48,7 +48,7 @@ export default function () {
Result output:

```
$ ./k6 run example.js
$ ./k6 run examples/script.js

/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
Expand All @@ -57,7 +57,7 @@ $ ./k6 run example.js
/ __________ \ |__| \__\ \_____/ .io

execution: local
script: ../example.js
script: examples/script.js
output: -

scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
Expand Down
File renamed without changes.
33 changes: 18 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
module github.com/grafana/xk6-exec

go 1.17
go 1.19

require go.k6.io/k6 v0.38.0
require go.k6.io/k6 v0.43.1

require (
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect
github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/dlclark/regexp2 v1.8.1 // indirect
github.com/dop251/goja v0.0.0-20230402114112-623f9dda9079 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible // indirect
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.27.6 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/afero v1.1.2 // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/guregu/null.v3 v3.3.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
gopkg.in/guregu/null.v3 v3.5.0 // indirect
)
Loading

0 comments on commit ec95c34

Please sign in to comment.