Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add pre-commit hooks for code formatting, linting #129

Merged
merged 3 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
1 change: 1 addition & 0 deletions raftify/src/raft_node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})),
})
Expand Down
Loading