1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: CI
on:
push:
branches:
pull_request:
branches:
env:
CARGO_TERM_COLOR: always
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v4
# Install Rust toolchain with target for embedded
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: thumbv7em-none-eabihf # ARM Cortex-M4/M7; adjust as needed
components: rustfmt, clippy
# Cache Rust dependencies
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
# Install dependencies (embedded-hal-async)
- name: Install dependencies
run: cargo add embedded-hal-async
# Check code formatting
- name: Run cargo fmt
run: cargo fmt --all -- --check
# Run Clippy for linting
- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# Build for the host (no tests since they're minimal)
- name: Build for host
run: cargo build --verbose
# Run unit tests (host, skipping doctests)
- name: Run tests
run: cargo test --no-run --verbose # Only build tests, don’t run due to doctest issues
# Build for embedded target (no_std)
- name: Build for thumbv7em-none-eabihf
run: cargo build --target thumbv7em-none-eabihf --verbose
# Check documentation generation
- name: Generate documentation
run: cargo doc --no-deps --verbose