diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..2b35b50 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,46 @@ +name: Rust Tests + +on: + push: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +env: + CARGO_TERM_COLOR: always + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + test: + name: Test + runs-on: ubuntu-latest + if: github.event_name == 'push' || !github.event.pull_request.draft + steps: + - uses: actions/checkout@v4 + with: + lfs: true + - uses: dsherret/rust-toolchain-file@v1 + - uses: Swatinem/rust-cache@v2 + - name: Run tests + run: cargo test --workspace --verbose + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + if: github.event_name == 'push' || !github.event.pull_request.draft + steps: + - uses: actions/checkout@v4 + - uses: dsherret/rust-toolchain-file@v1 + - run: cargo fmt --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + if: github.event_name == 'push' || !github.event.pull_request.draft + steps: + - uses: actions/checkout@v4 + - uses: dsherret/rust-toolchain-file@v1 + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all-targets --all-features -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index 3dcb0cc..91800b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,3 +48,9 @@ tracing = "0.1.41" tracing-subscriber = "0.3.19" url = "2.5.4" valuable = "0.1.1" + +[workspace.lints.clippy] +all = "warn" +correctness = "deny" +suspicious = "warn" +perf = "warn" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4f3e8c5..f018685 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,3 @@ [toolchain] channel = "1.89" +components = [ "rustfmt", "clippy" ]