88 lines
1.7 KiB
YAML
88 lines
1.7 KiB
YAML
name: Rust
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_VERSION: "1.86"
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- &udev-install
|
|
name: Install libudev development package
|
|
run: sudo apt-get update && sudo apt-get install -y libudev-dev
|
|
|
|
- &checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- &setup-rust
|
|
name: Install Rust toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: ${{ env.RUST_VERSION }}
|
|
profile: minimal
|
|
override: true
|
|
components: rustfmt
|
|
|
|
- &cargo-cache
|
|
name: Cache Rust dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/bin/
|
|
~/.cargo/registry/index/
|
|
~/.cargo/registry/cache/
|
|
~/.cargo/git/db/
|
|
target/
|
|
key: ${{ runner.os }}-${{ env.RUST_VERSION }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ env.RUST_VERSION }}-cargo-
|
|
|
|
- name: Build
|
|
env:
|
|
RUSTFLAGS: "-D warnings"
|
|
run: cargo build --verbose
|
|
|
|
format:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- *checkout
|
|
- *setup-rust
|
|
|
|
- name: Format
|
|
run: cargo fmt --check --verbose
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- *udev-install
|
|
- *checkout
|
|
- *setup-rust
|
|
- *cargo-cache
|
|
|
|
- name: Run tests
|
|
run: cargo test --verbose
|
|
|
|
mock:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- *udev-install
|
|
- *checkout
|
|
- *setup-rust
|
|
- *cargo-cache
|
|
|
|
- name: Mock Machine
|
|
run: cargo build --features "development-build,mock-machine"
|