name: CI tests
on: [push]
jobs:
build:
name: Build project
runs-on: ubuntu-latest
outputs:
rustc_cache_key: ${{ steps.setup_rust.outputs.cachekey }}
steps:
- run: sudo apt install libdbus-1-dev pkg-config
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: dtolnay/rust-toolchain@stable
id: setup_rust
with:
components: "rustfmt, clippy"
- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf 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-${{ env.RUSTC_CACHEKEY }}
- run: cargo build --locked --all-targets
test:
name: Run tests and linters
runs-on: ubuntu-latest
needs: build
steps:
- run: sudo apt install libdbus-1-dev pkg-config
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: "cargo-lint-${{ needs.build.outputs.rustc_cache_key }}-${{ hashFiles('**/Cargo.lock') }}"
restore-keys: |
cargo-lint-${{ env.RUSTC_CACHEKEY }}
cargo-base-${{ env.RUSTC_CACHEKEY }}
fail-on-cache-miss: true
- run: cargo fmt --all --check
- run: cargo test
- run: cargo clippy -- -D warnings
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
needs: build
env:
SKIP: "tests,clippy"
steps:
- run: sudo apt install libdbus-1-dev pkg-config
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: "cargo-lint-${{ needs.build.outputs.rustc_cache_key }}-${{ hashFiles('**/Cargo.lock') }}"
restore-keys: |
cargo-lint-${{ env.RUSTC_CACHEKEY }}
cargo-base-${{ env.RUSTC_CACHEKEY }}
fail-on-cache-miss: true
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 - name: set PYVERSION
run: echo "PYVERSION=$(python --version | tr ' ' '-')" >> $GITHUB_ENV
- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf with:
path: ~/.cache/pre-commit
key: pre-commit-${{ env.PYVERSION }}-${{ hashFiles('.pre-commit-config.yaml') }}
- run: pip install pre-commit
- run: pre-commit run --all --color=always --show-diff-on-failure