Skip to content

Commit

Permalink
Split tests by tags
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Dec 13, 2024
1 parent 745f0d4 commit bfdc271
Show file tree
Hide file tree
Showing 28 changed files with 140 additions and 1 deletion.
83 changes: 83 additions & 0 deletions .github/workflows/test-browser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Browser Tests
on:
push:
branches:
- master
pull_request:

defaults:
run:
shell: bash

jobs:
test-prev:
strategy:
fail-fast: false
matrix:
go-version: [1.22.x, 1.23.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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: 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
K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome K6_BROWSER_HEADLESS=true go test "${args[@]}" -timeout 800s -tags=browser_tests go.k6.io/k6/js/modules/k6/browser/tests
test-tip:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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: 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
K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome K6_BROWSER_HEADLESS=true go test "${args[@]}" -timeout 800s -tags=browser_tests go.k6.io/k6/js/modules/k6/browser/tests
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ lint: check-linter-version
tests:
go test -race -timeout 210s ./...

## test: Executes browser tests.
browser-tests:
go test -race -timeout 120s ./... -tags=browser_tests

## check: Runs the linters and tests.
check: lint tests

Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/browser_context_options_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/browser_context_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/browser_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/browser_type_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

// Package tests provides integration tests.
// The `testBrowser` type enables us to test the browser module with a real browser.
package tests
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/element_handle_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/frame_manager_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/frame_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/helpers.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/js_handle_get_properties_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/js_handle_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/keyboard_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/launch_options_slowmo_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/lifecycle_wait_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/locator_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/logrus_hook.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/mouse_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/network_manager_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
4 changes: 3 additions & 1 deletion js/modules/k6/browser/tests/page_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down Expand Up @@ -2135,7 +2137,7 @@ func TestPageOnMetric(t *testing.T) {
const page = await browser.newPage()
%s
await page.goto('%s', {waitUntil: 'networkidle'});
await page.close()
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/remote_obj_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/setinputfiles_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/test_browser.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/test_browser_proxy.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/test_browser_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/tracing_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down
2 changes: 2 additions & 0 deletions js/modules/k6/browser/tests/webvital_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build browser_tests

package tests

import (
Expand Down

0 comments on commit bfdc271

Please sign in to comment.