|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + types: [opened, synchronize, reopened] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +env: |
| 12 | + # Disable incremental compilation. CI builds are often closer to from-scratch builds, as changes |
| 13 | + # are typically bigger than from a local edit-compile cycle. |
| 14 | + # Incremental compilation also significantly increases the amount of IO and the size of ./target |
| 15 | + # folder, which makes caching less effective. |
| 16 | + CARGO_INCREMENTAL: 0 |
| 17 | + CARGO_NET_RETRY: 10 |
| 18 | + RUSTUP_MAX_RETRIES: 10 |
| 19 | + RUST_BACKTRACE: short |
| 20 | + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse |
| 21 | + # Cache should never take more than a few seconds to get downloaded. |
| 22 | + # If it does, let's just rebuild from scratch instead of hanging "forever". |
| 23 | + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 |
| 24 | + # Disabling debug info so compilation is faster and ./target folder is smaller. |
| 25 | + CARGO_PROFILE_DEV_DEBUG: 0 |
| 26 | + |
| 27 | +jobs: |
| 28 | + formatting: |
| 29 | + name: Check formatting |
| 30 | + runs-on: ubuntu-latest |
| 31 | + |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Check formatting |
| 36 | + run: cargo fmt --all --check |
| 37 | + |
| 38 | + checks: |
| 39 | + name: Checks [${{ matrix.os }}] |
| 40 | + runs-on: ${{ matrix.runner }} |
| 41 | + needs: formatting |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + os: [windows, linux, macos] |
| 46 | + include: |
| 47 | + - os: windows |
| 48 | + runner: windows-latest |
| 49 | + - os: linux |
| 50 | + runner: ubuntu-latest |
| 51 | + - os: macos |
| 52 | + runner: macos-latest |
| 53 | + |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Rust cache |
| 58 | + uses: Swatinem/rust-cache@v2.8.2 |
| 59 | + |
| 60 | + - name: Lints |
| 61 | + run: cargo clippy --workspace --all-features --tests -v -- -Dwarnings |
| 62 | + |
| 63 | + - name: Tests |
| 64 | + run: cargo test --workspace -v |
| 65 | + |
| 66 | + success: |
| 67 | + name: Success |
| 68 | + runs-on: ubuntu-latest |
| 69 | + if: ${{ always() }} |
| 70 | + needs: |
| 71 | + - formatting |
| 72 | + - checks |
| 73 | + |
| 74 | + steps: |
| 75 | + - name: CI succeeded |
| 76 | + id: succeeded |
| 77 | + if: ${{ !contains(needs.*.result, 'failure') }} |
| 78 | + run: exit 0 |
| 79 | + |
| 80 | + - name: CI failed |
| 81 | + if: ${{ steps.succeeded.outcome == 'skipped' }} |
| 82 | + run: exit 1 |
0 commit comments