Skip to content

Commit 43da087

Browse files
committed
update CI workflow
1 parent 6dd2255 commit 43da087

File tree

1 file changed

+49
-19
lines changed

1 file changed

+49
-19
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,60 @@
1-
# .github/workflows/ci.yml
2-
3-
name: CI
1+
# This is the name of the workflow that will be displayed on GitHub
2+
name: Rust CI
43

4+
# This section defines when the workflow will run.
5+
# It will trigger on any `push` to any branch, and on any `pull_request`.
56
on:
67
push:
7-
branches: [ main ]
8+
branches: [ "main" ]
89
pull_request:
9-
branches: [ main ]
10+
branches: [ "main" ]
11+
12+
# This defines the environment for the workflow. We set Cargo to use color output.
13+
env:
14+
CARGO_TERM_COLOR: always
1015

16+
# This section defines the jobs to be run. We have one job called "build".
1117
jobs:
12-
build_and_test:
13-
name: Rust Project
14-
runs-on: ubuntu-latest
18+
build:
19+
# The name that will be displayed for this job on GitHub
20+
name: Test on ${{ matrix.os }}
21+
22+
# This job will run on multiple operating systems to ensure cross-platform compatibility
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
matrix:
26+
os: [ubuntu-latest, macos-latest, windows-latest]
27+
28+
# These are the individual steps the job will execute in order
1529
steps:
16-
- uses: actions/checkout@v4
30+
# 1. Check out the repository code so the workflow can access it
31+
- uses: actions/checkout@v4
32+
33+
# 2. Cache the cargo directories to speed up future builds
34+
- name: Cache cargo dependencies
35+
uses: actions/cache@v4
36+
with:
37+
path: |
38+
~/.cargo/bin/
39+
~/.cargo/registry/index/
40+
~/.cargo/registry/cache/
41+
~/.cargo/git/db/
42+
target/
43+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
1744

18-
- name: Install Rust toolchain
19-
uses: dtolnay/rust-toolchain@stable
20-
with:
21-
components: rustfmt
45+
# 3. Check that the code is formatted correctly
46+
- name: Check formatting
47+
run: cargo fmt -- --check
2248

23-
- name: Check formatting
24-
run: cargo fmt -- --check
49+
# 4. Run Clippy to check for common mistakes and enforce idiomatic Rust
50+
# The `-D warnings` flag treats all warnings as errors, failing the build.
51+
- name: Run Clippy
52+
run: cargo clippy -- -D warnings
2553

26-
- name: Run Clippy
27-
run: cargo clippy -- -D warnings
54+
# 5. Run the tests (if any are defined)
55+
- name: Run tests
56+
run: cargo test --verbose
2857

29-
- name: Run tests
30-
run: cargo test
58+
# 6. Build the project in release mode to ensure it compiles
59+
- name: Build
60+
run: cargo build --release --verbose

0 commit comments

Comments
 (0)