Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add K6_BROWSER_EXECUTABLE_PATH in ci #962

Merged
merged 7 commits into from
Aug 17, 2023
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
35 changes: 16 additions & 19 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ jobs:
strategy:
matrix:
go: [stable, tip]
platform: [ubuntu-latest-8-cores, windows-latest, macos-latest]
runs-on: ubuntu-latest-8-cores
platform: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.platform }}
ka3de marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout code
if: matrix.go != 'tip' || matrix.platform != 'windows-latest'
ka3de marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/checkout@v2
- name: Install Go
if: matrix.go != 'tip' || matrix.platform != 'windows-latest'
inancgumus marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-go@v2
with:
go-version: 1.x
- name: Install Go tip
if: matrix.go == 'tip'
if: matrix.go == 'tip' && matrix.platform != 'windows-latest'
run: |
go install golang.org/dl/gotip@latest
gotip download
Expand All @@ -38,8 +40,10 @@ jobs:
echo "$HOME/go/bin" >> "$GITHUB_PATH"
echo "$HOME/sdk/gotip/bin" >> "$GITHUB_PATH"
- name: Install xk6
if: matrix.go != 'tip' || matrix.platform != 'windows-latest'
run: go install go.k6.io/xk6/cmd/xk6@master
- name: Build extension
if: matrix.go != 'tip' || matrix.platform != 'windows-latest'
run: |
which go
go version
Expand All @@ -48,29 +52,22 @@ jobs:
--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
if: matrix.go != 'tip' || matrix.platform != 'windows-latest'
run: |
set -x
if [ "$RUNNER_OS" == "Linux" ]; then
export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome
fi
export K6_BROWSER_HEADLESS=true
for f in examples/*.js; do
if [ "$f" == "examples/hosts.js" ] && [ "$RUNNER_OS" == "Windows" ]; then
echo "skipping $f on Windows"
continue
fi
./k6extension run "$f"
done
- name: Check screenshot
if: matrix.go != 'tip' || matrix.platform != 'windows-latest'
# TODO: Do something more sophisticated?
run: test -s screenshot.png
20 changes: 8 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
go-version: [1.19.x]
platform: [ubuntu-latest-8-cores]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
Expand Down Expand Up @@ -46,11 +46,10 @@ jobs:
args[1]="1"
export GOMAXPROCS=1
fi
export K6_BROWSER_HEADLESS=true
go test "${args[@]}" -timeout 5m ./...
K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome K6_BROWSER_HEADLESS=true go test "${args[@]}" -timeout 5m ./...
ka3de marked this conversation as resolved.
Show resolved Hide resolved

test-tip:
runs-on: ubuntu-latest-8-cores
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout code
Expand All @@ -75,15 +74,14 @@ jobs:
go version
export GOMAXPROCS=2
args=("-p" "2" "-race")
export K6_BROWSER_HEADLESS=true
go test "${args[@]}" -timeout 5m ./...
K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome K6_BROWSER_HEADLESS=true go test "${args[@]}" -timeout 5m ./...

test-current-cov:
strategy:
fail-fast: false
matrix:
go-version: [1.19.x]
platform: [ubuntu-latest-8-cores]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
Expand All @@ -104,15 +102,14 @@ jobs:
args[1]="1"
export GOMAXPROCS=1
fi
export K6_BROWSER_HEADLESS=true
echo "mode: set" > coverage.txt
for pkg in $(go list ./... | grep -v vendor); do
list=$(go list -test -f '{{ join .Deps "\n"}}' $pkg | grep github.com/grafana/xk6-browser | grep -v vendor || true)
if [ -n "$list" ]; then
list=$(echo "$list" | cut -f1 -d ' ' | sort -u | paste -sd, -)
fi

go test "${args[@]}" -timeout 5m --coverpkg="$list" -coverprofile=$(echo $pkg | tr / -).coverage $pkg
K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome K6_BROWSER_HEADLESS=true go test "${args[@]}" -timeout 5m --coverpkg="$list" -coverprofile=$(echo $pkg | tr / -).coverage $pkg
done
grep -h -v "^mode:" *.coverage >> coverage.txt
rm -f *.coverage
Expand All @@ -129,7 +126,7 @@ jobs:
fail-fast: false
matrix:
go-version: [1.19.x]
platform: [ubuntu-latest-8-cores]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
Expand All @@ -156,5 +153,4 @@ jobs:
go get go.k6.io/k6@master
go mod tidy
cat go.mod | grep go.k6.io/k6
export K6_BROWSER_HEADLESS=true
go test "${args[@]}" -timeout 5m ./...
K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome K6_BROWSER_HEADLESS=true go test "${args[@]}" -timeout 5m ./...