|
| 1 | +name: Build |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - staging |
| 8 | + - trying |
| 9 | + |
| 10 | +env: |
| 11 | + CARGO_TERM_COLOR: always |
| 12 | + |
| 13 | +jobs: |
| 14 | + # Run cargo fmt --check |
| 15 | + style: |
| 16 | + name: style |
| 17 | + runs-on: ubuntu-20.04 |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v1 |
| 21 | + |
| 22 | + - name: Install Rust |
| 23 | + uses: actions-rs/toolchain@v1 |
| 24 | + with: |
| 25 | + profile: minimal |
| 26 | + toolchain: stable |
| 27 | + override: true |
| 28 | + components: rustfmt |
| 29 | + |
| 30 | + - name: cargo fmt --check |
| 31 | + uses: actions-rs/cargo@v1 |
| 32 | + with: |
| 33 | + command: fmt |
| 34 | + args: --all -- --check |
| 35 | + |
| 36 | + # Compilation check |
| 37 | + check: |
| 38 | + name: check |
| 39 | + runs-on: ubuntu-20.04 |
| 40 | + strategy: |
| 41 | + matrix: |
| 42 | + target: |
| 43 | + - x86_64-unknown-linux-gnu |
| 44 | + - riscv32imc-unknown-none-elf |
| 45 | + - x86_64-unknown-linux-gnu |
| 46 | + - armv7r-none-eabi |
| 47 | + - thumbv6m-none-eabi |
| 48 | + - thumbv7m-none-eabi |
| 49 | + - thumbv8m.base-none-eabi |
| 50 | + - thumbv8m.main-none-eabi |
| 51 | + toolchain: |
| 52 | + - stable |
| 53 | + - nightly |
| 54 | + features: |
| 55 | + - "" |
| 56 | + - "serde" |
| 57 | + steps: |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v2 |
| 60 | + |
| 61 | + - name: Cache cargo dependencies |
| 62 | + uses: actions/cache@v2 |
| 63 | + with: |
| 64 | + path: | |
| 65 | + - ~/.cargo/bin/ |
| 66 | + - ~/.cargo/registry/index/ |
| 67 | + - ~/.cargo/registry/cache/ |
| 68 | + - ~/.cargo/git/db/ |
| 69 | + key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 70 | + restore-keys: | |
| 71 | + ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 72 | + ${{ runner.OS }}-cargo- |
| 73 | +
|
| 74 | + - name: Cache build output dependencies |
| 75 | + uses: actions/cache@v2 |
| 76 | + with: |
| 77 | + path: target |
| 78 | + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} |
| 79 | + restore-keys: | |
| 80 | + ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} |
| 81 | + ${{ runner.OS }}-build- |
| 82 | +
|
| 83 | + - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) |
| 84 | + uses: actions-rs/toolchain@v1 |
| 85 | + with: |
| 86 | + toolchain: ${{ matrix.toolchain }} |
| 87 | + target: ${{ matrix.target }} |
| 88 | + override: true |
| 89 | + |
| 90 | + - name: cargo check |
| 91 | + uses: actions-rs/cargo@v1 |
| 92 | + with: |
| 93 | + use-cross: false |
| 94 | + command: check |
| 95 | + args: --target=${{ matrix.target }} --features=${{ matrix.features }} |
| 96 | + |
| 97 | + # Run cpass tests |
| 98 | + testcpass: |
| 99 | + name: testcpass |
| 100 | + runs-on: ubuntu-20.04 |
| 101 | + strategy: |
| 102 | + matrix: |
| 103 | + target: |
| 104 | + - x86_64-unknown-linux-gnu |
| 105 | + toolchain: |
| 106 | + - stable |
| 107 | + - nightly |
| 108 | + - 1.36.0 |
| 109 | + features: |
| 110 | + - serde |
| 111 | + buildtype: |
| 112 | + - "" |
| 113 | + - "--release" |
| 114 | + steps: |
| 115 | + - name: Checkout |
| 116 | + uses: actions/checkout@v2 |
| 117 | + |
| 118 | + - name: Cache cargo dependencies |
| 119 | + uses: actions/cache@v2 |
| 120 | + with: |
| 121 | + path: | |
| 122 | + - ~/.cargo/bin/ |
| 123 | + - ~/.cargo/registry/index/ |
| 124 | + - ~/.cargo/registry/cache/ |
| 125 | + - ~/.cargo/git/db/ |
| 126 | + key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 127 | + restore-keys: | |
| 128 | + ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 129 | + ${{ runner.OS }}-cargo- |
| 130 | +
|
| 131 | + - name: Cache build output dependencies |
| 132 | + uses: actions/cache@v2 |
| 133 | + with: |
| 134 | + path: target |
| 135 | + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} |
| 136 | + restore-keys: | |
| 137 | + ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} |
| 138 | + ${{ runner.OS }}-build- |
| 139 | +
|
| 140 | + - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) |
| 141 | + uses: actions-rs/toolchain@v1 |
| 142 | + with: |
| 143 | + toolchain: ${{ matrix.toolchain }} |
| 144 | + target: ${{ matrix.target }} |
| 145 | + override: true |
| 146 | + - uses: actions-rs/cargo@v1 |
| 147 | + with: |
| 148 | + use-cross: false |
| 149 | + command: test |
| 150 | + args: --test cpass --target=${{ matrix.target }} --features=${{ matrix.features }} ${{ matrix.buildtype }} |
| 151 | + |
| 152 | + # Run test suite for UI |
| 153 | + testtsan: |
| 154 | + name: testtsan |
| 155 | + runs-on: ubuntu-20.04 |
| 156 | + strategy: |
| 157 | + matrix: |
| 158 | + target: |
| 159 | + - x86_64-unknown-linux-gnu |
| 160 | + toolchain: |
| 161 | + - nightly |
| 162 | + features: |
| 163 | + - x86-sync-pool |
| 164 | + buildtype: |
| 165 | + - "" |
| 166 | + - "--release" |
| 167 | + steps: |
| 168 | + - name: Checkout |
| 169 | + uses: actions/checkout@v2 |
| 170 | + |
| 171 | + - name: Cache cargo dependencies |
| 172 | + uses: actions/cache@v2 |
| 173 | + with: |
| 174 | + path: | |
| 175 | + - ~/.cargo/bin/ |
| 176 | + - ~/.cargo/registry/index/ |
| 177 | + - ~/.cargo/registry/cache/ |
| 178 | + - ~/.cargo/git/db/ |
| 179 | + key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 180 | + restore-keys: | |
| 181 | + ${{ runner.OS }}-cargo- |
| 182 | +
|
| 183 | + - name: Cache build output dependencies |
| 184 | + uses: actions/cache@v2 |
| 185 | + with: |
| 186 | + path: target |
| 187 | + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} |
| 188 | + restore-keys: | |
| 189 | + ${{ runner.OS }}-build- |
| 190 | +
|
| 191 | + - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) |
| 192 | + uses: actions-rs/toolchain@v1 |
| 193 | + with: |
| 194 | + toolchain: ${{ matrix.toolchain }} |
| 195 | + target: ${{ matrix.target }} |
| 196 | + override: true |
| 197 | + |
| 198 | + - name: Export variables |
| 199 | + run: | |
| 200 | + echo RUSTFLAGS="-Z sanitizer=thread" >> $GITHUB_ENV |
| 201 | + echo TSAN_OPTIONS="suppressions=$(pwd)/suppressions.txt" >> $GITHUB_ENV |
| 202 | + echo $GITHUB_ENV |
| 203 | +
|
| 204 | + - uses: actions-rs/cargo@v1 |
| 205 | + with: |
| 206 | + use-cross: false |
| 207 | + command: test |
| 208 | + args: --test tsan --target=${{ matrix.target }} --features=${{ matrix.features }} ${{ matrix.buildtype }} -- --test-threads=1 |
| 209 | + |
| 210 | + # Run cfail tests on MSRV |
| 211 | + testcfail: |
| 212 | + name: testcfail |
| 213 | + runs-on: ubuntu-20.04 |
| 214 | + defaults: |
| 215 | + run: |
| 216 | + working-directory: cfail |
| 217 | + |
| 218 | + steps: |
| 219 | + - name: Checkout |
| 220 | + uses: actions/checkout@v2 |
| 221 | + |
| 222 | + - name: Cache cargo dependencies |
| 223 | + uses: actions/cache@v2 |
| 224 | + with: |
| 225 | + path: | |
| 226 | + - ~/.cargo/bin/ |
| 227 | + - ~/.cargo/registry/index/ |
| 228 | + - ~/.cargo/registry/cache/ |
| 229 | + - ~/.cargo/git/db/ |
| 230 | + key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 231 | + restore-keys: | |
| 232 | + ${{ runner.OS }}-cargo- |
| 233 | +
|
| 234 | + - name: Cache build output dependencies |
| 235 | + uses: actions/cache@v2 |
| 236 | + with: |
| 237 | + path: target |
| 238 | + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} |
| 239 | + restore-keys: | |
| 240 | + ${{ runner.OS }}-build- |
| 241 | +
|
| 242 | + - name: Install Rust |
| 243 | + uses: actions-rs/toolchain@v1 |
| 244 | + with: |
| 245 | + toolchain: 1.36.0 |
| 246 | + target: x86_64-unknown-linux-gnu |
| 247 | + override: true |
| 248 | + |
| 249 | + - name: Run cargo |
| 250 | + run: cargo run |
| 251 | + |
| 252 | + # Only runs when pushing to master branch |
| 253 | + deploy: |
| 254 | + name: deploy |
| 255 | + runs-on: ubuntu-20.04 |
| 256 | + needs: |
| 257 | + - style |
| 258 | + - check |
| 259 | + - testcpass |
| 260 | + - testtsan |
| 261 | + - testcfail |
| 262 | + # Only run this when pushing to master branch |
| 263 | + if: github.ref == 'refs/heads/master' |
| 264 | + steps: |
| 265 | + - uses: actions/checkout@v2 |
| 266 | + |
| 267 | + - name: Set up Python 3.x |
| 268 | + uses: actions/setup-python@v2 |
| 269 | + with: |
| 270 | + # Semantic version range syntax or exact version of a Python version |
| 271 | + python-version: '3.x' |
| 272 | + # Optional - x64 or x86 architecture, defaults to x64 |
| 273 | + architecture: 'x64' |
| 274 | + |
| 275 | + # You can test your matrix by printing the current Python version |
| 276 | + - name: Display Python version |
| 277 | + run: python -c "import sys; print(sys.version)" |
| 278 | + |
| 279 | + - name: mdBook Action |
| 280 | + |
| 281 | + with: |
| 282 | + mdbook-version: 'latest' |
| 283 | + |
| 284 | + - name: Remove cargo-config |
| 285 | + run: rm -f .cargo/config |
| 286 | + |
| 287 | + - name: Build docs |
| 288 | + run: cargo doc |
| 289 | + |
| 290 | + - name: Deploy to GH-pages |
| 291 | + uses: peaceiris/actions-gh-pages@v3 |
| 292 | + with: |
| 293 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 294 | + publish_dir: ./target/doc |
| 295 | + |
| 296 | + # Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149 |
| 297 | + # |
| 298 | + # ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB! |
| 299 | + |
| 300 | + ci-success: |
| 301 | + name: ci |
| 302 | + if: github.event_name == 'push' && success() |
| 303 | + needs: |
| 304 | + - style |
| 305 | + - check |
| 306 | + - testcpass |
| 307 | + - testtsan |
| 308 | + - testcfail |
| 309 | + runs-on: ubuntu-20.04 |
| 310 | + steps: |
| 311 | + - name: Mark the job as a success |
| 312 | + run: exit 0 |
| 313 | + ci-failure: |
| 314 | + name: ci |
| 315 | + if: github.event_name == 'push' && !success() |
| 316 | + needs: |
| 317 | + - style |
| 318 | + - check |
| 319 | + - testcpass |
| 320 | + - testtsan |
| 321 | + - testcfail |
| 322 | + runs-on: ubuntu-20.04 |
| 323 | + steps: |
| 324 | + - name: Mark the job as a failure |
| 325 | + run: exit 1 |
0 commit comments