-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (131 loc) · 3.9 KB
/
ci.yaml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# This CI workflow ensures that the project is built, tested, analyzed, and
# documented across the supported Rust toolchains, enhancing the reliability and
# quality of the codebase.
#
# The workflow is triggered by:
# - Pushes to the 'main' branch.
# - Pull requests targeting the 'main' branch.
# - Manual dispatch.
#
# The workflow consists of four jobs:
#
# 1. **Build**:
# - Uses a matrix to test against multiple Rust toolchains (1.65.0, stable, beta, nightly).
# - Builds the project in release mode.
# - Builds an example located in 'examples/read-decibel-value'.
#
# 2. **Unit Tests**:
# - Uses a matrix to test against multiple Rust toolchains (1.65.0, stable, beta, nightly).
# - Runs the unit tests.
# - If the nightly toolchain is used, installs Miri and runs unit tests through Miri for undefined behavior detection.
#
# 3. **Analysis**:
# - Runs Clippy for linting, allowing all lints.
# - Runs rustfmt to check code formatting.
#
# 4. **Docs**:
# - Generates the documentation using rustdoc.
# - Uploads the generated documentation as an artifact named 'docs'.
#
name: CI
run-name: CI build initiated by ${{ github.actor }}
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.65.0, stable, beta, nightly]
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Install target needed
run: |
rustup target add thumbv7em-none-eabihf
- name: Build driver (release)
run: |
cargo build --release
- name: Build example
run: |
cargo build
working-directory: examples/read-decibel-value
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.65.0, stable, beta, nightly]
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Install target needed
run: |
rustup target add thumbv7em-none-eabihf
- name: Run unit tests
run: |
cargo test
- name: Install Miri
if: matrix.rust == 'nightly'
run: |
rustup toolchain install nightly --component miri
- name: Run unit tests through Miri undefined behavior detection
if: matrix.rust == 'nightly'
run: |
cargo miri test
analysis:
name: Analysis
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.65.0, stable, beta, nightly]
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Install target needed
run: |
rustup target add thumbv7em-none-eabihf
- name: Install Clippy
run: |
rustup component add clippy --toolchain ${{ matrix.rust }}
- name: Install Rustfmt
run: |
rustup component add rustfmt --toolchain ${{ matrix.rust }}
- name: Run clippy
run: |
cargo clippy -- -D warnings
- name: Format
run: |
cargo fmt --all -- --check
docs:
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install target needed
run: |
rustup target add thumbv7em-none-eabihf
- name: Run rustdoc
run: |
cargo doc
- uses: actions/upload-artifact@v4
with:
name: docs
path: target/doc/pcb_artists_spl