Skip to content

Commit 1bc7aaf

Browse files
committed
[CI] Add ruff-pre-commit hook
- Add precommit config - Update CONTRIBUTION.md, Add "Prepare" section Signed-off-by: MingZhu Yan <yanmingzhu@iscas.ac.cn>
1 parent 9277915 commit 1bc7aaf

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.7.0
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
# Run the formatter. (disabled until format PR merged)
9+
# - id: ruff-format
10+
# args: [ --check ]

CONTRIBUTION.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,33 @@ Your inputs are welcome and greatly appreciated! We want to make contributing to
99
- Becoming a maintainer
1010

1111
## We develop with Github
12+
1213
We use github to host code, to track issues and feature requests, as well as accept pull requests.
1314

15+
## Prepare
16+
17+
We use [ruff](https://docs.astral.sh/ruff/) as our linter and formatter, all the changes you made will be checked by out CI pipeline. So you should:
18+
19+
- install ruff: `pip install ruff` or [more install methods](https://docs.astral.sh/ruff/installation/)
20+
21+
To run CI locally, you can use [pre-commit](https://pre-commit.com/), it runs the same check as CI pipeline:
22+
23+
- install pre-commit: `pip install pre-commit`
24+
25+
then you can run check directly by: `pre-commit run`
26+
27+
> notice that pre-commit will only run on the staged files, if you want to check all, please use `pre-commit run -a`
28+
29+
If you use git, you can set [git hooks](https://git-scm.com/book/ms/v2/Customizing-Git-Git-Hooks) automatically by:
30+
31+
- set git hooks: `pre-commit install`
32+
33+
then pre-commit check will be triggered automatically when you run `git commit`
34+
35+
> if your think some changes are necessary even though they won't pass the check, you can use `git commit --no-verify` which will skip the pre-commit check.
36+
37+
If you are using vscode, you can also use [Offical Ruff Extension for vscode](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) to automatically format/lint your code on save.
38+
1439
## We use a simple git flow where all code changes happen through Pull Requests
1540

1641
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
@@ -54,9 +79,11 @@ Note: You can have either a patch or minor or major update.
5479
Note: In case of a conflict, the maintainers will decide the final version to be assigned.
5580

5681
## Any contributions you make will be under the permissive open-source License
82+
5783
In short, when you submit code changes, your submissions are understood to be under a permissive open source license like BSD-3, Apache-2.0 and CC, etc that covers the project. Feel free to contact the maintainers if that's a concern.
5884

5985
## Report bugs using Github's [issues](https://github.com/riscv/riscv-arch-test/issues)
86+
6087
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/riscv/riscv-arch-test/issues/new); it's that easy!
6188

6289
## Write bug reports with detail, background, and sample code
@@ -66,12 +93,11 @@ We use GitHub issues to track public bugs. Report a bug by [opening a new issue]
6693
- A quick summary and/or background
6794
- Steps to reproduce
6895
- Be specific!
69-
- Give sample code if you can.
96+
- Give sample code if you can.
7097
- What you expected would happen
7198
- What actually happens
7299
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
73100

74101
## License
75102
By contributing, you agree that your contributions will be licensed under its permissive open source
76103
licenses.
77-

0 commit comments

Comments
 (0)