Add UCAN version badge (#119) #353
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🧪 Tests and Checks | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ '*' ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
run-checks: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
rust-toolchain: | |
- stable | |
- nightly | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
# Smarter caching action, speeds up build times compared to regular cache: | |
# https://github.com/Swatinem/rust-cache | |
- name: Cache Project | |
uses: Swatinem/rust-cache@v2 | |
- name: Install Rust Toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust-toolchain }} | |
components: clippy, rustfmt | |
- name: Check Format | |
run: cargo +${{ matrix.rust-toolchain }} fmt --all -- --check | |
- name: Run Linter | |
run: cargo +${{ matrix.rust-toolchain }} clippy --all -- -D warnings | |
- name: Install Cargo Audit | |
if: ${{ matrix.rust-toolchain == 'stable' }} | |
run: cargo install --force cargo-audit | |
- name: Run Audit on Deps | |
if: ${{ matrix.rust-toolchain == 'stable' }} | |
run: cargo-audit audit | |
# Only "test" release build on push event. | |
- name: Test Release | |
if: ${{ matrix.rust-toolchain == 'stable' && github.event_name == 'push' }} | |
run: cargo build --release | |
run-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
rust-toolchain: | |
- stable | |
- nightly | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Install Environment Packages | |
run: | | |
sudo apt-get update -qqy | |
sudo apt-get install jq | |
- name: Cache Project | |
uses: Swatinem/rust-cache@v2 | |
- name: Install Rust Toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust-toolchain }} | |
- name: Run Tests | |
run: cargo test --all | |
- name: Install Rust/WASM Test Dependencies | |
run: | | |
rustup target install wasm32-unknown-unknown | |
cargo install toml-cli | |
WASM_BINDGEN_VERSION=`toml get ./Cargo.lock . | jq '.package | map(select(.name == "wasm-bindgen"))[0].version' | xargs echo` | |
cargo install wasm-bindgen-cli --vers "$WASM_BINDGEN_VERSION" | |
# See: https://github.com/SeleniumHQ/selenium/blob/5d108f9a679634af0bbc387e7e3811bc1565912b/.github/actions/setup-chrome/action.yml | |
- name: Setup Chrome and Chromedriver | |
run: | | |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list.d/google-chrome.list | |
sudo apt-get update -qqy | |
sudo apt-get -qqy install google-chrome-stable | |
CHROME_VERSION=$(google-chrome-stable --version) | |
CHROME_FULL_VERSION=${CHROME_VERSION%%.*} | |
CHROME_MAJOR_VERSION=${CHROME_FULL_VERSION//[!0-9]} | |
sudo rm /etc/apt/sources.list.d/google-chrome.list | |
export CHROMEDRIVER_VERSION=`curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION%%.*}` | |
curl -L -O "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" | |
unzip chromedriver_linux64.zip && chmod +x chromedriver && sudo mv chromedriver /usr/local/bin | |
chromedriver -version | |
- name: Run Rust Headless Browser Tests | |
run: CHROMEDRIVER=/usr/local/bin/chromedriver cargo test --target wasm32-unknown-unknown |