-
Notifications
You must be signed in to change notification settings - Fork 1.3k
87 lines (81 loc) · 3 KB
/
xk6.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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-2019, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
if: matrix.go != 'tip'
uses: actions/setup-go@v5
with:
go-version: 1.23.x
check-latest: true
- name: Download Go tip
if: matrix.go == 'tip'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download ${{ matrix.platform }} --repo grafana/gotip --pattern 'go.zip'
- name: Install Go tip
if: matrix.go == 'tip'
run: |
unzip go.zip -d $HOME/sdk
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
export CGO_ENABLED=0
COMMIT_ID="${{ github.event.pull_request.head.sha }}"
if [[ "$COMMIT_ID" == "" ]]; then
COMMIT_ID="$(git rev-parse HEAD)" # branch, not PR merge commit
fi
echo "COMMIT_ID=$COMMIT_ID"
cd .github/workflows/xk6-tests
go install go.k6.io/xk6/cmd/xk6@master
if [ "${{ github.event_name }}" == "pull_request" -a \
"${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
export XK6_K6_REPO="github.com/${{ github.event.pull_request.head.repo.full_name }}"
fi
# The following is a workaround for Windows, cause when using 'shell: bash', the PATH is expressed
# with ':' as separator, but Go code, running on a Windows OS, expects ';' as separator.
XPATH="$PATH"
if [[ "${{ matrix.platform }}" == "windows-latest" || "${{ matrix.platform }}" == "windows-2019" ]]; then
XPATH="$HOME/sdk/gotip/bin;$XPATH"
fi
PATH="$XPATH" \
GOPRIVATE="go.k6.io/k6" xk6 build "$COMMIT_ID" \
--output ./k6ext \
--with github.com/grafana/xk6-js-test="$(pwd)/xk6-js-test" \
--with github.com/grafana/xk6-output-test="$(pwd)/xk6-output-test"
./k6ext version
./k6ext run --out outputtest=output-results.txt xk6-test.js
OUTPUT_RESULT="$(cat output-results.txt)"
if [[ "$OUTPUT_RESULT" != "10" ]]; then
echo "output result was not as expected: $OUTPUT_RESULT"
exit 11
fi
SUMMARY_RESULT="$(cat summary-results.txt)"
if [[ "$SUMMARY_RESULT" != "10" ]]; then
echo "summary result was not as expected: $SUMMARY_RESULT"
exit 12
fi