CI #289
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: 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: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
rust: [nightly, stable] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
# Caching must be after toolchain selection | |
- uses: Swatinem/rust-cache@v2 | |
- run: rustc --version && cargo --version | |
- run: cargo build --verbose | |
- run: cargo test --verbose --all-features | |
bench: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@nightly | |
# Caching must be after toolchain selection | |
- uses: Swatinem/rust-cache@v2 | |
- run: | | |
sudo apt-get update # Run update first or install might start failing eventually. | |
sudo apt-get install --no-install-recommends -y hyperfine | |
- run: rustc --version && cargo --version | |
- run: ./bench.sh --show-output | |
working-directory: cvars-bench-compile-time | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- 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 | |
- run: cargo fmt --version | |
- run: cargo fmt -- --check | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- 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. | |
# LATER Seems like this doesn't check tests because we're using trybuild. Any way to fix that? | |
- run: cargo clippy --all-targets --all-features -- --deny warnings | |
# No fixmes allowed - they're to be fixed before committing | |
# or at least before merging to master so they can be used | |
# during development for things that must not be forgotten | |
# and grep's output is not littered with other people's fixmes. | |
# | |
# Grep returns success when found and failure when not found, `!` inverts success/failure. | |
# The `[F]` is the usual trick to avoid matching this line itself | |
# while still matching other potential uses in this file. | |
- run: "! ( grep --recursive --exclude-dir=target [F]IXME . && echo 'The lines above this message must be fixed (or marked as todo/later in uppercase, not fixme)' )" | |
docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Docs.rs uses nightly https://docs.rs/about/builds | |
- uses: dtolnay/rust-toolchain@nightly | |
# Caching must be after toolchain selection | |
- uses: Swatinem/rust-cache@v2 | |
- run: rustc --version && cargo --version | |
- run: cargo doc --all-features | |
env: | |
RUSTDOCFLAGS: --deny warnings |