Skip to content

Commit

Permalink
feat: Add pre-commit hooks for code formatting, linting (#129)
Browse files Browse the repository at this point in the history
* add pre-commit yaml

* lint

* docs: Update DEVELOPMENT.md

---------

Co-authored-by: Gyubong <[email protected]>
  • Loading branch information
why-arong and jopemachine authored Sep 29, 2024
1 parent 7ff4d30 commit 4d91316
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
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

0 comments on commit 4d91316

Please sign in to comment.