From 4d913168b9882a5f6affef3c57ec140134a7c33b Mon Sep 17 00:00:00 2001 From: pilmo kim <68311908+why-arong@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:32:41 +0900 Subject: [PATCH] feat: Add pre-commit hooks for code formatting, linting (#129) * add pre-commit yaml * lint * docs: Update DEVELOPMENT.md --------- Co-authored-by: Gyubong --- .pre-commit-config.yaml | 25 +++++++++++++++++++++++++ DEVELOPMENT.md | 18 ++++++++++++++++++ raftify/src/raft_node/mod.rs | 1 + 3 files changed, 44 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..8fd3f3ac --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: + - repo: https://github.com/doublify/pre-commit-rust + rev: v1.0 + hooks: + - id: fmt + name: Running "cargo fmt" + description: Format files with cargo fmt. + - id: clippy + name: Running "cargo clippy" + description: Lint rust sources + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.7 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 47fb7a13..8f8b96da 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -5,3 +5,21 @@ You can use this command to clone the repository: ``` ❯ git clone --recursive https://github.com/lablup/raftify.git ``` + +If you already cloned it and forgot to initialize the submodules, execute the following command: + +``` +❯ git submodule update --init +``` + +# Development environment setup + +## precommit hook setup + +You can use pre-commit hooks with the following configuration. +This commit hook performs checks like cargo fmt and cargo clippy before committing. + +``` +❯ pip install pre-commit --break-system-packages +❯ pre-commit install +``` diff --git a/raftify/src/raft_node/mod.rs b/raftify/src/raft_node/mod.rs index 62bb9426..b318943d 100644 --- a/raftify/src/raft_node/mod.rs +++ b/raftify/src/raft_node/mod.rs @@ -1147,6 +1147,7 @@ impl< tx_msg .send(LocalResponseMsg::GetRawNode { raw_node: Arc::new(Mutex::new(unsafe { + #[allow(clippy::missing_transmute_annotations)] std::mem::transmute(&self.raw_node) })), })