|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + name: test ${{ matrix.rust }} ${{ matrix.flags }} |
| 18 | + runs-on: ubuntu-latest |
| 19 | + timeout-minutes: 30 |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + rust: ["stable", "nightly", "1.76"] # MSRV |
| 24 | + flags: ["--no-default-features", "", "--all-features"] |
| 25 | + exclude: |
| 26 | + # Some features have higher MSRV. |
| 27 | + - rust: "1.76" # MSRV |
| 28 | + flags: "--all-features" |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v3 |
| 31 | + - uses: dtolnay/rust-toolchain@master |
| 32 | + with: |
| 33 | + toolchain: ${{ matrix.rust }} |
| 34 | + - name: Install Anvil |
| 35 | + uses: foundry-rs/foundry-toolchain@v1 |
| 36 | + with: |
| 37 | + version: nightly |
| 38 | + - name: Install test binaries |
| 39 | + shell: bash |
| 40 | + run: ./.github/scripts/install_test_binaries.sh |
| 41 | + - uses: Swatinem/rust-cache@v2 |
| 42 | + with: |
| 43 | + cache-on-failure: true |
| 44 | + # Only run tests on latest stable and above |
| 45 | + - name: Install cargo-nextest |
| 46 | + if: ${{ matrix.rust != '1.76' }} # MSRV |
| 47 | + uses: taiki-e/install-action@nextest |
| 48 | + - name: build |
| 49 | + if: ${{ matrix.rust == '1.76' }} # MSRV |
| 50 | + run: cargo build --workspace ${{ matrix.flags }} |
| 51 | + - name: test |
| 52 | + if: ${{ matrix.rust != '1.76' }} # MSRV |
| 53 | + run: cargo nextest run --workspace ${{ matrix.flags }} |
| 54 | + |
| 55 | + doctest: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + timeout-minutes: 30 |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + - uses: dtolnay/rust-toolchain@stable |
| 61 | + - uses: Swatinem/rust-cache@v2 |
| 62 | + with: |
| 63 | + cache-on-failure: true |
| 64 | + - run: cargo test --workspace --doc |
| 65 | + - run: cargo test --all-features --workspace --doc |
| 66 | + |
| 67 | + no-std: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + timeout-minutes: 30 |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v3 |
| 72 | + - uses: dtolnay/rust-toolchain@stable |
| 73 | + with: |
| 74 | + target: riscv32imac-unknown-none-elf |
| 75 | + - uses: taiki-e/install-action@cargo-hack |
| 76 | + - uses: Swatinem/rust-cache@v2 |
| 77 | + with: |
| 78 | + cache-on-failure: true |
| 79 | + - name: check |
| 80 | + run: ./scripts/check_no_std.sh |
| 81 | + |
| 82 | + feature-checks: |
| 83 | + runs-on: ubuntu-latest |
| 84 | + timeout-minutes: 30 |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@v3 |
| 87 | + - uses: dtolnay/rust-toolchain@stable |
| 88 | + - uses: taiki-e/install-action@cargo-hack |
| 89 | + - uses: Swatinem/rust-cache@v2 |
| 90 | + with: |
| 91 | + cache-on-failure: true |
| 92 | + - name: cargo hack |
| 93 | + run: cargo hack check --feature-powerset --depth 1 |
| 94 | + |
| 95 | + clippy: |
| 96 | + runs-on: ubuntu-latest |
| 97 | + timeout-minutes: 30 |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + - uses: dtolnay/rust-toolchain@master |
| 101 | + with: |
| 102 | + toolchain: stable |
| 103 | + components: clippy |
| 104 | + - uses: Swatinem/rust-cache@v2 |
| 105 | + with: |
| 106 | + cache-on-failure: true |
| 107 | + - run: cargo +stable clippy --workspace --all-targets --all-features |
| 108 | + env: |
| 109 | + RUSTFLAGS: -Dwarnings |
| 110 | + |
| 111 | + docs: |
| 112 | + runs-on: ubuntu-latest |
| 113 | + timeout-minutes: 30 |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@v3 |
| 116 | + - uses: dtolnay/rust-toolchain@nightly |
| 117 | + - uses: Swatinem/rust-cache@v2 |
| 118 | + with: |
| 119 | + cache-on-failure: true |
| 120 | + - run: cargo doc --workspace --all-features --no-deps --document-private-items |
| 121 | + env: |
| 122 | + RUSTDOCFLAGS: |
| 123 | + --cfg docsrs -D warnings --show-type-layout --generate-link-to-definition |
| 124 | + --enable-index-page -Zunstable-options |
| 125 | + - name: Deploy documentation |
| 126 | + uses: peaceiris/actions-gh-pages@v3 |
| 127 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 128 | + with: |
| 129 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 130 | + publish_dir: target/doc |
| 131 | + force_orphan: true |
| 132 | + |
| 133 | + fmt: |
| 134 | + runs-on: ubuntu-latest |
| 135 | + timeout-minutes: 30 |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v3 |
| 138 | + - uses: dtolnay/rust-toolchain@nightly |
| 139 | + with: |
| 140 | + components: rustfmt |
| 141 | + - run: cargo fmt --all --check |
| 142 | + |
| 143 | + cfg-check: |
| 144 | + runs-on: ubuntu-latest |
| 145 | + timeout-minutes: 30 |
| 146 | + steps: |
| 147 | + - uses: actions/checkout@v3 |
| 148 | + - uses: dtolnay/rust-toolchain@nightly |
| 149 | + with: |
| 150 | + toolchain: nightly |
| 151 | + - uses: Swatinem/rust-cache@v2 |
| 152 | + with: |
| 153 | + cache-on-failure: true |
| 154 | + - run: cargo check -Zcheck-cfg --workspace |
0 commit comments