|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ trunk, main ] |
| 6 | + paths: |
| 7 | + - 'src/**' |
| 8 | + - 'examples/**' |
| 9 | + - 'Cargo.toml' |
| 10 | + - 'Cargo.lock' |
| 11 | + - '.github/workflows/ci.yml' |
| 12 | + pull_request: |
| 13 | + branches: [ trunk, main ] |
| 14 | + paths: |
| 15 | + - 'src/**' |
| 16 | + - 'examples/**' |
| 17 | + - 'Cargo.toml' |
| 18 | + - 'Cargo.lock' |
| 19 | + - '.github/workflows/ci.yml' |
| 20 | + |
| 21 | +env: |
| 22 | + CARGO_TERM_COLOR: always |
| 23 | + |
| 24 | +jobs: |
| 25 | + test: |
| 26 | + name: Test |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 31 | + rust: [stable, beta] |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Install Rust |
| 36 | + uses: dtolnay/rust-toolchain@master |
| 37 | + with: |
| 38 | + toolchain: ${{ matrix.rust }} |
| 39 | + |
| 40 | + - name: Cache cargo registry |
| 41 | + uses: actions/cache@v4 |
| 42 | + with: |
| 43 | + path: ~/.cargo/registry |
| 44 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 45 | + |
| 46 | + - name: Cache cargo index |
| 47 | + uses: actions/cache@v4 |
| 48 | + with: |
| 49 | + path: ~/.cargo/git |
| 50 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 51 | + |
| 52 | + - name: Cache cargo build |
| 53 | + uses: actions/cache@v4 |
| 54 | + with: |
| 55 | + path: target |
| 56 | + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} |
| 57 | + |
| 58 | + - name: Run tests |
| 59 | + run: cargo test --verbose |
| 60 | + |
| 61 | + - name: Run doc tests |
| 62 | + run: cargo test --doc --verbose |
| 63 | + |
| 64 | + fmt: |
| 65 | + name: Rustfmt |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Install Rust |
| 71 | + uses: dtolnay/rust-toolchain@stable |
| 72 | + with: |
| 73 | + components: rustfmt |
| 74 | + |
| 75 | + - name: Check formatting |
| 76 | + run: cargo fmt --all -- --check |
| 77 | + |
| 78 | + clippy: |
| 79 | + name: Clippy |
| 80 | + runs-on: ubuntu-latest |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Install Rust |
| 85 | + uses: dtolnay/rust-toolchain@stable |
| 86 | + with: |
| 87 | + components: clippy |
| 88 | + |
| 89 | + - name: Run clippy |
| 90 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 91 | + |
| 92 | + examples: |
| 93 | + name: Examples |
| 94 | + runs-on: ubuntu-latest |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@v4 |
| 97 | + |
| 98 | + - name: Install Rust |
| 99 | + uses: dtolnay/rust-toolchain@stable |
| 100 | + |
| 101 | + - name: Check examples |
| 102 | + run: cargo check --examples |
| 103 | + |
| 104 | + - name: Build examples |
| 105 | + run: cargo build --examples |
| 106 | + |
| 107 | + - name: Run enemy example |
| 108 | + run: cargo run --example enemy_example |
| 109 | + |
| 110 | + coverage: |
| 111 | + name: Code Coverage |
| 112 | + runs-on: ubuntu-latest |
| 113 | + steps: |
| 114 | + - uses: actions/checkout@v4 |
| 115 | + |
| 116 | + - name: Install Rust |
| 117 | + uses: dtolnay/rust-toolchain@stable |
| 118 | + |
| 119 | + - name: Install cargo-tarpaulin |
| 120 | + run: cargo install cargo-tarpaulin |
| 121 | + |
| 122 | + - name: Generate coverage |
| 123 | + run: cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out xml |
| 124 | + |
| 125 | + - name: Upload coverage to Codecov |
| 126 | + uses: codecov/codecov-action@v4 |
| 127 | + with: |
| 128 | + files: ./cobertura.xml |
| 129 | + fail_ci_if_error: false |
| 130 | + |
| 131 | + msrv: |
| 132 | + name: Minimum Supported Rust Version |
| 133 | + runs-on: ubuntu-latest |
| 134 | + steps: |
| 135 | + - uses: actions/checkout@v4 |
| 136 | + |
| 137 | + - name: Install Rust 1.85.0 |
| 138 | + uses: dtolnay/rust-toolchain@master |
| 139 | + with: |
| 140 | + toolchain: "1.85.0" |
| 141 | + |
| 142 | + - name: Check with MSRV |
| 143 | + run: cargo check --all-features |
| 144 | + |
| 145 | + wasm: |
| 146 | + name: WebAssembly |
| 147 | + runs-on: ubuntu-latest |
| 148 | + steps: |
| 149 | + - uses: actions/checkout@v4 |
| 150 | + |
| 151 | + - name: Install Rust |
| 152 | + uses: dtolnay/rust-toolchain@stable |
| 153 | + with: |
| 154 | + targets: wasm32-unknown-unknown |
| 155 | + |
| 156 | + - name: Check wasm32-unknown-unknown |
| 157 | + run: cargo check --target wasm32-unknown-unknown --lib |
| 158 | + |
| 159 | + - name: Build wasm32-unknown-unknown |
| 160 | + run: cargo build --target wasm32-unknown-unknown --lib --release |
0 commit comments