|
| 1 | +name: Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, ready_for_review] |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + pull-requests: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint: |
| 16 | + name: Rustfmt + Clippy |
| 17 | + runs-on: ubuntu-latest |
| 18 | + # Skip for draft PRs, run for pushes and non-draft PRs |
| 19 | + if: github.event.pull_request.draft == false || github.event_name != 'pull_request' |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 1 |
| 25 | + |
| 26 | + - name: Install Rust (stable) with components |
| 27 | + uses: dtolnay/rust-toolchain@stable |
| 28 | + with: |
| 29 | + components: clippy, rustfmt |
| 30 | + |
| 31 | + - name: Cache cargo registry and build |
| 32 | + uses: Swatinem/rust-cache@v2 |
| 33 | + |
| 34 | + - name: rustfmt check |
| 35 | + run: cargo fmt --all -- --check |
| 36 | + |
| 37 | + - name: clippy (deny warnings) |
| 38 | + run: | |
| 39 | + cargo clippy --all-targets --all-features -- --deny warnings |
| 40 | +
|
| 41 | + build: |
| 42 | + name: Cargo Build |
| 43 | + runs-on: ubuntu-latest |
| 44 | + needs: lint |
| 45 | + steps: |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + fetch-depth: 1 |
| 50 | + |
| 51 | + - name: Install Rust (stable) |
| 52 | + uses: dtolnay/rust-toolchain@stable |
| 53 | + |
| 54 | + - name: Cache cargo registry and build |
| 55 | + uses: Swatinem/rust-cache@v2 |
| 56 | + |
| 57 | + - name: Build |
| 58 | + run: | |
| 59 | + set -e |
| 60 | + cargo build --workspace --all-targets --verbose |
| 61 | +
|
| 62 | + test: |
| 63 | + name: Cargo Test |
| 64 | + runs-on: ubuntu-latest |
| 65 | + needs: build |
| 66 | + steps: |
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@v4 |
| 69 | + with: |
| 70 | + fetch-depth: 1 |
| 71 | + |
| 72 | + - name: Install Rust (stable) |
| 73 | + uses: dtolnay/rust-toolchain@stable |
| 74 | + |
| 75 | + - name: Cache cargo registry and build |
| 76 | + uses: Swatinem/rust-cache@v2 |
| 77 | + |
| 78 | + - name: Run tests |
| 79 | + run: | |
| 80 | + set -e |
| 81 | + cargo test --workspace --all-features --verbose |
0 commit comments