Skip to content

Re-try to start WebDriver on failure #213

Re-try to start WebDriver on failure

Re-try to start WebDriver on failure #213

name: Coverage & Documentation
on:
push:
branches: ["main"]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
coverage:
name: Test Coverage ${{ matrix.mt.description }} ${{ matrix.features.description }}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
mt:
- { id: "st" }
- {
id: "mt",
description: with Atomics,
component: --component rust-src,
cflags: -matomics -mbulk-memory,
flags: "-Ctarget-feature=+atomics,+bulk-memory",
build-std: true,
}
features:
- { id: "", features: "", no_std: false }
- { id: -no_std, features: --no-default-features, no_std: true, description: (`no_std`) }
env:
CFLAGS_wasm32_unknown_unknown: ${{ matrix.mt.cflags }}
RUSTFLAGS:
-Cinstrument-coverage -Zcoverage-options=condition -Zno-profiler-runtime --emit=llvm-ir
--cfg=wasm_bindgen_unstable_test_coverage ${{ matrix.mt.flags }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install `wasm-bindgen-cli`
uses: taiki-e/install-action@v2
with:
tool: wasm-bindgen-cli
- name: Install Clang v19
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main"
sudo apt-get install clang-19
- name: Install Rust nightly
run: |
rustup toolchain install nightly --profile minimal --target wasm32-unknown-unknown ${{ matrix.mt.component }}
rustup default nightly
- name: Set `build-std` components
if: matrix.mt.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.mt.build-std == true && matrix.features.no_std == true
run: echo "BUILD_STD_COMPONENTS=-Zbuild-std=core,alloc" >> $GITHUB_ENV
- name: Test
env:
WASM_BINDGEN_USE_BROWSER: 1
CHROMEDRIVER_REMOTE: http://127.0.0.1:9000
run: |
chromedriver --port=9000 &
mkdir coverage-output
WASM_BINDGEN_UNSTABLE_TEST_PROFRAW_OUT=$(realpath coverage-output) cargo test --workspace --features serde --target wasm32-unknown-unknown $BUILD_STD_COMPONENTS ${{ matrix.features.features }} --tests
- name: Prepare Object Files
run: |
mkdir coverage-input
crate_name=web_time
IFS=$'\n'
for file in $(
cargo test --workspace --features serde --target wasm32-unknown-unknown $BUILD_STD_COMPONENTS ${{ matrix.features.features }} --tests --no-run --message-format=json | \
jq -r "select(.reason == \"compiler-artifact\") | (select(.target.kind == [\"test\"]) // select(.target.name == \"$crate_name\")) | .filenames[0]"
)
do
if [[ ${file##*.} == "rlib" ]]; then
base=$(basename $file .rlib)
file=$(dirname $file)/${base#"lib"}.ll
else
file=$(dirname $file)/$(basename $file .wasm).ll
fi
clang-19 $file -Wno-override-module -c -o coverage-output/$(basename $file .ll).o
done
- name: Upload Test Coverage Artifact
uses: actions/upload-artifact@v4
with:
name: test-coverage-${{ matrix.mt.id }}${{ matrix.features.id }}
path: coverage-output
retention-days: 1
if-no-files-found: error
collect-coverage:
name: Collect Test Coverage
needs: coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust nightly
run: |
rustup toolchain install nightly --profile minimal --component llvm-tools
rustup default nightly
- name: Install `cargo-binutils`
uses: taiki-e/install-action@v2
with:
tool: cargo-binutils
- name: Download Test Coverage
uses: actions/download-artifact@v4
with:
pattern: test-coverage-*
path: coverage-input
- name: Merge Profile Data
run:
rust-profdata merge -sparse coverage-input/*/*.profraw -o coverage-input/coverage.profdata
- name: Export Code Coverage Report
run: |
mkdir coverage-output
objects=()
for file in $(ls coverage-input/*/*.o)
do
objects+=(-object $file)
done
rust-cov show -show-instantiations=false -output-dir coverage-output -format=html -instr-profile=coverage-input/coverage.profdata ${objects[@]} -sources src
rust-cov export -format=text -summary-only -instr-profile=coverage-input/coverage.profdata ${objects[@]} -sources src | \
printf '{ "coverage": "%.2f%%" }' $(jq '.data[0].totals.functions.percent') > coverage-output/coverage.json
sed 's/<!doctype html>//' coverage-output/index.html | sed "s/<script src='control.js'><\/script>//" | perl -p0e 's/<a[^>]*>((?!here).*?)<\/a>/$1/g' >> $GITHUB_STEP_SUMMARY
- name: Upload Test Coverage Artifact
uses: actions/upload-artifact@v4
with:
name: test-coverage
path: coverage-output
if-no-files-found: error
document:
name: Document
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust nightly
run: |
rustup toolchain install nightly --profile minimal --target wasm32-unknown-unknown
rustup default nightly
- name: Run Rustdoc
env:
RUSTDOCFLAGS: --crate-version main --cfg=docsrs
run:
cargo doc --no-deps -Z rustdoc-map -Z rustdoc-scrape-examples --target
wasm32-unknown-unknown --features serde
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Fix permissions
run: |
chmod -c -R +rX "target/wasm32-unknown-unknown/doc" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload
uses: actions/upload-artifact@v4
with:
name: documentation
path: target/wasm32-unknown-unknown/doc
retention-days: 1
if-no-files-found: error
deploy:
name: Deploy
needs: [collect-coverage, document]
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}doc/web_time
runs-on: ubuntu-latest
if:
github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.ref_name ==
'main')
permissions:
contents: read
pages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Test Coverage
uses: actions/download-artifact@v4
with:
name: test-coverage
path: page/coverage
- name: Download Documentation
uses: actions/download-artifact@v4
with:
name: documentation
path: page/doc
- name: Upload Page Artifact
uses: actions/upload-pages-artifact@v3
with:
path: page
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4