|
1 | | -name: CI/CD Pipeline |
| 1 | +name: Rust CI/CD |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + paths: |
| 7 | + - 'src/**' |
| 8 | + - 'crates/**' |
| 9 | + - 'Cargo.toml' |
| 10 | + - 'Cargo.lock' |
| 11 | + - '.github/workflows/ci.yml' |
| 12 | + pull_request: |
| 13 | + branches: [main, develop] |
| 14 | + paths: |
| 15 | + - 'src/**' |
| 16 | + - 'crates/**' |
| 17 | + - 'Cargo.toml' |
| 18 | + - 'Cargo.lock' |
4 | 19 | workflow_dispatch: |
5 | 20 |
|
6 | 21 | jobs: |
7 | | - build: |
8 | | - name: Build & Test |
| 22 | + test: |
| 23 | + name: Test & Lint |
9 | 24 | runs-on: ${{ matrix.os }} |
10 | 25 | strategy: |
11 | 26 | matrix: |
12 | 27 | os: [ubuntu-latest, windows-latest, macos-latest] |
13 | 28 |
|
14 | 29 | steps: |
15 | | - - uses: actions/checkout@v3 |
| 30 | + - uses: actions/checkout@v4 |
16 | 31 |
|
17 | 32 | - name: Setup Rust |
18 | | - uses: actions-rs/toolchain@v1 |
| 33 | + uses: dtolnay/rust-toolchain@stable |
19 | 34 | with: |
20 | | - toolchain: stable |
21 | | - override: true |
22 | | - |
23 | | - - name: Setup Python |
24 | | - uses: actions/setup-python@v4 |
25 | | - with: |
26 | | - python-version: '3.11' |
| 35 | + components: rustfmt, clippy |
27 | 36 |
|
28 | 37 | - name: Cache cargo |
29 | | - uses: actions/cache@v3 |
| 38 | + uses: Swatinem/rust-cache@v2 |
30 | 39 | with: |
31 | | - path: ~/.cargo |
32 | | - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 40 | + workspaces: '.' |
33 | 41 |
|
34 | | - - name: Build Rust |
35 | | - run: cargo build --verbose --release |
| 42 | + - name: Build |
| 43 | + run: cargo build --verbose |
36 | 44 |
|
37 | 45 | - name: Run tests |
38 | 46 | run: cargo test --verbose |
39 | 47 |
|
40 | | - - name: Lint Rust |
41 | | - run: cargo clippy -- -D warnings |
| 48 | + - name: Lint (clippy) |
| 49 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 50 | + |
| 51 | + - name: Format check |
| 52 | + run: cargo fmt -- --check |
| 53 | + |
| 54 | + coverage: |
| 55 | + name: Code Coverage |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Setup Rust |
| 61 | + uses: dtolnay/rust-toolchain@stable |
| 62 | + |
| 63 | + - name: Install tarpaulin |
| 64 | + run: cargo install cargo-tarpaulin |
| 65 | + |
| 66 | + - name: Generate coverage |
| 67 | + run: cargo tarpaulin --workspace --out Xml --exclude-files tests/* --timeout 300 |
| 68 | + |
| 69 | + - name: Upload coverage to Codecov |
| 70 | + uses: codecov/codecov-action@v3 |
| 71 | + with: |
| 72 | + files: ./cobertura.xml |
| 73 | + flags: rust |
| 74 | + fail_ci_if_error: false |
42 | 75 |
|
43 | 76 | security: |
44 | 77 | name: Security Audit |
45 | 78 | runs-on: ubuntu-latest |
46 | 79 | steps: |
47 | | - - uses: actions/checkout@v3 |
48 | | - - uses: rustsec/audit-check-action@v1 |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Setup Rust |
| 83 | + uses: dtolnay/rust-toolchain@stable |
| 84 | + |
| 85 | + - name: Install cargo-audit |
| 86 | + run: cargo install cargo-audit |
| 87 | + |
| 88 | + - name: Run security audit |
| 89 | + run: cargo audit |
| 90 | + |
| 91 | + release-build: |
| 92 | + name: Release Build |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - name: Setup Rust |
| 98 | + uses: dtolnay/rust-toolchain@stable |
| 99 | + |
| 100 | + - name: Cache cargo |
| 101 | + uses: Swatinem/rust-cache@v2 |
49 | 102 | with: |
50 | | - token: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + workspaces: '.' |
| 104 | + |
| 105 | + - name: Build release |
| 106 | + run: cargo build --release --verbose |
0 commit comments