-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (62 loc) · 1.95 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
# .github/workflows/ci.yml
name: Rust CI for rust-cli-tools
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: [stable, beta, nightly]
steps:
# 1. Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
# 2. Set up Rust toolchain
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
override: true
components: rustfmt, clippy
target: x86_64-unknown-linux-gnu # Corrected input parameter
# 3. Cache Cargo registry
- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
# 4. Cache Cargo build
- name: Cache Cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
# 5. Install Dependencies
- name: Install dependencies
run: cargo fetch
# 6. Format Check
- name: Check formatting
run: cargo fmt --all -- --check
# 7. Linting with Clippy
- name: Run Clippy
run: cargo clippy --workspace -- -D warnings
# 8. Build the workspace
- name: Build
run: cargo build --workspace --verbose
# 9. Run Tests
- name: Run tests
run: cargo test --workspace --verbose
# 10. Optional: Security Audit
- name: Install cargo audit
run: cargo install cargo-audit
- name: Run cargo audit
if: matrix.rust-version == 'stable' # Run only on stable to avoid issues with nightly
run: cargo audit