Optimize GitHub Actions workflows #433
Workflow file for this run
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
on: [push, pull_request] | |
name: CI tests | |
jobs: | |
build: | |
name: Build project | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
id: setup_rust | |
with: | |
components: "rustfmt, clippy" | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: "cargo-base-${{ steps.setup_rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}" | |
restore-keys: | | |
cargo-base-${{ steps.setup_rust.outputs.cachekey }} | |
- run: cargo build | |
lint: | |
name: Run lints | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
id: setup_rust | |
with: | |
components: "rustfmt, clippy" | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: "cargo-lint-${{ steps.setup_rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}" | |
restore-keys: | | |
cargo-lint-${{ steps.setup_rust.outputs.cachekey }} | |
cargo-base-${{ steps.setup_rust.outputs.cachekey }} | |
- run: cargo fmt --all -- --check | |
- run: cargo check | |
- run: cargo clippy -- -D warnings | |
test-linux: | |
name: Test on Linux | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
id: setup_rust | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: "cargo-test-${{ steps.setup_rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}" | |
restore-keys: | | |
cargo-test-${{ steps.setup_rust.outputs.cachekey }} | |
cargo-base-${{ steps.setup_rust.outputs.cachekey }} | |
- run: cargo test | |
test-windows: | |
name: Test on Windows | |
runs-on: windows-latest | |
needs: build | |
steps: | |
- run: git config --system core.autocrlf false && git config --system core.eol lf | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
id: setup_rust | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: "cargo-windows-${{ steps.setup_rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}" | |
restore-keys: | | |
cargo-windows-${{ steps.setup_rust.outputs.cachekey }} | |
cargo-base-${{ steps.setup_rust.outputs.cachekey }} | |
- run: cargo test | |
coverage: | |
name: Code coverage | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
id: setup_rust | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: "cargo-coverage-${{ steps.setup_rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}" | |
restore-keys: | | |
cargo-coverage-${{ steps.setup_rust.outputs.cachekey }} | |
cargo-base-${{ steps.setup_rust.outputs.cachekey }} | |
- uses: actions-rs/[email protected] | |
with: | |
# Constrained by https://github.com/actions-rs/tarpaulin/pull/23 | |
version: "0.22.0" | |
args: "--ignore-tests" | |
out-type: "Html" | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: tarpaulin-report | |
path: tarpaulin-report.html |