|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: {} |
| 8 | + |
| 9 | +env: |
| 10 | + # Disable incremental compilation. |
| 11 | + # |
| 12 | + # Incremental compilation is useful as part of an edit-build-test-edit cycle, |
| 13 | + # as it lets the compiler avoid recompiling code that hasn't changed. However, |
| 14 | + # on CI, we're not making small edits; we're almost always building the entire |
| 15 | + # project from scratch. Thus, incremental compilation on CI actually |
| 16 | + # introduces *additional* overhead to support making future builds |
| 17 | + # faster...but no future builds will ever occur in any given CI environment. |
| 18 | + # |
| 19 | + # See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow |
| 20 | + # for details. |
| 21 | + CARGO_INCREMENTAL: 0 |
| 22 | + # Allow more retries for network requests in cargo (downloading crates) and |
| 23 | + # rustup (installing toolchains). This should help to reduce flaky CI failures |
| 24 | + # from transient network timeouts or other issues. |
| 25 | + CARGO_NET_RETRY: 10 |
| 26 | + RUSTUP_MAX_RETRIES: 10 |
| 27 | + # Don't emit giant backtraces in the CI logs. |
| 28 | + RUST_BACKTRACE: short |
| 29 | + |
| 30 | +jobs: |
| 31 | + ### check jobs ### |
| 32 | + |
| 33 | + check: |
| 34 | + # Run `cargo check` first to ensure that the pushed code at least compiles. |
| 35 | + name: cargo check |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v3 |
| 39 | + - uses: dtolnay/rust-toolchain@stable |
| 40 | + - name: Check |
| 41 | + run: cargo check --all --tests --benches |
| 42 | + |
| 43 | + style: |
| 44 | + # Check style. |
| 45 | + name: cargo fmt |
| 46 | + needs: check |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v3 |
| 50 | + - uses: dtolnay/rust-toolchain@stable |
| 51 | + with: |
| 52 | + components: rustfmt |
| 53 | + - name: rustfmt |
| 54 | + run: cargo fmt --all -- --check |
| 55 | + |
| 56 | + warnings: |
| 57 | + # Check for any warnings. This is informational and thus is allowed to fail. |
| 58 | + runs-on: ubuntu-latest |
| 59 | + needs: check |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v3 |
| 62 | + - uses: dtolnay/rust-toolchain@stable |
| 63 | + with: |
| 64 | + components: clippy |
| 65 | + - name: Clippy |
| 66 | + uses: actions-rs/clippy-check@v1 |
| 67 | + with: |
| 68 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + args: --all --examples --tests --benches -- -D warnings |
| 70 | + |
| 71 | + cargo-hack: |
| 72 | + needs: check |
| 73 | + name: cargo check (feature combinations) |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v3 |
| 77 | + - uses: dtolnay/rust-toolchain@stable |
| 78 | + - name: install cargo-hack |
| 79 | + uses: taiki-e/install-action@cargo-hack |
| 80 | + - run: cargo hack check --feature-powerset --no-dev-deps |
| 81 | + |
| 82 | + check-msrv: |
| 83 | + # Run `cargo check` on our minimum supported Rust version (1.56.0). This |
| 84 | + # checks with minimal versions; maximal versions are checked above. |
| 85 | + name: "cargo check (+MSRV -Zminimal-versions)" |
| 86 | + needs: check |
| 87 | + runs-on: ubuntu-latest |
| 88 | + strategy: |
| 89 | + matrix: |
| 90 | + toolchain: |
| 91 | + - 1.56.0 |
| 92 | + - stable |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v3 |
| 95 | + - name: install Rust nightly |
| 96 | + uses: dtolnay/rust-toolchain@nightly |
| 97 | + - name: "install Rust ${{ matrix.toolchain }}" |
| 98 | + uses: dtolnay/rust-toolchain@master |
| 99 | + with: |
| 100 | + toolchain: ${{ matrix.toolchain }} |
| 101 | + - name: install cargo-hack |
| 102 | + uses: taiki-e/install-action@cargo-hack |
| 103 | + - name: install cargo-minimal-versions |
| 104 | + uses: taiki-e/install-action@cargo-minimal-versions |
| 105 | + - name: cargo minimal-versions check |
| 106 | + working-directory: ${{ matrix.subcrate }} |
| 107 | + run: cargo minimal-versions check --feature-powerset --no-dev-deps |
| 108 | + |
| 109 | + ### test jobs ############################################################# |
| 110 | + |
| 111 | + test: |
| 112 | + # Test against stable Rust across macOS, Windows, and Linux, and against |
| 113 | + # beta and nightly rust on Ubuntu. |
| 114 | + name: "cargo test (${{ matrix.rust }} on ${{ matrix.os }})" |
| 115 | + needs: check |
| 116 | + strategy: |
| 117 | + matrix: |
| 118 | + # test all Rust versions on ubuntu-latest |
| 119 | + os: [ubuntu-latest] |
| 120 | + rust: [stable, beta, nightly] |
| 121 | + # test stable Rust on Windows and MacOS as well |
| 122 | + include: |
| 123 | + - rust: stable |
| 124 | + os: windows-latest |
| 125 | + - rust: stable |
| 126 | + os: macos-latest |
| 127 | + fail-fast: false |
| 128 | + runs-on: ${{ matrix.os }} |
| 129 | + steps: |
| 130 | + - uses: actions/checkout@v3 |
| 131 | + - name: "install Rust ${{ matrix.rust }}" |
| 132 | + uses: dtolnay/rust-toolchain@master |
| 133 | + with: |
| 134 | + toolchain: ${{ matrix.rust }} |
| 135 | + - name: install cargo-nextest |
| 136 | + uses: taiki-e/install-action@nextest |
| 137 | + - name: Run tests |
| 138 | + run: cargo nextest run --profile ci --workspace |
| 139 | + # TODO(eliza): punt on this for now because the generated JUnit report is |
| 140 | + # missing some fields that this action needs to give good output. |
| 141 | + # - name: Publish Test Report |
| 142 | + # uses: mikepenz/action-junit-report@v3 |
| 143 | + # if: always() # always run even if the previous step fails |
| 144 | + # with: |
| 145 | + # report_paths: 'target/nextest/ci/junit.xml' |
| 146 | + # check_name: "cargo test (Rust ${{ matrix.rust }} on ${{ matrix.os }})" |
| 147 | + # check_title_template: "{{SUITE_NAME}}::{{TEST_NAME}}" |
| 148 | + - name: Run doctests |
| 149 | + run: cargo test --doc --workspace |
| 150 | + |
| 151 | + test-build-wasm: |
| 152 | + name: build tests (wasm) |
| 153 | + needs: check |
| 154 | + runs-on: ubuntu-latest |
| 155 | + steps: |
| 156 | + - uses: actions/checkout@v3 |
| 157 | + - uses: dtolnay/rust-toolchain@stable |
| 158 | + with: |
| 159 | + target: wasm32-unknown-unknown |
| 160 | + - name: build all tests |
| 161 | + run: cargo test --no-run |
| 162 | + |
| 163 | + # all required checks except for the main test run (which we only require |
| 164 | + # specific matrix combinations from) |
| 165 | + all_required: |
| 166 | + name: "all systems go!" |
| 167 | + runs-on: ubuntu-latest |
| 168 | + needs: |
| 169 | + - style |
| 170 | + - cargo-hack |
| 171 | + - check-msrv |
| 172 | + - test-build-wasm |
| 173 | + - test |
| 174 | + steps: |
| 175 | + - run: exit 0 |
0 commit comments