Add getByRole in the browser module #5497
This file contains hidden or 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: Test | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: read | |
jobs: | |
test-prev: | |
strategy: | |
fail-fast: false | |
matrix: | |
go-version: [1.23.x] | |
platform: [ubuntu-22.04, ubuntu-24.04-arm, windows-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- 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@v5 | |
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/MacOS to minimize flakiness. | |
if [[ "${{ matrix.platform }}" == windows* || "${{ matrix.platform }}" == macos* ]]; then | |
unset args[2] | |
args[1]="1" | |
export GOMAXPROCS=1 | |
fi | |
go test "${args[@]}" -timeout 800s ./... | |
test-tip: | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [ubuntu-22.04, ubuntu-24.04-arm, windows-latest] | |
runs-on: ${{ matrix.platform }} | |
continue-on-error: true | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
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 tests | |
run: | | |
set -x | |
which go | |
go version | |
export GOMAXPROCS=2 | |
args=("-p" "2" "-race") | |
# Run with less concurrency on Windows/MacOS to minimize flakiness. | |
if [[ "${{ matrix.platform }}" == windows* || "${{ matrix.platform }}" == macos* ]]; then | |
unset args[2] | |
args[1]="1" | |
export GOMAXPROCS=1 | |
fi | |
go test "${args[@]}" -timeout 800s ./... | |
test-current-cov: | |
strategy: | |
fail-fast: false | |
matrix: | |
go-version: [1.24.x] | |
platform: [ubuntu-22.04, ubuntu-24.04-arm, windows-latest] | |
permissions: # required for Vault | |
id-token: write | |
contents: read | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
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 with code coverage | |
run: | | |
go version | |
export GOMAXPROCS=2 | |
args=("-p" "2" "-race") | |
# Run with less concurrency on Windows/MacOS to minimize flakiness. | |
if [[ "${{ matrix.platform }}" == windows* || "${{ matrix.platform }}" == macos* ]]; then | |
unset args[2] | |
args[1]="1" | |
export GOMAXPROCS=1 | |
fi | |
echo "mode: set" > coverage.txt | |
for pkg in $(go list ./... | grep -v vendor); do | |
list=$(go list -test -f '{{ join .Deps "\n"}}' $pkg | grep go.k6.io/k6 | grep -v vendor || true) | |
if [ -n "$list" ]; then | |
list=$(echo "$list" | cut -f1 -d ' ' | sort -u | paste -sd, -) | |
fi | |
go test "${args[@]}" -timeout 800s --coverpkg="$list" -coverprofile=$(echo $pkg | tr / -).coverage $pkg | |
done | |
grep -h -v "^mode:" *.coverage >> coverage.txt | |
rm -f *.coverage | |
# Sets CODECOV_TOKEN as an environment variable for the next step | |
- name: Get Codecov token | |
# Skip this step if the PR is from a fork, as we can't fetch secrets for forks. | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
uses: grafana/shared-workflows/actions/get-vault-secrets@get-vault-secrets/v1.2.1 | |
with: | |
repo_secrets: | | |
CODECOV_TOKEN=CODECOV_TOKEN:CODECOV_TOKEN | |
- name: Upload coverage to Codecov | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
env: | |
CODECOV_BASH_VERSION: 1.0.1 | |
CODECOV_BASH_SHA512SUM: d075b412a362a9a2b7aedfec3b8b9a9a927b3b99e98c7c15a2b76ef09862aeb005e91d76a5fd71b511141496d0fd23d1b42095f722ebcd509d768fba030f159e | |
run: | | |
if [[ "${{ matrix.platform }}" == macos* ]]; then | |
shopt -s expand_aliases | |
alias sha512sum='shasum -a 512' | |
fi | |
curl -fsSLO "https://raw.githubusercontent.com/codecov/codecov-bash/${CODECOV_BASH_VERSION}/codecov" | |
echo "$CODECOV_BASH_SHA512SUM codecov" | sha512sum -c - | |
platform="${{ matrix.platform }}" | |
bash ./codecov -F "${platform%%-*}" | |
- name: Generate coverage HTML report | |
run: go tool cover -html=coverage.txt -o coverage.html | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-coverage-report-${{ matrix.platform }} | |
path: coverage.html |