|
| 1 | +name: Lints |
| 2 | + |
| 3 | +on: |
| 4 | + merge_group: |
| 5 | + pull_request: |
| 6 | + types: [synchronize, opened, reopened, ready_for_review] |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} |
| 13 | + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + lints: |
| 17 | + name: Various lints |
| 18 | + timeout-minutes: 30 |
| 19 | + runs-on: ubuntu-24.04 |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + - uses: dtolnay/rust-toolchain@master |
| 24 | + with: |
| 25 | + components: rustfmt, clippy |
| 26 | + targets: riscv32im-unknown-none-elf |
| 27 | + # TODO: figure out way to keep this in sync with rust-toolchain.toml automatically |
| 28 | + toolchain: nightly-2025-03-25 |
| 29 | + - name: Cargo cache |
| 30 | + uses: actions/cache@v4 |
| 31 | + with: |
| 32 | + path: | |
| 33 | + ~/.cargo/bin/ |
| 34 | + ~/.cargo/registry/index/ |
| 35 | + ~/.cargo/registry/cache/ |
| 36 | + ~/.cargo/git/db/ |
| 37 | + target/ |
| 38 | + ceno_rt/target/ |
| 39 | + examples/target/ |
| 40 | + key: lint-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 41 | + restore-keys: lint-${{ runner.os }}-cargo- |
| 42 | + |
| 43 | + - name: Install cargo make |
| 44 | + run: | |
| 45 | + cargo make --version || cargo install cargo-make |
| 46 | +
|
| 47 | + - name: Check code format |
| 48 | + run: cargo fmt --all --check |
| 49 | + |
| 50 | + - name: Run clippy |
| 51 | + env: |
| 52 | + RUSTFLAGS: "-Dwarnings" |
| 53 | + run: | |
| 54 | + cargo check --workspace --all-targets |
| 55 | + # We have a lot of code under #[cfg(not(debug_assertions))] and similar, |
| 56 | + # so we need to run cargo check in release mode, too: |
| 57 | + cargo check --workspace --all-targets --release |
| 58 | + cargo make clippy |
| 59 | + # Same for clippy: |
| 60 | + cargo clippy --workspace --all-targets --release |
| 61 | +
|
| 62 | + - name: Install taplo |
| 63 | + run: taplo --version || cargo install taplo-cli |
| 64 | + - name: Run taplo |
| 65 | + run: taplo fmt --check --diff |
0 commit comments