Skip to content

Cleanups

Cleanups #242

Workflow file for this run

name: Rust CI
on:
# Always test pull requests
pull_request:
# Bors related branches
push:
branches:
- master
- staging
- trying
# Test once per week: Monday at 00:00
schedule:
- cron: "0 0 * * 1"
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
jobs:
clippy_check:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"]
rust: ["stable", "nightly"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
name: clippy "No Default Features" (${{ matrix.os }} / ${{ matrix.rust }})
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --no-default-features --all-targets -- -D warnings
name: clippy "No Default Features" (${{ matrix.os }} / ${{ matrix.rust }})
- uses: actions-rs/clippy-check@v1
name: clippy "Default" (${{ matrix.os }} / ${{ matrix.rust }})
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --all-targets -- -D warnings
name: clippy "Default" (${{ matrix.os }} / ${{ matrix.rust }})
- uses: actions-rs/clippy-check@v1
name: clippy "All Features" (${{ matrix.os }} / ${{ matrix.rust }})
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --all-features --all-targets -- -D warnings
name: clippy "All Features" (${{ matrix.os }} / ${{ matrix.rust }})
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
name: Rustfmt Check (${{ matrix.rust }})
with:
command: fmt
args: --all -- --check
build_and_test:
name: Build and Test
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
# It is good to test more than the MSRV and stable since sometimes
# breakage occurs in intermediate versions.
rust: ["1.46", "1.50", "stable", "beta", "nightly"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: actions-rs/cargo@v1
name: Build (${{ matrix.os }} / ${{ matrix.rust }})
with:
command: build
args: --workspace --all-features --all-targets
- uses: actions-rs/cargo@v1
name: Test "No Default Features" (${{ matrix.os }} / ${{ matrix.rust }})
with:
command: test
# cargo test --all-targets does NOT run doctests
# since doctests are important this should not be added
# https://github.com/rust-lang/cargo/issues/6669
args: --workspace --no-default-features
- uses: actions-rs/cargo@v1
name: Test "Default" (${{ matrix.os }} / ${{ matrix.rust }})
with:
command: test
args: --workspace
- uses: actions-rs/cargo@v1
name: Test "All Features" (${{ matrix.os }} / ${{ matrix.rust }})
with:
command: test
args: --workspace --all-features
- name: Run cargo-tarpaulin
uses: actions-rs/tarpaulin@v0.1
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
with:
# tarpaulin already runs with --all-targets
args: "--workspace --all-features -- --test-threads 1"
version: "latest"
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
# Added to summarize the matrix (otherwise we would need to list every single
# job in bors.toml)
# https://forum.bors.tech/t/bors-with-github-workflows/426
tests-result:
name: Tests result
if: always()
needs:
- rustfmt
- clippy_check
- build_and_test
runs-on: ubuntu-latest
steps:
- name: Mark the job as a success
if: "needs.rustfmt.result == 'success' && needs.clippy_check.result == 'success' && needs.build_and_test.result == 'success'"
run: exit 0
- name: Mark the job as a failure
if: "!(needs.rustfmt.result == 'success' && needs.clippy_check.result == 'success' && needs.build_and_test.result == 'success')"
run: exit 1