diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d9398bf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: CI + +on: + pull_request: + types: [opened, ready_for_review, synchronize, reopened] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo build + uses: Swatinem/rust-cache@v2 + + - name: Check code formatting + run: cargo fmt --all -- --check + + - name: Run clippy Check + run: cargo clippy -- -D clippy::correctness + + - name: Run tests + run: cargo test --all --verbose diff --git a/Cargo.toml b/Cargo.toml index ac54ddc..06914ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,3 +30,21 @@ lto = true codegen-units = 1 panic = "abort" strip = true + +[lints.rust] +unsafe_code = "forbid" +missing_debug_implementations = "warn" + +[lints.clippy] +# Enable for educational purposes, but don't block CI +pedantic = "warn" +nursery = "warn" + +# To avoid .unwrap() usage +unwrap_used = "warn" + +# Float comparisons can be problematic +float_cmp = "warn" + +# Allow many arguments in functions for GUI code +#too_many_arguments = "allow" \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..cb549b9 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,15 @@ +[toolchain] +channel = "stable" + +components = [ + "rustfmt", + "clippy", + "rust-analysis", + "rust-docs", + "rust-src" +] + +targets = [ + "x86_64-unknown-linux-gnu", + "aarch64-unknown-linux-gnu" +] \ No newline at end of file