Skip to content

Separate web testing into per-browser runners #25661

Separate web testing into per-browser runners

Separate web testing into per-browser runners #25661

Workflow file for this run

name: Test Web
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Paths filter
runs-on: ubuntu-22.04
outputs:
should_run: ${{ steps.filter.outputs.src }}
steps:
- uses: actions/checkout@v4
- uses: AurorNZ/paths-filter@v4
id: filter
with:
filters: |
src:
- '!**/*.md'
build:
needs: changes
if: needs.changes.outputs.should_run == 'true'
name: Test Node.js ${{ matrix.node_version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node_version: ["20", "22"]
os: [ubuntu-22.04, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
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: ${{ github.ref == 'refs/heads/master' }}
# 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.93
# Keep the version number in sync in all workflows,
# and in the extension builder Dockerfile!
- name: Install wasm-opt
# It takes too long to run on Windows, and has no benefit there.
if: matrix.os != 'windows-latest'
uses: sigoden/install-binary@v1
with:
repo: WebAssembly/binaryen
tag: version_119
name: wasm-opt
- name: Build
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
- name: Check formatting
working-directory: web
run: npm run lint
- name: Run node-based tests
working-directory: web
run: npm test
- name: Upload artifacts
if: matrix.os == 'ubuntu-22.04' && matrix.node_version == '22'
uses: actions/upload-artifact@v4
with:
name: selfhosted-dist
path: web/packages/selfhosted/dist
browser-tests:
# Only the instance that uploads the artifact is really needed, but there's no way to express that.
# See: https://github.com/orgs/community/discussions/42335
needs: build
if: needs.changes.outputs.should_run == 'true'
name: Test in ${{ matrix.browser }}
runs-on: ubuntu-22.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 artifacts
uses: actions/download-artifact@v4
with:
name: selfhosted-dist
path: web/packages/selfhosted/dist
- name: Run browser-based tests
working-directory: web
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
build-dummy:
needs: changes
if: needs.changes.outputs.should_run == 'false'
name: Test Node.js ${{ matrix.node_version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node_version: ["20", "22"]
os: [ubuntu-22.04, windows-latest]
steps:
- name: No-op
run: echo noop
browser-tests-dummy:
needs: build
if: needs.changes.outputs.should_run == 'false'
name: Test in ${{ matrix.browser }}
runs-on: ubuntu-22.04
strategy:
matrix:
browser: ["chrome", "firefox", "edge"]
steps:
- name: No-op
run: echo noop