Rust #272
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: Rust | |
# I unfortunately could not figure out how to get the SRC_DR to work in the | |
# paths key | |
env: | |
CARGO_TERM_COLOR: always | |
SRC_DIR: "xbf_rs" | |
on: | |
push: | |
branches: ["main", "develop"] | |
paths: | |
- "xbf_rs/**" | |
pull_request: | |
branches: ["main"] | |
paths: | |
- "xbf_rs/**" | |
schedule: | |
- cron: "00 18 * * *" | |
workflow_dispatch: | |
inputs: | |
reason: | |
required: false | |
description: Reason for triggering this workflow | |
type: string | |
jobs: | |
sanity-checks: | |
name: Sanity checks (check, clippy) as expected on ${{ matrix.os }} | |
needs: [debug-tests, release-tests] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
defaults: | |
run: | |
working-directory: ${{ env.SRC_DIR }} | |
# Sanity Checks | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check | |
run: cargo check --verbose | |
- name: Clippy | |
run: cargo clippy -- -D warnings | |
debug-tests: | |
name: Regular build and test (debug) on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
defaults: | |
run: | |
working-directory: ${{ env.SRC_DIR }} | |
# Test in debug mode | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build | |
run: cargo build --verbose | |
- name: Run tests | |
run: cargo test --verbose | |
release-tests: | |
name: Regular build and test (release) on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
defaults: | |
run: | |
working-directory: ${{ env.SRC_DIR }} | |
# Test in release mode | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build | |
run: cargo build --verbose -r | |
- name: Run tests | |
run: cargo test --verbose -r | |
hygiene-checks: | |
name: Hygiene checks (audit, coverage, formatting) on ${{ matrix.os }} | |
needs: [release-tests, debug-tests, nightly-checks] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
defaults: | |
run: | |
working-directory: ${{ env.SRC_DIR }} | |
# Extras | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Rust Cache | |
uses: Swatinem/[email protected] | |
- name: Setup | |
run: cargo install cargo-audit cargo-tarpaulin # and install dependencies | |
- name: Audit | |
run: cargo audit -D warnings | |
- name: Coverage | |
run: cargo tarpaulin --ignore-tests --run-types AllTargets Tests Benchmarks Bins Lib --fail-under 90 --coveralls ${{ secrets.COVERALLS_REPO_TOKEN }} | |
- name: Format | |
run: cargo fmt -- --check | |
nightly-checks: | |
name: Nightly checks (build, test, Miri) on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
defaults: | |
run: | |
working-directory: ${{ env.SRC_DIR }} | |
# Extras | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install nightly and Miri | |
run: | | |
rustup toolchain install nightly --component miri | |
rustup override set nightly | |
- name: Build (release) | |
run: cargo build --verbose -r | |
- name: Run tests (release) | |
run: cargo test --verbose -r | |
- name: Clean previous | |
run: cargo clean | |
- name: Build (debug) | |
run: cargo build --verbose | |
- name: Run tests (debug) | |
run: cargo test --verbose | |
- name: Clean previous for Miri | |
run: | | |
cargo clean | |
cargo miri setup | |
- name: Run Miri | |
run: cargo miri test |