Skip to content

Re-try to start WebDriver on failure #212

Re-try to start WebDriver on failure

Re-try to start WebDriver on failure #212

Workflow file for this run

name: Test
on:
push:
branches: ["main"]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
test:
name:
Test ${{ matrix.driver.description }} ${{ matrix.environment.description }} ${{
matrix.rust.description }} ${{ matrix.features.description }}
runs-on: ${{ matrix.driver.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
target:
- { target: wasm32-unknown-unknown, docargs: -Zdoctest-xcompile }
rust:
- { version: nightly }
- {
version: nightly,
description: with Atomics,
component: --component rust-src,
flags: "-Ctarget-feature=+atomics,+bulk-memory",
build-std: true,
atomics: true,
}
features:
- { features: "", no_std: false }
- { features: --no-default-features, no_std: true, description: (`no_std`) }
- {
features: --no-default-features --features msrv,
no_std: true,
description: "(`no_std`, `msrv`)",
}
driver:
- {
os: ubuntu-latest,
description: Chrome,
env: CHROMEDRIVER,
binary: chromedriver,
browser: true,
}
- {
os: ubuntu-latest,
description: Firefox,
env: GECKODRIVER,
binary: geckodriver,
browser: true,
firefox: true,
}
- {
os: macos-latest,
description: Safari,
env: SAFARIDRIVER,
binary: safaridriver,
browser: true,
}
- { os: ubuntu-24.04, description: Node.js, nodejs: true }
environment:
- { name: WASM_BINDGEN_USE_BROWSER, browser: true }
- {
description: Dedicated Worker,
name: WASM_BINDGEN_USE_DEDICATED_WORKER,
browser: true,
}
- {
description: Shared Worker,
name: WASM_BINDGEN_USE_SHARED_WORKER,
browser: true,
shared-worker: true,
}
- {
description: Service Worker,
name: WASM_BINDGEN_USE_SERVICE_WORKER,
browser: true,
service-worker: true,
}
- { nodejs: true, no-modules: true }
- { description: ESM, name: WASM_BINDGEN_USE_NODE_EXPERIMENTAL, nodejs: true }
include:
- target: { target: x86_64-unknown-linux-gnu }
rust: { version: stable }
features: { features: "", no_std: false }
driver: { os: ubuntu-latest, description: Native, native: true }
exclude:
- driver: { browser: true }
environment: { browser: false }
- driver: { nodejs: true }
environment: { browser: true }
# Firefox doesn't support `Atomics.waitAsync()` and the polyfill requires spawning workers.
- driver: { firefox: true }
rust: { atomics: true }
environment: { shared-worker: true }
# Firefox doesn't support module service workers.
- driver: { firefox: true }
environment: { service-worker: true }
# Thread spawning is only supported for ESM
- rust: { atomics: true }
environment: { no-modules: true }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install `wasm-bindgen-cli`
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: wasm-bindgen-cli
git: https://github.com/daxpedda/wasm-bindgen
rev: 9dc93d8c096cdb50c2c2d8a181f337ddfa927517
- name: Install Rust
run: |
rustup toolchain install ${{ matrix.rust.version }} --profile minimal ${{ matrix.rust.component }} --target ${{ matrix.target.target }}
rustup default ${{ matrix.rust.version }}
- name: Set `build-std` components
if: matrix.rust.build-std == true && matrix.features.no_std == false
run: echo "BUILD_STD_COMPONENTS=-Zbuild-std=panic_abort,std" >> $GITHUB_ENV
- name: Set `build-std` `no_std` components
if: matrix.rust.build-std == true && matrix.features.no_std == true
run: echo "BUILD_STD_COMPONENTS=-Zbuild-std=core,alloc" >> $GITHUB_ENV
- name: Start and set WebDriver
if: matrix.driver.browser == true
run: |
iteration=5
while true; do
if (( iteration == 0 )); then
echo "CI: Failed to start driver."
exit 1
fi
(( iteration-- ))
${{ matrix.driver.binary }} --port=9000 2>stderr &
process_pid=$!
tail -f stderr >&2 &
while true; do
sleep 1
if [[ $(wc -l < stderr) -gt 0 ]]; then
echo "CI: WebDriver failed"
kill -SIGKILL $process_pid || true
echo
echo "CI: stderr:"
sed 's/^/CI: /' stderr
echo
echo "CI: Re-trying to start the WebDriver."
break
else
port=$(lsof -p $process_pid -a -i4| tail -n +2 | awk '{print $9}' | cut -d: -f2)
if [[ $port ]]; then
echo "Successfully started WebDriver on port $port."
echo "${{ matrix.driver.env }}_REMOTE=http://127.0.0.1:9000" >> $GITHUB_ENV
break 2
else
lsof -p $process_pid
fi
fi
done
done
- name: Set environment
if: matrix.environment.name != ''
run: echo "${{ matrix.environment.name }}=1" >> $GITHUB_ENV
- name: Test
env:
RUSTFLAGS: ${{ matrix.rust.flags }}
RUSTDOCFLAGS: ${{ matrix.rust.flags }}
run:
cargo test --features serde ${{ matrix.features.features }} --target ${{
matrix.target.target }} $BUILD_STD_COMPONENTS --workspace ${{ matrix.target.docargs }}