Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/actions/test-browser/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Test browser"
description: "Run only tests in browser/tests package without parallel execution"

inputs:
use_gotip:
description: "whether to set up gotip env variables or not"
required: false
default: "false"

runs:
using: "composite"
steps:
- name: Run tests
shell: bash
env:
USE_GOTIP: ${{ inputs.use_gotip }}
run: |
set -x

if [[ ${USE_GOTIP} == 'true' ]]; then
export GOROOT="$HOME/sdk/gotip"
export GOPATH="$HOME/go"
export PATH="$HOME/sdk/gotip/bin:$HOME/go/bin:$PATH" > /dev/null
fi

which go
go version
export GOMAXPROCS=1
go test -p 1 -timeout 800s ./internal/js/modules/k6/browser/tests/...
39 changes: 39 additions & 0 deletions .github/actions/test-common/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Test common"
description: "Pre-test steps: Go install and optional Chromium install"

inputs:
go_version:
description: "Go version (eg 1.25.x) or gotip."
required: false
default: "1.25.x"
platform:
description: "matrix.platform value (used for windows/arm detection)."
required: true

runs:
using: "composite"
steps:
- name: Install Go
if: ${{ inputs.go_version != 'gotip' }}
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
with:
go-version: ${{ inputs.go_version }}
check-latest: true

- name: Download and install Go tip
if: ${{ inputs.go_version == 'gotip' }}
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLATFORM: ${{ inputs.platform }}
run: |
gh release download ${PLATFORM} --repo grafana/gotip --pattern 'go.zip'
unzip go.zip -d $HOME/sdk

- name: Install chromium
# This is only needed on arm images, chromium comes preinstalled on amd64 runner images.
if: ${{contains(inputs.platform, 'arm') }}
shell: bash
run: |
sudo apt update && sudo apt install chromium-browser
chromium --version || true
42 changes: 42 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Test"
description: "Run all tests except ones in browser/tests package"

inputs:
platform:
description: "matrix.platform value (used for windows/arm detection)."
required: true
use_gotip:
description: "whether to set up gotip env variables or not"
required: false
default: "false"

runs:
using: "composite"
steps:
- name: Run tests
shell: bash
env:
PLATFORM: ${{ inputs.platform }}
USE_GOTIP: ${{ inputs.use_gotip }}
run: |
set -x

if [[ ${USE_GOTIP} == 'true' ]]; then
export GOROOT="$HOME/sdk/gotip"
export GOPATH="$HOME/go"
export PATH="$HOME/sdk/gotip/bin:$HOME/go/bin:$PATH" > /dev/null
fi

which go
go version
export GOMAXPROCS=2
args=("-p" "2" "-race")
# Run with less concurrency on Windows/ARM to minimize flakiness.
if [[ "${PLATFORM}" == windows* || "${PLATFORM}" == *arm ]]; then
args[1]="1"
export GOMAXPROCS=1
if [[ "${PLATFORM}" == windows* ]]; then
unset args[2]
fi
fi
go test "${args[@]}" -timeout 800s `go list ./... | grep -v browser/tests`
90 changes: 90 additions & 0 deletions .github/workflows/test-browser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Browser tests
on:
push:
branches:
- master
pull_request:

defaults:
run:
shell: bash

permissions:
contents: read

jobs:
test-prev:
if: ${{ github.ref == 'refs/heads/master' }}
strategy:
fail-fast: false
matrix:
go-version: [1.24.x]
platform:
[ubuntu-22.04, ubuntu-arm64-large, github-hosted-windows-x64-large]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
fetch-depth: 0
persist-credentials: false
- name: Run common test steps
uses: ./.github/actions/test-common
with:
go_version: ${{ matrix.go-version }}
platform: ${{ matrix.platform }}
- name: Get the k6 version
id: get_k6_version
run: |
echo "Running tests on '${GITHUB_REF}' with '$(git describe --tags --always --long --dirty)' checked out..."
- name: Run tests
uses: ./.github/actions/test-browser

test-tip:
strategy:
fail-fast: false
matrix:
include:
- platform: ubuntu-22.04
gotip_platform: ubuntu-22.04
- platform: ubuntu-arm64-large
gotip_platform: ubuntu-24.04-arm
- platform: github-hosted-windows-x64-large
gotip_platform: windows-latest
runs-on: ${{ matrix.platform }}
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
persist-credentials: false
- name: Run common test steps
uses: ./.github/actions/test-common
with:
go_version: "gotip"
platform: ${{ matrix.gotip_platform }}
- name: Run tests
uses: ./.github/actions/test-browser
with:
use_gotip: "true"

test-latest:
strategy:
fail-fast: false
matrix:
go-version: [1.25.x]
platform:
[ubuntu-22.04, ubuntu-arm64-large, github-hosted-windows-x64-large]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
persist-credentials: false
- name: Run common test steps
uses: ./.github/actions/test-common
with:
go_version: ${{ matrix.go-version }}
platform: ${{ matrix.platform }}
- name: Run tests
uses: ./.github/actions/test-browser
108 changes: 25 additions & 83 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,19 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
- name: Run common test steps
uses: ./.github/actions/test-common
with:
go_version: ${{ matrix.go-version }}
platform: ${{ matrix.platform }}
- name: Get the k6 version
id: get_k6_version
run: |
echo "Running tests on '${GITHUB_REF}' with '$(git describe --tags --always --long --dirty)' checked out..."
- name: Install Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Install chromium
# This is only needed on arm images, chromium comes preinstalled on amd64 runner images.
if: contains(matrix.platform, 'arm')
run: |
sudo apt update && sudo apt install chromium-browser
chromium --version
- name: Run tests
run: |
set -x
go version
export GOMAXPROCS=2
args=("-p" "2" "-race")
# Run with less concurrency on Windows/ARM to minimize flakiness.
if [[ "${{ matrix.platform }}" == windows* || "${{ matrix.platform }}" == *arm ]]; then
args[1]="1"
export GOMAXPROCS=1
if [[ "${{ matrix.platform }}" == windows* ]]; then
unset args[2]
fi
fi
go test "${args[@]}" -timeout 800s ./...
uses: ./.github/actions/test
with:
platform: ${{ matrix.platform }}

test-tip:
strategy:
Expand All @@ -70,41 +53,17 @@ jobs:
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
persist-credentials: false
- name: Download Go tip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download ${{ matrix.platform }} --repo grafana/gotip --pattern 'go.zip'
- name: Install 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: Install chromium
# This is only needed on arm images, chromium comes preinstalled on amd64 runner images.
if: contains(matrix.platform, 'arm')
run: |
sudo apt update && sudo apt install chromium-browser
chromium --version
- name: Run common test steps
uses: ./.github/actions/test-common
with:
go_version: "gotip"
platform: ${{ matrix.platform }}
- name: Run tests
run: |
set -x
which go
go version
export GOMAXPROCS=2
args=("-p" "2" "-race")
# Run with less concurrency on Windows/ARM to minimize flakiness.
if [[ "${{ matrix.platform }}" == windows* || "${{ matrix.platform }}" == *arm ]]; then
args[1]="1"
export GOMAXPROCS=1
if [[ "${{ matrix.platform }}" == windows* ]]; then
unset args[2]
fi
fi
go test "${args[@]}" -timeout 800s ./...

uses: ./.github/actions/test
with:
use_gotip: "true"
platform: ${{ matrix.platform }}

test-latest:
strategy:
fail-fast: false
Expand All @@ -117,29 +76,12 @@ jobs:
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
persist-credentials: false
- name: Install Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
- name: Run common test steps
uses: ./.github/actions/test-common
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Install chromium
# This is only needed on arm images, chromium comes preinstalled on amd64 runner images.
if: contains(matrix.platform, 'arm')
run: |
sudo apt update && sudo apt install chromium-browser
chromium --version
go_version: ${{ matrix.go-version }}
platform: ${{ matrix.platform }}
- name: Run tests
run: |
set -x
go version
export GOMAXPROCS=2
args=("-p" "2" "-race")
# Run with less concurrency on Windows/ARM to minimize flakiness.
if [[ "${{ matrix.platform }}" == windows* || "${{ matrix.platform }}" == *arm ]]; then
args[1]="1"
export GOMAXPROCS=1
if [[ "${{ matrix.platform }}" == windows* ]]; then
unset args[2]
fi
fi
go test "${args[@]}" -timeout 800s ./...
uses: ./.github/actions/test
with:
platform: ${{ matrix.platform }}
Loading
Loading