Skip to content

CI

CI #576

Workflow file for this run

name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
# Runs at 15:00 UTC on Fri
- cron: "0 15 * * 5"
workflow_dispatch:
# This allows running it on any branch manually:
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
env:
CARGO_TERM_COLOR: always
# Deny warns here as a catch-all and because some commands (e.g. cargo build) don't accept `--deny warnings`
# but also deny them on all individual cargo invocations where applicable because:
# 1) Some commands might not support rustflags (e.g. clippy didn't at first, cargo doc uses a different var, ...)
# 2) People (or me) might copy paste the commands into CI where this flag is missing without noticing.
RUSTFLAGS: --deny warnings
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [stable, nightly]
# For reference: https://github.com/actions/virtual-environments#available-environments
os: [ubuntu-latest, windows-latest, macos-latest]
exclude:
# Each minute of MacOS CI counts as 10 minutes towards the limit
# (https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#minute-multipliers)
# and nightly doesn't benefit from caching much
# so this combination would take up the vast majority of the free CI limit.
- os: macos-latest
rust: nightly
steps:
- name: Install linux deps
if: ${{ matrix.os == 'ubuntu-latest' }}
# Run update first or install might start failing eventually
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y pkg-config libx11-dev libxi-dev libgl1-mesa-dev libasound2-dev
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: wasm32-unknown-unknown
# Caching must be after toolchain selection
- uses: Swatinem/rust-cache@v2
- name: Print versions
run: rustc --version && cargo --version
- name: Build native
# Use build instead of check since it needs to be built for tests anyway
run: cargo build --verbose --all-features
- name: Run tests
run: cargo test --verbose --all-features
- name: Build web
# Test WASM only on ubuntu - the result should be the same on any OS and ubuntu is the fastest.
if: ${{ matrix.os == 'ubuntu-latest' }}
run: cargo build --verbose --target wasm32-unknown-unknown
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo fmt --version
- run: cargo fmt -- --check
lint:
runs-on: ubuntu-latest
steps:
- name: Install linux deps
# Run update first or install might start failing eventually
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y pkg-config libx11-dev libxi-dev libgl1-mesa-dev libasound2-dev
- uses: actions/checkout@v3
# Use rust-toolchain because GHA tends to still have an old version for a few days after a new Rust release.
- uses: dtolnay/rust-toolchain@stable
# Caching must be after toolchain selection
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --version
# Use --all-targets to also check tests.
# Note that --all-features doesn't check all code when something is *disabled* by a feature.
- run: cargo clippy --all-targets --all-features -- --deny warnings
- run: ./extra-lints.sh