Use the precompiled 'gotip' on the xk6 workflow #6396
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Remove the default Go installation | |
if: matrix.go == 'tip' && (matrix.platform == 'windows-latest' || matrix.platform == 'windows-2019') | |
shell: pwsh | |
run: | | |
$go_path = (Get-Command go).Source | |
Write-Host "Removing Go executable from: $go_path" | |
Remove-Item -Force $go_path | |
- 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: | | |
set -x | |
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" | |
echo "$PATH" | |
- name: Run tests | |
run: | | |
set -x | |
which go | |
go version | |
echo "$PATH" | |
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 | |
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 |