-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
# A pre-push hook for rust codebases that checks formatting, clippy, and tests | ||
|
||
set -eu | ||
|
||
if [[ "${IGNORE_RUSTHOOKS:=0}" -ne 0 ]]; then | ||
echo "Ignoring rusthooks" | ||
exit 0 | ||
fi | ||
|
||
if ! cargo fmt -- --check | ||
then | ||
echo "There are some code style issues." | ||
echo "Run cargo fmt first." | ||
exit 1 | ||
fi | ||
|
||
if ! cargo clippy --all-targets --all-features --workspace -- -D warnings | ||
then | ||
echo "There are some clippy issues." | ||
exit 1 | ||
fi | ||
|
||
if ! cargo test --all-features | ||
then | ||
echo "There are some test issues." | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Welcome to the portgraph development guide <!-- omit in toc --> | ||
|
||
This guide is intended to help you get started with developing portgraph. | ||
|
||
If you find any errors or omissions in this document, please [open an issue](https://github.com/CQCL/portgraph/issues/new)! | ||
|
||
## #️⃣ Setting up the development environment | ||
|
||
You can setup the development environment you will need: | ||
|
||
- Rust: https://www.rust-lang.org/tools/install | ||
|
||
You can use the git hook in [`.github/pre-commit`](.github/pre-commit) to automatically run the test and check formatting before committing. | ||
To install it, run: | ||
|
||
```bash | ||
ln -s .github/pre-commit .git/hooks/pre-commit | ||
# Or, to check before pushing instead | ||
ln -s .github/pre-commit .git/hooks/pre-push | ||
``` | ||
|
||
## 🏃 Running the tests | ||
|
||
To compile and test the rust code, run: | ||
|
||
```bash | ||
cargo build | ||
cargo test | ||
``` | ||
|
||
Run the benchmarks with: | ||
|
||
```bash | ||
cargo bench | ||
``` | ||
|
||
Finally, if you have rust nightly installed, you can run `miri` to detect | ||
undefined behaviour in the code. | ||
|
||
```bash | ||
cargo +nightly miri test | ||
``` | ||
|
||
## 💅 Coding Style | ||
|
||
The rustfmt tool is used to enforce a consistent rust coding style. The CI will fail if the code is not formatted correctly. | ||
|
||
To format your code, run: | ||
|
||
```bash | ||
# Format rust code | ||
cargo fmt | ||
``` | ||
|
||
We also check for clippy warnings, which are a set of linting rules for rust. To run clippy, run: | ||
|
||
```bash | ||
cargo clippy --all-targets | ||
``` | ||
|
||
## 🌐 Contributing to portgraph | ||
|
||
We welcome contributions to portgraph! Please open [an issue](https://github.com/CQCL/portgraph/issues/new) or [pull request](https://github.com/CQCL/portgraph/compare) if you have any questions or suggestions. | ||
|
||
PRs should be made against the `main` branch, and should pass all CI checks before being merged. This includes using the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) format for the PR title. | ||
|
||
The general format of a contribution title should be: | ||
|
||
``` | ||
<type>(<scope>)!: <description> | ||
``` | ||
|
||
Where the scope is optional, and the `!` is only included if this is a semver breaking change that requires a major version bump. | ||
|
||
We accept the following contribution types: | ||
|
||
- feat: New features. | ||
- fix: Bug fixes. | ||
- docs: Improvements to the documentation. | ||
- style: Formatting, missing semi colons, etc; no code change. | ||
- refactor: Refactoring code without changing behaviour. | ||
- perf: Code refactoring focused on improving performance. | ||
- test: Adding missing tests, refactoring tests; no production code change. | ||
- ci: CI related changes. These changes are not published in the changelog. | ||
- chore: Updating build tasks, package manager configs, etc. These changes are not published in the changelog. | ||
- revert: Reverting previous commits. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters