|
| 1 | +name: Rust |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +env: |
| 6 | + CARGO_TERM_COLOR: always |
| 7 | + CARGO_INCREMENTAL: 0 |
| 8 | + CARGO_NET_RETRY: 10 |
| 9 | + RUST_BACKTRACE: short |
| 10 | + RUSTUP_MAX_RETRIES: 10 |
| 11 | + |
| 12 | +jobs: |
| 13 | + tests: |
| 14 | + name: Tests |
| 15 | + |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + # We test the following targets: |
| 21 | + # - 64bit Linux stable |
| 22 | + # - 64bit Linux beta |
| 23 | + # - 64bit Linux nightly |
| 24 | + # - 64bit MacOS stable |
| 25 | + # - 64bit Windows stable |
| 26 | + # - 32bit Windows stable |
| 27 | + include: |
| 28 | + - { |
| 29 | + rust: stable, |
| 30 | + target: x86_64-unknown-linux-gnu, |
| 31 | + os: ubuntu-latest, |
| 32 | + } |
| 33 | + - { rust: stable, target: x86_64-apple-darwin, os: macos-latest } |
| 34 | + - { rust: stable, target: x86_64-pc-windows-msvc, os: windows-latest } |
| 35 | + - { rust: stable, target: i686-pc-windows-msvc, os: windows-latest } |
| 36 | + - { rust: beta, target: x86_64-unknown-linux-gnu, os: ubuntu-latest } |
| 37 | + - { |
| 38 | + rust: nightly, |
| 39 | + target: x86_64-unknown-linux-gnu, |
| 40 | + os: ubuntu-latest, |
| 41 | + } |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout |
| 45 | + uses: actions/checkout@v3 |
| 46 | + |
| 47 | + - name: Install rust |
| 48 | + uses: actions-rs/toolchain@v1 |
| 49 | + with: |
| 50 | + toolchain: ${{ matrix.rust }} |
| 51 | + target: ${{ matrix.target }} |
| 52 | + profile: minimal |
| 53 | + default: true |
| 54 | + |
| 55 | + - name: Restore cache |
| 56 | + uses: Swatinem/rust-cache@v1 |
| 57 | + |
| 58 | + # We split building the tests into a separate step |
| 59 | + # so that we can easily distinguish between build |
| 60 | + # errors and failing tests |
| 61 | + - name: Build tests with all features |
| 62 | + uses: actions-rs/cargo@v1 |
| 63 | + with: |
| 64 | + command: test |
| 65 | + args: --no-run --all-features --target ${{ matrix.target }} |
| 66 | + |
| 67 | + - name: Build tests with no features |
| 68 | + uses: actions-rs/cargo@v1 |
| 69 | + with: |
| 70 | + command: test |
| 71 | + args: --no-run --no-default-features --target ${{ matrix.target }} |
| 72 | + |
| 73 | + - name: Run tests |
| 74 | + uses: actions-rs/cargo@v1 |
| 75 | + with: |
| 76 | + command: test |
| 77 | + args: --all-features --target ${{ matrix.target }} |
| 78 | + |
| 79 | + miri: |
| 80 | + name: Miri |
| 81 | + |
| 82 | + runs-on: ${{ matrix.os }} |
| 83 | + strategy: |
| 84 | + fail-fast: false |
| 85 | + matrix: |
| 86 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 87 | + |
| 88 | + steps: |
| 89 | + - name: Checkout repository |
| 90 | + uses: actions/checkout@v3 |
| 91 | + |
| 92 | + - name: Install rust |
| 93 | + uses: actions-rs/toolchain@v1 |
| 94 | + with: |
| 95 | + toolchain: nightly |
| 96 | + profile: minimal |
| 97 | + components: miri, rust-src |
| 98 | + default: true |
| 99 | + |
| 100 | + - name: Restore cache |
| 101 | + uses: Swatinem/rust-cache@v1 |
| 102 | + |
| 103 | + - name: Run miri |
| 104 | + uses: actions-rs/cargo@v1 |
| 105 | + env: |
| 106 | + OS: ${{ matrix.os }} |
| 107 | + MIRIFLAGS: "-Zmiri-tag-raw-pointers -Zmiri-disable-isolation" |
| 108 | + with: |
| 109 | + command: miri |
| 110 | + args: test --all-features |
| 111 | + |
| 112 | + test-sanitizers: |
| 113 | + name: Sanitizer Tests |
| 114 | + |
| 115 | + runs-on: ${{ matrix.os }} |
| 116 | + strategy: |
| 117 | + fail-fast: false |
| 118 | + |
| 119 | + # Note: We use this really sketchy matrix because msan doesn't work on macos, |
| 120 | + # I would much rather use `matrix.exclude` for this but for some reason |
| 121 | + # github actions in its ever-inspired wisdom decided that `include` |
| 122 | + # should calculate its combinations *after* `exclude`` is applied |
| 123 | + # and since no one could *ever* want to exclude things added by an |
| 124 | + # `include` and in their infinite brilliance they saw fit not to have |
| 125 | + # any way of excluding things added by an include. In an ideal world I'd |
| 126 | + # just write this since it's what makes sense |
| 127 | + # ``` |
| 128 | + # matrix: |
| 129 | + # sanitizer: [address, thread, memory, leak] |
| 130 | + # include: |
| 131 | + # - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest } |
| 132 | + # - { target: x86_64-apple-darwin, os: macos-latest } |
| 133 | + # exclude: |
| 134 | + # - target: x86_64-apple-darwin |
| 135 | + # sanitizer: memory |
| 136 | + # ``` |
| 137 | + # but no, instead we have to do whatever the hell this is |
| 138 | + matrix: |
| 139 | + os: [ubuntu-latest, macos-latest] |
| 140 | + sanitizer: [address, thread, memory, leak] |
| 141 | + target: [x86_64-unknown-linux-gnu, x86_64-apple-darwin] |
| 142 | + exclude: |
| 143 | + # Exclude ubuntu runs with darwin targets |
| 144 | + - { os: ubuntu-latest, target: x86_64-apple-darwin } |
| 145 | + # Exclude macos runs with linux targets |
| 146 | + - { os: macos-latest, target: x86_64-unknown-linux-gnu } |
| 147 | + # Exclude darwin runs with memory sanitizers since |
| 148 | + # it doesn't support msan |
| 149 | + - { target: x86_64-apple-darwin, sanitizer: memory } |
| 150 | + |
| 151 | + steps: |
| 152 | + - name: Checkout |
| 153 | + uses: actions/checkout@v3 |
| 154 | + |
| 155 | + - name: Install rust |
| 156 | + uses: actions-rs/toolchain@v1 |
| 157 | + with: |
| 158 | + profile: minimal |
| 159 | + toolchain: nightly |
| 160 | + target: ${{ matrix.target }} |
| 161 | + components: rust-src |
| 162 | + default: true |
| 163 | + |
| 164 | + - name: Restore cache |
| 165 | + uses: Swatinem/rust-cache@v1 |
| 166 | + |
| 167 | + - name: Run tests under ${{ matrix.sanitizer }} sanitizer |
| 168 | + uses: actions-rs/cargo@v1 |
| 169 | + env: |
| 170 | + RUSTDOCFLAGS: "-Z sanitizer=${{ matrix.sanitizer }}" |
| 171 | + RUSTFLAGS: "-Z sanitizer=${{ matrix.sanitizer }}" |
| 172 | + ASAN_OPTIONS: detect_stack_use_after_return=1,detect_leaks=1 |
| 173 | + # Backtraces sometimes mess with sanitizers |
| 174 | + RUST_BACKTRACE: 0 |
| 175 | + with: |
| 176 | + command: test |
| 177 | + args: --all-features --target ${{ matrix.target }} -Z build-std |
| 178 | + |
| 179 | + clippy: |
| 180 | + name: Clippy |
| 181 | + runs-on: ubuntu-latest |
| 182 | + |
| 183 | + steps: |
| 184 | + - name: Checkout repository |
| 185 | + uses: actions/checkout@v3 |
| 186 | + |
| 187 | + - name: Install rust |
| 188 | + uses: actions-rs/toolchain@v1 |
| 189 | + with: |
| 190 | + profile: minimal |
| 191 | + toolchain: nightly |
| 192 | + components: clippy |
| 193 | + default: true |
| 194 | + |
| 195 | + - name: Restore cache |
| 196 | + uses: Swatinem/rust-cache@v1 |
| 197 | + |
| 198 | + - name: Run clippy |
| 199 | + uses: actions-rs/clippy-check@v1 |
| 200 | + with: |
| 201 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 202 | + args: --all-features --all -- -D warnings |
| 203 | + |
| 204 | + fmt: |
| 205 | + name: Rustfmt |
| 206 | + runs-on: ubuntu-latest |
| 207 | + |
| 208 | + steps: |
| 209 | + - name: Checkout repository |
| 210 | + uses: actions/checkout@v3 |
| 211 | + |
| 212 | + - name: Install rust |
| 213 | + uses: actions-rs/toolchain@v1 |
| 214 | + with: |
| 215 | + profile: minimal |
| 216 | + toolchain: nightly |
| 217 | + components: rustfmt |
| 218 | + default: true |
| 219 | + |
| 220 | + - name: Run rustfmt |
| 221 | + uses: actions-rs/cargo@v1 |
| 222 | + with: |
| 223 | + command: fmt |
| 224 | + args: --all -- --check |
| 225 | + |
| 226 | + links: |
| 227 | + name: Check Doc Links |
| 228 | + runs-on: ubuntu-latest |
| 229 | + |
| 230 | + steps: |
| 231 | + - name: Checkout |
| 232 | + uses: actions/checkout@v3 |
| 233 | + |
| 234 | + - name: Install rust |
| 235 | + uses: actions-rs/toolchain@v1 |
| 236 | + with: |
| 237 | + toolchain: stable |
| 238 | + default: true |
| 239 | + |
| 240 | + - name: Restore cache |
| 241 | + uses: Swatinem/rust-cache@v1 |
| 242 | + |
| 243 | + - name: Check links |
| 244 | + uses: actions-rs/cargo@v1 |
| 245 | + with: |
| 246 | + command: rustdoc |
| 247 | + args: --all-features -- -D warnings |
0 commit comments