Skip to content

Commit 08effea

Browse files
committed
ci: add GitHub Actions workflows
- Add basic CI workflow (test, build, lint) - Add code coverage workflow with Codecov - Configure Rust toolchain and caching
1 parent a11aa5d commit 08effea

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: rustfmt, clippy
23+
24+
- name: Cache dependencies
25+
uses: Swatinem/rust-cache@v2
26+
27+
- name: Check formatting
28+
run: cargo fmt -- --check
29+
30+
- name: Clippy
31+
run: cargo clippy -- -D warnings
32+
33+
- name: Run tests
34+
run: cargo test --verbose
35+
36+
build:
37+
name: Build
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Install Rust
43+
uses: dtolnay/rust-toolchain@stable
44+
45+
- name: Cache dependencies
46+
uses: Swatinem/rust-cache@v2
47+
48+
- name: Build
49+
run: cargo build --verbose
50+
51+
- name: Build (release)
52+
run: cargo build --verbose --release

.github/workflows/coverage.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Code Coverage
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
coverage:
11+
name: Code Coverage
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install Rust
17+
uses: dtolnay/rust-toolchain@stable
18+
with:
19+
components: llvm-tools-preview
20+
21+
- name: Install cargo-llvm-cov
22+
run: cargo install cargo-llvm-cov
23+
24+
- name: Generate code coverage
25+
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
26+
27+
- name: Upload coverage to Codecov
28+
uses: codecov/codecov-action@v3
29+
with:
30+
file: ./lcov.info
31+
fail_ci_if_error: true

0 commit comments

Comments
 (0)