|
| 1 | +# We use `actions-rs` for most of our actions |
| 2 | +# |
| 3 | +# This file is for the main tests. clippy & rustfmt are separate workflows |
| 4 | +on: [push, pull_request] |
| 5 | +name: Cargo Test |
| 6 | + |
| 7 | +env: |
| 8 | + CARGO_TERM_COLOR: always |
| 9 | + # has a history of occasional bugs (especially on old versions) |
| 10 | + # |
| 11 | + # the ci is free so we might as well use it ;) |
| 12 | + CARGO_INCREMENTAL: 0 |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + # Only run on PRs if the source branch is on someone else's repo |
| 19 | + if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} |
| 20 | + |
| 21 | + runs-on: ubuntu-latest |
| 22 | + strategy: |
| 23 | + fail-fast: false # Even if one job fails we still want to see the other ones |
| 24 | + matrix: |
| 25 | + rust: |
| 26 | + # Minimum Supported Rust Version |
| 27 | + # |
| 28 | + # This is hardcoded and needs to be in sync with Cargo.toml and the README |
| 29 | + # |
| 30 | + # If one of the features does not support this MSRV, |
| 31 | + # you need to remove this from the main list and manually add the desired |
| 32 | + # feature/version combinations to 'include' |
| 33 | + # This hack is not currently needed because serde-erased v0.3 supports our MSRV. |
| 34 | + - 1.63 |
| 35 | + |
| 36 | + # Intermediate Releases (between MSRV and latest stable) |
| 37 | + # Be careful not to add these needlessly; they hold up CI |
| 38 | + |
| 39 | + # The most recent version of stable rust (automatically updated) |
| 40 | + - stable |
| 41 | + - nightly |
| 42 | + # NOTE: Features to test must be specified manually. They are applied to all versions separately. |
| 43 | + features: |
| 44 | + - "std" |
| 45 | + - "std bytemuck slog serde" |
| 46 | + include: |
| 47 | + - rust: stable |
| 48 | + features: "std parking_lot" |
| 49 | + - rust: nightly |
| 50 | + features: "nightly" # no features except nightly |
| 51 | + - rust: nightly |
| 52 | + features: "nightly alloc" # no features except nightly + alloc |
| 53 | + - rust: nightly |
| 54 | + features: "std nightly" |
| 55 | + - rust: nightly |
| 56 | + features: "std unique-wrap-std nightly" |
| 57 | + - rust: nightly |
| 58 | + features: "std nightly parking_lot" |
| 59 | + - rust: nightly |
| 60 | + features: "std nightly parking_lot bytemuck slog serde" |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v5 |
| 63 | + - uses: dtolnay/rust-toolchain@master |
| 64 | + with: |
| 65 | + toolchain: ${{ matrix.rust }} |
| 66 | + - name: Cache Cargo Registry |
| 67 | + id: cache-index |
| 68 | + uses: actions/cache@v4 |
| 69 | + with: |
| 70 | + path: |
| 71 | + # Before the sparse index, updating the registry took forever |
| 72 | + ~/.cargo/registry/index/ |
| 73 | + key: ${{ runner.os }}-cargo-${{ matrix.rust }} |
| 74 | + restore-keys: | |
| 75 | + ${{ runner.os }}-cargo- |
| 76 | + continue-on-error: false |
| 77 | + - name: Test |
| 78 | + # NOTE: Running --all-targets does not include doc tests |
| 79 | + # Does not compile benchmarks because they break on MSRV. Still checked by clippy |
| 80 | + run: | |
| 81 | + cargo test --all --verbose --no-default-features --features "${{ matrix.features }}" --exclude "benchmarks" |
| 82 | +
|
| 83 | + clippy: |
| 84 | + # Only run on PRs if the source branch is on someone else's repo |
| 85 | + if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} |
| 86 | + |
| 87 | + runs-on: ubuntu-latest |
| 88 | + strategy: |
| 89 | + fail-fast: false |
| 90 | + matrix: |
| 91 | + rust: |
| 92 | + # in hardcoded versions, warnings will fail the build |
| 93 | + - 1.89 |
| 94 | + # in auto-updated versions, warnings will not fail the build |
| 95 | + - stable |
| 96 | + - nightly |
| 97 | + features: |
| 98 | + # NOTE: Unfortunately, the benchmarks crate implicitly requires 'std' |
| 99 | + - "std parking_lot bytemuck slog serde" |
| 100 | + include: |
| 101 | + - rust: nightly |
| 102 | + features: "std slog bytemuck parking_lot serde nightly" |
| 103 | + - rust: nightly |
| 104 | + features: "std nightly unique-wrap-std" |
| 105 | + |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@v5 |
| 108 | + - uses: dtolnay/rust-toolchain@master |
| 109 | + with: |
| 110 | + toolchain: ${{ matrix.rust }} |
| 111 | + components: clippy |
| 112 | + - name: Clippy |
| 113 | + run: | |
| 114 | + cargo clippy --all --all-targets --verbose --no-default-features --features "${{ matrix.features }}" -- -D warnings |
| 115 | + # When using hardcoded/pinned versions, warnings are forbidden. |
| 116 | + # |
| 117 | + # On automatically updated versions of rust (both stable & nightly) we allow clippy to fail. |
| 118 | + # This is because automatic updates can introduce new lints or change existing lints. |
| 119 | + continue-on-error: ${{ !contains(matrix.rust, '1.') }} |
| 120 | + |
| 121 | + docs: |
| 122 | + # Only run on PRs if the source branch is on someone else's repo |
| 123 | + if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} |
| 124 | + |
| 125 | + runs-on: ubuntu-latest |
| 126 | + env: |
| 127 | + RUSTDOCFLAGS: "-D warnings" |
| 128 | + strategy: |
| 129 | + fail-fast: false |
| 130 | + matrix: |
| 131 | + rust: |
| 132 | + - nightly |
| 133 | + - stable |
| 134 | + features: |
| 135 | + - "std parking_lot bytemuck slog serde" |
| 136 | + include: |
| 137 | + - rust: nightly |
| 138 | + features: "std parking_lot bytemuck slog serde nightly nightly-docs" |
| 139 | + steps: |
| 140 | + - uses: actions/checkout@v5 |
| 141 | + - uses: dtolnay/rust-toolchain@master |
| 142 | + with: |
| 143 | + toolchain: ${{ matrix.rust }} |
| 144 | + - name: Docs |
| 145 | + run: | |
| 146 | + cargo doc --verbose --no-default-features --features "${{ matrix.features }}" |
| 147 | + cargo-rdme: |
| 148 | + # Only run on PRs if the source branch is on someone else's repo |
| 149 | + if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} |
| 150 | + |
| 151 | + runs-on: ubuntu-latest |
| 152 | + steps: |
| 153 | + - uses: actions/checkout@v5 |
| 154 | + - uses: dtolnay/rust-toolchain@stable |
| 155 | + with: |
| 156 | + components: rust-src |
| 157 | + # need to cache cargo-rdme to avoid redundant install |
| 158 | + - name: Cache Binaries |
| 159 | + id: cache-binaries |
| 160 | + uses: actions/cache@v4 |
| 161 | + with: |
| 162 | + path: |
| 163 | + ~/.cargo/bin/cargo-rdme |
| 164 | + key: ${{ runner.os }}-binary-cargo-rdme |
| 165 | + - name: Install cargo-rdme |
| 166 | + run: | |
| 167 | + cargo install cargo-rdme |
| 168 | + - name: Run cargo-rdme |
| 169 | + run: | |
| 170 | + cargo install cargo-rdme |
| 171 | + cargo rdme --check |
0 commit comments