Skip to content

Commit

Permalink
build with k6 version from go.mod
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Chacin <[email protected]>
  • Loading branch information
pablochacin committed Feb 14, 2024
1 parent 27bf323 commit d25abd5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,40 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: get k6 version
run: |
K6_VERSION=$(cat go.mod | grep "go.k6.io/k6" | cut -d' ' -f 2)
echo "K6_VERSION=$K6_VERSION" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build with xk6
env:
K6_VERSION: ${{ env.K6_VERSION }}
run: |
go install go.k6.io/xk6/cmd/xk6@latest
xk6 build --with $(go list -m)=.
build-with-xk6-docker:
runs-on: ubuntu-latest
steps:
- name: get k6 version
run: |
K6_VERSION=$(cat go.mod | grep "go.k6.io/k6" | cut -d' ' -f 2)
echo "K6_VERSION=$K6_VERSION" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: Build with xk6
env:
K6_VERSION: ${{ env.K6_VERSION }}
run: |
docker run --rm -i -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" grafana/xk6 build --with $(go list -m)=/xk6
docker run --rm -i -u "$(id -u):$(id -g)" \
-v "${PWD}:/xk6-disruptor" \
-e K6_VERSION="${K6_VERSION}" \
grafana/xk6 build --with $(go list -m)=/xk6-disruptor
run-unit-tests:
runs-on: ${{ matrix.os }}
Expand Down
7 changes: 6 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $0 [OPTIONS]
options:
-a, --arch: target architecture (valid option amd64, arm64. Defaults to GOARCH)
-b, --build: directory for building binaries (defaults to 'build. Created if it does not exist)
-k, --k6-version: version of k6 to use
-n, --name: package base name. Defaults to 'xk6-disruptor'
-o, --os: target operating systems (valid options linux, darwing, windows. Defaults to GOOS)
-r, --replace: module that replaces xk6-distruptor module
Expand Down Expand Up @@ -46,6 +47,10 @@ while [[ $# -gt 0 ]]; do
BUILD="$2"
shift
;;
-k|--k6-version)
K6_VERSION="$2"
shift
;;
-o|--os)
OS="$2"
if [[ ! $OS =~ linux|darwin|windows ]]; then
Expand Down Expand Up @@ -112,6 +117,6 @@ fi
export GOARCH=$ARCH
export GOOS=$OS
export XK6_BUILD_FLAGS='-ldflags "-w -s'
xk6 build --with $MOD=${REPLACE} --output $BUILD/$BINARY
xk6 build $K6_VERSION --with $MOD=${REPLACE} --output $BUILD/$BINARY
)

0 comments on commit d25abd5

Please sign in to comment.