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

Separate web testing into per-browser runners #17529

Merged
merged 4 commits into from
Oct 28, 2024
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
112 changes: 108 additions & 4 deletions .github/workflows/test_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
# Keep the version number in sync in all workflows,
# and in the extension builder Dockerfile!
- name: Install wasm-opt
# It runs for a long time, and the build is already slow on Windows,
# where it doesn't have much benefit anyway - most tests are run on Ubuntu.
if: matrix.os != 'windows-latest'
uses: sigoden/install-binary@v1
with:
repo: WebAssembly/binaryen
Expand All @@ -86,20 +89,108 @@ jobs:
npm run build

- name: Check formatting
if: matrix.os == 'ubuntu-24.04'
working-directory: web
run: npm run lint

- name: Run node-based tests
working-directory: web
run: npm test

build-for-browser-tests:
needs: changes
if: needs.changes.outputs.should_run == 'true'
name: Build for browser tests
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: web/package-lock.json

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- name: Cache Cargo output
uses: Swatinem/rust-cache@v2
with:
shared-key: "web"
save-if: false

# wasm-bindgen-cli version must match wasm-bindgen crate version.
# Be sure to update in release_nightly.yml, Cargo.toml, web/docker/Dockerfile,
# and web/README.md as well.
- name: Install wasm-bindgen
run: cargo install wasm-bindgen-cli --version 0.2.95

# No real need to install wasm-opt here

- name: Build selfhosted
env:
RUSTFLAGS: -D warnings
# Verify that all features build.
CARGO_FLAGS: --all-features
working-directory: web
shell: bash -l {0}
run: |
npm ci
npm run build --workspace=ruffle-core
npm run build --workspace=ruffle-selfhosted

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: selfhosted-dist
path: web/packages/selfhosted/dist


browser-tests:
needs: build-for-browser-tests
if: needs.changes.outputs.should_run == 'true'
name: Test in ${{ matrix.browser }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
browser: ["chrome", "firefox", "edge"]

steps:
- uses: actions/checkout@v4

- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: web/package-lock.json

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: selfhosted-dist
path: web/packages/selfhosted/dist

- name: Run browser-based tests
# Don't run browser tests on Windows because it's flaky for unknown reasons. :-(
if: runner.os == 'Linux'
working-directory: web
run: npm run wdio -- --headless --chrome --firefox --edge
shell: bash -l {0}
run: |
npm ci
npm run wdio -- --headless --parallel --${{ matrix.browser }}

# The rest is needed only because otherwise the real jobs couldn't be made required for merging PRs,
# as they would fail the entire workflow run if skipped - this makes GitHub happy instead.
# See:
# - https://github.com/orgs/community/discussions/13690
# - https://github.com/orgs/community/discussions/44490

check-required:
build-dummy:
needs: changes
if: needs.changes.outputs.should_run == 'false'
name: Test Node.js ${{ matrix.node_version }} / ${{ matrix.os }}
Expand All @@ -112,3 +203,16 @@ jobs:
steps:
- name: No-op
run: echo noop

browser-tests-dummy:
needs: changes
if: needs.changes.outputs.should_run == 'false'
name: Test in ${{ matrix.browser }}
runs-on: ubuntu-24.04
strategy:
matrix:
browser: ["chrome", "firefox", "edge"]

steps:
- name: No-op
run: echo noop
9 changes: 5 additions & 4 deletions web/packages/selfhosted/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const firefox = process.argv.includes("--firefox");
const edge = process.argv.includes("--edge");
const browserstack = process.argv.includes("--browserstack");
const oldVersions = process.argv.includes("--oldVersions");
const maxInstances = process.argv.includes("--parallel") ? 4 : 1;

let user: string | undefined = undefined;
let key: string | undefined = undefined;
Expand All @@ -22,7 +23,7 @@ if (chrome) {
args.push("--headless");
torokati44 marked this conversation as resolved.
Show resolved Hide resolved
}
capabilities.push({
"wdio:maxInstances": 1,
"wdio:maxInstances": maxInstances,
browserName: "chrome",
"goog:chromeOptions": {
args,
Expand All @@ -36,7 +37,7 @@ if (edge) {
args.push("--headless");
}
capabilities.push({
"wdio:maxInstances": 1,
"wdio:maxInstances": maxInstances,
browserName: "MicrosoftEdge",
torokati44 marked this conversation as resolved.
Show resolved Hide resolved
"ms:edgeOptions": {
args,
Expand All @@ -50,7 +51,7 @@ if (firefox) {
args.push("-headless");
}
capabilities.push({
"wdio:maxInstances": 1,
"wdio:maxInstances": maxInstances,
browserName: "firefox",
"moz:firefoxOptions": {
args,
Expand Down Expand Up @@ -219,7 +220,7 @@ export const config: Options.Testrunner = {
"./test/js_api/*.ts",
"./test/integration_tests/**/test.ts",
],
maxInstances: 10,
maxInstances: maxInstances,
capabilities,
logLevel: "info",
bail: 0,
Expand Down