Skip to content
This repository has been archived by the owner on Sep 17, 2021. It is now read-only.

Commit

Permalink
Add test and xk6 CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed Jun 22, 2021
1 parent 01a84bd commit 9ab8708
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test
on:
# Enable manually triggering this workflow via the API or web UI
workflow_dispatch:
push:
branches:
- master
tags:
- v*
pull_request:

defaults:
run:
shell: bash

jobs:
lint:
runs-on: ubuntu-latest
env:
GOLANG_CI_VERSION: "1.41.1"
GO111MODULE: 'on'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Install golangci-lint
working-directory: /tmp
run: go install "github.com/golangci/golangci-lint/cmd/golangci-lint@v$GOLANG_CI_VERSION"
- name: Run linters
run: |
golangci-lint run --out-format=tab ./...
test:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Run tests
run: |
set -x
go version
export GOMAXPROCS=2
go test -p 2 -race -timeout 60s ./...
39 changes: 39 additions & 0 deletions .github/workflows/xk6-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { sleep } from 'k6';
import exec from 'k6/x/execution';

export let options = {
scenarios: {
shared: {
executor: 'shared-iterations',
vus: 50,
iterations: 500,
},
rar: {
executor: 'ramping-arrival-rate',
startTime: '10s',
startRate: 20,
timeUnit: '1s',
preAllocatedVUs: 0,
maxVUs: 40,
stages: [
{ target: 50, duration: '5s' },
{ target: 0, duration: '5s' },
],
gracefulStop: '0s',
},
}
}

function logObj(msg, o) {
console.log(msg, JSON.stringify(o, Object.keys(o).sort()));
}

export default function () {
const vuStats = exec.getVUStats();
const scStats = exec.getScenarioStats();
const testStats = exec.getTestInstanceStats();
sleep(1);
logObj('VU stats:', vuStats);
logObj('Scenario stats:', scStats);
logObj('Test stats:', testStats);
}
48 changes: 48 additions & 0 deletions .github/workflows/xk6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: xk6
on:
# Enable manually triggering this workflow via the API or web UI
workflow_dispatch:
push:
branches:
- master
pull_request:

defaults:
run:
shell: bash

jobs:
test-xk6:
strategy:
matrix:
go: [stable, tip]
platform: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Install Go tip
if: matrix.go == '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: |
set -x
which go
go version
go install github.com/k6io/xk6/cmd/xk6@master
GOPROXY="direct" xk6 build master \
--output ./k6ext \
--with github.com/k6io/xk6-execution="$(pwd)"
./k6ext version
./k6ext run --quiet --verbose .github/workflows/xk6-test.js

0 comments on commit 9ab8708

Please sign in to comment.