|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + release: |
| 9 | + types: [created] |
| 10 | +env: |
| 11 | + CARGO_TERM_COLOR: always |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + name: Test (all feature combinations) |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + rust: |
| 20 | + - stable |
| 21 | + - beta |
| 22 | + - nightly |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v5 |
| 26 | + |
| 27 | + - name: Install Rust |
| 28 | + uses: dtolnay/rust-toolchain@master |
| 29 | + with: |
| 30 | + toolchain: ${{ matrix.rust }} |
| 31 | + |
| 32 | + - name: Install cargo-hack |
| 33 | + run: cargo install cargo-hack |
| 34 | + |
| 35 | + - name: Cache dependencies |
| 36 | + uses: actions/cache@v4 |
| 37 | + with: |
| 38 | + path: | |
| 39 | + ~/.cargo/registry |
| 40 | + ~/.cargo/git |
| 41 | + target |
| 42 | + key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} |
| 43 | + |
| 44 | + - name: Run tests with all feature combinations |
| 45 | + run: cargo hack test --feature-powerset |
| 46 | + |
| 47 | + test-embedded: |
| 48 | + name: Test embedded targets |
| 49 | + runs-on: ubuntu-latest |
| 50 | + strategy: |
| 51 | + matrix: |
| 52 | + target: |
| 53 | + - thumbv7em-none-eabi |
| 54 | + - thumbv7m-none-eabi |
| 55 | + - riscv32imac-unknown-none-elf |
| 56 | + |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v5 |
| 59 | + |
| 60 | + - name: Install Rust |
| 61 | + uses: dtolnay/rust-toolchain@stable |
| 62 | + with: |
| 63 | + targets: ${{ matrix.target }} |
| 64 | + |
| 65 | + - name: Cache dependencies |
| 66 | + uses: actions/cache@v4 |
| 67 | + with: |
| 68 | + path: | |
| 69 | + ~/.cargo/registry |
| 70 | + ~/.cargo/git |
| 71 | + target |
| 72 | + key: ${{ runner.os }}-cargo-nostd-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} |
| 73 | + |
| 74 | + - name: Build (no_std) |
| 75 | + run: cargo build --target ${{ matrix.target }} --no-default-features |
| 76 | + |
| 77 | + - name: Build (no_std + alloc) |
| 78 | + run: cargo build --target ${{ matrix.target }} --no-default-features --features alloc |
| 79 | + |
| 80 | + clippy: |
| 81 | + name: Clippy |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v5 |
| 85 | + |
| 86 | + - name: Install Rust |
| 87 | + uses: dtolnay/rust-toolchain@stable |
| 88 | + with: |
| 89 | + components: clippy |
| 90 | + |
| 91 | + - name: Install cargo-hack |
| 92 | + run: cargo install cargo-hack |
| 93 | + |
| 94 | + - name: Cache dependencies |
| 95 | + uses: actions/cache@v4 |
| 96 | + with: |
| 97 | + path: | |
| 98 | + ~/.cargo/registry |
| 99 | + ~/.cargo/git |
| 100 | + target |
| 101 | + key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }} |
| 102 | + |
| 103 | + - name: Run clippy with all feature combinations |
| 104 | + run: cargo hack clippy --feature-powerset -- -D warnings |
| 105 | + |
| 106 | + fmt: |
| 107 | + name: Rustfmt |
| 108 | + runs-on: ubuntu-latest |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v5 |
| 111 | + |
| 112 | + - name: Install Rust |
| 113 | + uses: dtolnay/rust-toolchain@stable |
| 114 | + with: |
| 115 | + components: rustfmt |
| 116 | + |
| 117 | + - name: Run rustfmt |
| 118 | + run: cargo fmt --all -- --check |
| 119 | + |
| 120 | + docs: |
| 121 | + name: Docs |
| 122 | + runs-on: ubuntu-latest |
| 123 | + steps: |
| 124 | + - uses: actions/checkout@v5 |
| 125 | + |
| 126 | + - name: Install Rust |
| 127 | + uses: dtolnay/rust-toolchain@stable |
| 128 | + |
| 129 | + - name: Install cargo-hack |
| 130 | + run: cargo install cargo-hack |
| 131 | + |
| 132 | + - name: Cache dependencies |
| 133 | + uses: actions/cache@v4 |
| 134 | + with: |
| 135 | + path: | |
| 136 | + ~/.cargo/registry |
| 137 | + ~/.cargo/git |
| 138 | + target |
| 139 | + key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }} |
| 140 | + |
| 141 | + - name: Check documentation with all feature combinations |
| 142 | + run: cargo hack doc --feature-powerset --no-deps --document-private-items |
| 143 | + env: |
| 144 | + RUSTDOCFLAGS: -D warnings |
| 145 | + |
| 146 | + msrv: |
| 147 | + name: MSRV |
| 148 | + runs-on: ubuntu-latest |
| 149 | + steps: |
| 150 | + - uses: actions/checkout@v5 |
| 151 | + |
| 152 | + - name: Install Rust 1.66 |
| 153 | + |
| 154 | + |
| 155 | + - name: Cache dependencies |
| 156 | + uses: actions/cache@v4 |
| 157 | + with: |
| 158 | + path: | |
| 159 | + ~/.cargo/registry |
| 160 | + ~/.cargo/git |
| 161 | + target |
| 162 | + key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.lock') }} |
| 163 | + |
| 164 | + - name: Check MSRV |
| 165 | + run: cargo check --no-default-features |
| 166 | + |
| 167 | + - name: Check MSRV (with alloc) |
| 168 | + run: cargo check --no-default-features --features alloc |
| 169 | + |
| 170 | + coverage: |
| 171 | + name: Coverage |
| 172 | + runs-on: ubuntu-latest |
| 173 | + steps: |
| 174 | + - uses: actions/checkout@v5 |
| 175 | + |
| 176 | + - name: Install Rust |
| 177 | + uses: dtolnay/rust-toolchain@stable |
| 178 | + |
| 179 | + - name: Install cargo-tarpaulin |
| 180 | + run: cargo install cargo-tarpaulin |
| 181 | + |
| 182 | + - name: Cache dependencies |
| 183 | + uses: actions/cache@v4 |
| 184 | + with: |
| 185 | + path: | |
| 186 | + ~/.cargo/registry |
| 187 | + ~/.cargo/git |
| 188 | + target |
| 189 | + key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }} |
| 190 | + |
| 191 | + - name: Generate coverage report |
| 192 | + run: | |
| 193 | + cargo tarpaulin --verbose --features std --workspace --timeout 120 --out xml |
| 194 | +
|
| 195 | + - name: Upload coverage to Codecov |
| 196 | + uses: codecov/codecov-action@v5 |
| 197 | + with: |
| 198 | + fail_ci_if_error: false |
| 199 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 200 | + |
| 201 | + publish: |
| 202 | + name: Publish to crates.io |
| 203 | + runs-on: ubuntu-latest |
| 204 | + if: github.event_name == 'release' |
| 205 | + needs: [test, test-embedded, clippy, fmt, docs, msrv] |
| 206 | + steps: |
| 207 | + - uses: actions/checkout@v5 |
| 208 | + |
| 209 | + - name: Install Rust |
| 210 | + uses: dtolnay/rust-toolchain@stable |
| 211 | + |
| 212 | + - name: Publish to crates.io |
| 213 | + run: cargo publish |
| 214 | + env: |
| 215 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }} |
0 commit comments