Skip to content

Use k6 events to handle browser lifecycle #2343

Use k6 events to handle browser lifecycle

Use k6 events to handle browser lifecycle #2343

Workflow file for this run

name: E2E
on:
# Enable manually triggering this workflow via the API or web UI
workflow_dispatch:
push:
branches:
- main
pull_request:
schedule:
# At 06:00 AM UTC from Monday through Friday
- cron: '0 6 * * 1-5'
defaults:
run:
shell: bash
jobs:
test:
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.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: Install xk6
run: go install go.k6.io/xk6/cmd/xk6@master
- name: Build extension
run: |
which go
go version
GOPRIVATE="go.k6.io/k6" xk6 build latest \
--output ./k6extension \
--with github.com/grafana/xk6-browser=.
./k6extension version
- name: Install Chrome dependencies
if: runner.os == 'Linux'
run: "${GITHUB_WORKSPACE}/.github/bin/install_chrome_deps_linux.sh"
- name: Setup Chrome
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- name: Chrome version
if: runner.os != 'Windows'
run: chrome --version
- name: Chrome version
if: runner.os == 'Windows'
shell: pwsh
# chrome --version doesn't work on Windows :-/
# See https://bugs.chromium.org/p/chromium/issues/detail?id=158372
run: (get-command chrome.exe).Version
- name: Run E2E tests
run: |
set -x
export K6_BROWSER_HEADLESS=true
for f in examples/*.js; do
./k6extension run "$f"
done
- name: Check screenshot
# TODO: Do something more sophisticated?
run: test -s screenshot.png