Skip to content

Commit 1be6994

Browse files
committed
ci: set up GitHub Actions for CI
- Add CI workflow for running clippy, formatting, docs, and tests
1 parent 08740f2 commit 1be6994

File tree

3 files changed

+127
-51
lines changed

3 files changed

+127
-51
lines changed

.github/workflows/ci.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: CI
2+
3+
on: [pull_request, push]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
RUSTFLAGS: --deny warnings
8+
RUSTDOCFLAGS: --deny warnings
9+
10+
jobs:
11+
clippy:
12+
name: Clippy
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Cache Cargo artifacts
20+
uses: actions/cache@v4
21+
with:
22+
path: |
23+
~/.cargo/bin/
24+
~/.cargo/registry/index/
25+
~/.cargo/registry/cache/
26+
~/.cargo/git/db/
27+
target/
28+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
29+
30+
- name: Install Rust toolchain
31+
uses: dtolnay/rust-toolchain@stable
32+
33+
- name: Install alsa and udev
34+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
35+
36+
- name: Run clippy lints
37+
run: cargo clippy --locked --workspace --all-targets --all-features -- --deny warnings
38+
39+
format:
40+
name: Format
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v4
46+
47+
- name: Cache Cargo artifacts
48+
uses: actions/cache@v4
49+
with:
50+
path: |
51+
~/.cargo/bin/
52+
~/.cargo/registry/index/
53+
~/.cargo/registry/cache/
54+
~/.cargo/git/db/
55+
target/
56+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
57+
58+
- name: Install Rust toolchain
59+
uses: dtolnay/rust-toolchain@stable
60+
with:
61+
components: rustfmt
62+
63+
- name: Run cargo fmt
64+
run: cargo fmt --all -- --check
65+
66+
doc:
67+
name: Docs
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Checkout repository
71+
uses: actions/checkout@v4
72+
73+
- name: Cache Cargo artifacts
74+
uses: actions/cache@v4
75+
with:
76+
path: |
77+
~/.cargo/bin/
78+
~/.cargo/registry/index/
79+
~/.cargo/registry/cache/
80+
~/.cargo/git/db/
81+
target/
82+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
83+
84+
- name: Install Rust toolchain
85+
uses: dtolnay/rust-toolchain@stable
86+
87+
- name: Install alsa and udev
88+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
89+
90+
- name: Check documentation
91+
run: cargo doc --locked --workspace --all-features --document-private-items --no-deps
92+
93+
test:
94+
name: Tests
95+
runs-on: ubuntu-latest
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@v4
99+
100+
- name: Cache Cargo artifacts
101+
uses: actions/cache@v4
102+
with:
103+
path: |
104+
~/.cargo/bin/
105+
~/.cargo/registry/index/
106+
~/.cargo/registry/cache/
107+
~/.cargo/git/db/
108+
target/
109+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
110+
111+
- name: Install Rust toolchain
112+
uses: dtolnay/rust-toolchain@stable
113+
114+
- name: Install alsa and udev
115+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
116+
117+
- name: Test
118+
run: cargo test --release -- --test-threads 2
119+
120+
- name: Generate code coverage
121+
run: cargo llvm-cov --all-features --no-cfg-coverage --workspace --lcov --output-path lcov.info
122+
123+
- name: Upload coverage to Codecov
124+
uses: codecov/codecov-action@v4
125+
with:
126+
token: ${{ secrets.CODECOV_TOKEN }}
127+
files: lcov.info

.github/workflows/test.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ mod tests {
1010
#[cfg(not(debug_assertions))]
1111
use std::fs;
1212

13-
#[expect(dead_code)]
1413
fn solve<R: RangeBounds<usize> + IntoIterator<Item = usize>>(
1514
levels: &[Level],
1615
range: R,

0 commit comments

Comments
 (0)