From 4c2df22ca026a325bdc74c50d8aaea0c5baeec69 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Fri, 7 Jul 2023 15:55:43 +0100 Subject: [PATCH 1/7] Add K6_BROWSER_EXECUTABLE_PATH in ci The github runners have both chromium and google chrome installed. Google chrome is kept up to date whereas chromium isn't. We want to work with the latest version of google chrome (for now, in the future we may want to install the exact version we want to work with). We've had issues working with chromium in the runners where the application crashes on startup. --- .github/workflows/e2e.yml | 3 +++ .github/workflows/test.yml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 2c6749430..04a3ff52c 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -67,6 +67,9 @@ jobs: - name: Run E2E tests 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 ./k6extension run "$f" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01d91ce3c..aa69fdec6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,6 +46,7 @@ jobs: args[1]="1" export GOMAXPROCS=1 fi + export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome export K6_BROWSER_HEADLESS=true go test "${args[@]}" -timeout 5m ./... @@ -75,6 +76,7 @@ jobs: go version export GOMAXPROCS=2 args=("-p" "2" "-race") + export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome export K6_BROWSER_HEADLESS=true go test "${args[@]}" -timeout 5m ./... @@ -104,6 +106,7 @@ jobs: args[1]="1" export GOMAXPROCS=1 fi + export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome export K6_BROWSER_HEADLESS=true echo "mode: set" > coverage.txt for pkg in $(go list ./... | grep -v vendor); do @@ -156,5 +159,6 @@ jobs: go get go.k6.io/k6@master go mod tidy cat go.mod | grep go.k6.io/k6 + export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome export K6_BROWSER_HEADLESS=true go test "${args[@]}" -timeout 5m ./... From fdcb847f9d412c0714f48d5cfc18bb9a03f51c36 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Fri, 7 Jul 2023 15:59:08 +0100 Subject: [PATCH 2/7] Update to work with the standard runner again --- .github/workflows/e2e.yml | 4 ++-- .github/workflows/test.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 04a3ff52c..1d3ecd1a3 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -19,8 +19,8 @@ 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: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa69fdec6..096fac6b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -51,7 +51,7 @@ jobs: go test "${args[@]}" -timeout 5m ./... test-tip: - runs-on: ubuntu-latest-8-cores + runs-on: ubuntu-latest continue-on-error: true steps: - name: Checkout code @@ -85,7 +85,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 @@ -132,7 +132,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 From 675bb66336bedd9a23a1a4c208e20d63020dca6c Mon Sep 17 00:00:00 2001 From: ankur22 Date: Fri, 7 Jul 2023 16:11:43 +0100 Subject: [PATCH 3/7] Fix matrix.platform to set the platform in e2e ci --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 1d3ecd1a3..0556b1178 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -20,7 +20,7 @@ jobs: matrix: go: [stable, tip] platform: [ubuntu-latest, windows-latest, macos-latest] - runs-on: ubuntu-latest + runs-on: ${{ matrix.platform }} steps: - name: Checkout code uses: actions/checkout@v2 From 36a8398f9edd88087f4193b7e40b3d70fb2c60c2 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Fri, 7 Jul 2023 16:41:21 +0100 Subject: [PATCH 4/7] Remove chrome setup step --- .github/workflows/e2e.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 0556b1178..e3fd93d37 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -48,22 +48,6 @@ 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 run: | set -x From 3c0aaac589f0a847a39eab9cae6889e3d6cb963d Mon Sep 17 00:00:00 2001 From: ankur22 Date: Wed, 16 Aug 2023 14:31:57 +0100 Subject: [PATCH 5/7] Refactor env vars to be inline with go test in ci --- .github/workflows/test.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 096fac6b5..11053ebf4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,9 +46,7 @@ jobs: args[1]="1" export GOMAXPROCS=1 fi - export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome - 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-tip: runs-on: ubuntu-latest @@ -76,9 +74,7 @@ jobs: go version export GOMAXPROCS=2 args=("-p" "2" "-race") - export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome - 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: @@ -106,8 +102,6 @@ jobs: args[1]="1" export GOMAXPROCS=1 fi - export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome - 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) @@ -115,7 +109,7 @@ jobs: 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 @@ -159,6 +153,4 @@ jobs: go get go.k6.io/k6@master go mod tidy cat go.mod | grep go.k6.io/k6 - export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome - 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 ./... From 95a87a4ad2df7f70b77f1569f7f19d254a5b69a9 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Wed, 16 Aug 2023 16:21:54 +0100 Subject: [PATCH 6/7] Add skip for examples/hosts.js on Windows It's not known why this example doesn't work in the github action runner. It works fine on a Windows 11 computer. --- .github/workflows/e2e.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e3fd93d37..8c350410c 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -56,6 +56,10 @@ jobs: 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 From 7d983cd7679ad95dcd4cdd42421ddaa9cd7e9448 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Wed, 16 Aug 2023 18:15:54 +0100 Subject: [PATCH 7/7] Add skip tip and windows e2e test run The e2e workflow for windows using the tip version of go doesn't seem to work on Windows (or at least in the ci github action). The tip is installed correctly, but when it comes to building the k6 binary using xk6, xk6 seems to always execute the stable version of the go binary and not the tip version. When running commands outside of xk6 to verify the env vars (e.g. GOROOT) it always returns the tip paths. It's unclear why this is happening. For now, we're skipping the windows e2e tip workflow. --- .github/workflows/e2e.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 8c350410c..0cf4ea8ed 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -23,13 +23,15 @@ jobs: runs-on: ${{ matrix.platform }} steps: - name: Checkout code + if: matrix.go != 'tip' || matrix.platform != 'windows-latest' uses: actions/checkout@v2 - name: Install Go + if: matrix.go != 'tip' || matrix.platform != 'windows-latest' 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 @@ -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 @@ -49,6 +53,7 @@ jobs: --with github.com/grafana/xk6-browser=. ./k6extension version - name: Run E2E tests + if: matrix.go != 'tip' || matrix.platform != 'windows-latest' run: | set -x if [ "$RUNNER_OS" == "Linux" ]; then @@ -63,5 +68,6 @@ jobs: ./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