From 572a2b89a69e142627588692e68595474b01cd68 Mon Sep 17 00:00:00 2001 From: GitGhillie Date: Fri, 19 Jan 2024 22:23:47 +0100 Subject: [PATCH] chore(CI): Add lint CI (#100) * Add lint CI * Clippy allow complex types, warn on some others * bevy_gltf_blueprints use workspace lints * Update toolchain for workspace wide lints * Use workspace lints on the other crates as well --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++ Cargo.toml | 12 +++++++++++ crates/bevy_gltf_blueprints/Cargo.toml | 3 +++ crates/bevy_gltf_components/Cargo.toml | 3 +++ crates/bevy_gltf_save_load/Cargo.toml | 3 +++ rust-toolchain.toml | 2 +- 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..93c2ea6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: CI + +on: + pull_request: + push: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ubuntu-latest-cargo-lint-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.75.0 + components: rustfmt, clippy + - name: Install alsa and udev + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev + - name: Run clippy + run: cargo clippy --workspace --all-targets --all-features -- -Dwarnings + - name: Check format + run: cargo fmt --all -- --check diff --git a/Cargo.toml b/Cargo.toml index 77216a3..71a2c6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,18 @@ members = [ ] resolver = "2" +[workspace.lints.clippy] +type_complexity = "allow" +doc_markdown = "warn" +manual_let_else = "warn" +undocumented_unsafe_blocks = "warn" +redundant_else = "warn" +match_same_arms = "warn" +semicolon_if_nothing_returned = "warn" + +[lints] +workspace = true + #### --------------------Dev/ debug------------------------------- # Enable high optimizations for dependencies (incl. Bevy), but not for our code: [profile.dev.package."*"] diff --git a/crates/bevy_gltf_blueprints/Cargo.toml b/crates/bevy_gltf_blueprints/Cargo.toml index 59387c9..15b99df 100644 --- a/crates/bevy_gltf_blueprints/Cargo.toml +++ b/crates/bevy_gltf_blueprints/Cargo.toml @@ -10,6 +10,9 @@ categories = ["game-development"] edition = "2021" license = "MIT OR Apache-2.0" +[lints] +workspace = true + [dev-dependencies] bevy = { version = "0.12", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf", "bevy_animation", "animation"] } diff --git a/crates/bevy_gltf_components/Cargo.toml b/crates/bevy_gltf_components/Cargo.toml index c0b08fb..2e50ece 100644 --- a/crates/bevy_gltf_components/Cargo.toml +++ b/crates/bevy_gltf_components/Cargo.toml @@ -10,6 +10,9 @@ categories = ["game-development"] edition = "2021" license = "MIT OR Apache-2.0" +[lints] +workspace = true + [dev-dependencies] bevy = { version = "0.12", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] } diff --git a/crates/bevy_gltf_save_load/Cargo.toml b/crates/bevy_gltf_save_load/Cargo.toml index c41ab0e..9006566 100644 --- a/crates/bevy_gltf_save_load/Cargo.toml +++ b/crates/bevy_gltf_save_load/Cargo.toml @@ -10,6 +10,9 @@ categories = ["game-development"] edition = "2021" license = "MIT OR Apache-2.0" +[lints] +workspace = true + [dev-dependencies] bevy = { version = "0.12", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 263cc78..ffcfdc7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = '1.72.0' +channel = '1.75.0'