|
1 | | -name: Build & Test Draco |
| 1 | +name: Rust CI/CD Pipeline |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
| 5 | + pull_request: |
| 6 | + types: [opened, reopened] |
| 7 | + |
| 8 | +env: |
| 9 | + RUST_BACKTRACE: 1 |
5 | 10 |
|
6 | 11 | jobs: |
7 | | - draco: |
| 12 | + # Job 1: Format Check |
| 13 | + format: |
| 14 | + name: Format Check |
8 | 15 | runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v5 |
| 19 | + |
| 20 | + - name: Install Rust toolchain |
| 21 | + uses: dtolnay/rust-toolchain@stable |
| 22 | + with: |
| 23 | + components: rustfmt |
9 | 24 |
|
10 | | - defaults: |
11 | | - run: |
12 | | - shell: bash |
| 25 | + - name: Check formatting |
| 26 | + run: cargo fmt --all -- --check |
13 | 27 |
|
| 28 | + # Job 2: Lint Check |
| 29 | + lint: |
| 30 | + name: Lint Check |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - name: Checkout code |
| 34 | + uses: actions/checkout@v5 |
| 35 | + |
| 36 | + - name: Install Rust toolchain |
| 37 | + uses: dtolnay/rust-toolchain@stable |
| 38 | + with: |
| 39 | + components: clippy |
| 40 | + |
| 41 | + - name: Cache cargo registry |
| 42 | + uses: actions/cache@v4 |
| 43 | + with: |
| 44 | + path: | |
| 45 | + ~/.cargo/registry |
| 46 | + ~/.cargo/git |
| 47 | + target |
| 48 | + key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-cargo- |
| 51 | +
|
| 52 | + - name: Run clippy |
| 53 | + run: cargo clippy --all-targets --all-features |
| 54 | + |
| 55 | + # Job 3: Build |
| 56 | + build: |
| 57 | + name: Build |
| 58 | + needs: [ lint, format ] |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - name: Checkout code |
| 62 | + uses: actions/checkout@v5 |
| 63 | + |
| 64 | + - name: Install Rust toolchain |
| 65 | + uses: dtolnay/rust-toolchain@stable |
| 66 | + |
| 67 | + - name: Cache cargo registry |
| 68 | + uses: actions/cache@v4 |
| 69 | + with: |
| 70 | + path: | |
| 71 | + ~/.cargo/registry |
| 72 | + ~/.cargo/git |
| 73 | + target |
| 74 | + key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} |
| 75 | + restore-keys: | |
| 76 | + ${{ runner.os }}-cargo- |
| 77 | +
|
| 78 | + - name: Build project |
| 79 | + run: cargo build --verbose --all-features |
| 80 | + |
| 81 | + test: |
| 82 | + name: Test |
| 83 | + needs: build |
| 84 | + runs-on: ubuntu-latest |
14 | 85 | steps: |
15 | | - - uses: actions/checkout@v5 |
16 | | - - name: Setup rust |
17 | | - run: rustup update --no-self-update stable |
18 | | - - name: Build crate |
19 | | - run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo build |
20 | | - env: |
21 | | - RUST_BACKTRACE: 'full' |
22 | 86 | - name: Run Tests |
23 | | - run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo test |
| 87 | + run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo test |
24 | 88 | env: |
25 | 89 | RUST_BACKTRACE: 'full' |
0 commit comments