|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thank you for taking an interest in the project! Described below is what you need |
| 4 | +to get up to speed with this program. |
| 5 | + |
| 6 | +## Table of contents |
| 7 | + |
| 8 | +<details> |
| 9 | +<summary>Expand</summary> |
| 10 | + |
| 11 | +- [Build](#build) |
| 12 | +- [Test](#test) |
| 13 | +- [Local Dev](#local-dev) |
| 14 | +- [Documentation](#documentation) |
| 15 | +- [Style](#style) |
| 16 | + - [Format](#format) |
| 17 | + - [Linting](#linting) |
| 18 | + - [Code documentation](#code-documentation) |
| 19 | + - [Git hygiene](#git-hygiene) |
| 20 | + - [Conventional commits](#conventional-commits) |
| 21 | + |
| 22 | +</details> |
| 23 | + |
| 24 | +## Build |
| 25 | + |
| 26 | +Building the project locally is as easy as `cargo build`, and you can just as easily |
| 27 | +run the project via `cargo run` (ctrl+c to exit). |
| 28 | + |
| 29 | +## Test |
| 30 | + |
| 31 | +Testing the entire project can be done via `cargo test --all-features` from the |
| 32 | +repo root. |
| 33 | + |
| 34 | +Note that our current convention is to _avoid_ writing unit tests. We only write functional tests. |
| 35 | +(`cargo test` calls these "integration tests".) |
| 36 | +We believe unit tests slow you down when refactoring, don't provide regression |
| 37 | +safety because they require changes whenever you change the related code, and ultimately only become |
| 38 | +a maintenance burden that yields very little benefit. We test from the program interface level, |
| 39 | +which are the REST and websocket API. |
| 40 | + |
| 41 | +## Local Dev |
| 42 | + |
| 43 | +While working on code locally sometimes is convenient to have a hot reload to improve code changes and build time. Rust on it's own doesn't provide |
| 44 | +a hot reload mechanism but community has built [cargo-watch](https://crates.io/crates/cargo-watch) as a plugin for cargo. |
| 45 | + |
| 46 | +## Documentation |
| 47 | + |
| 48 | +You can generate and open this repo's full documentation via: |
| 49 | + |
| 50 | +``` |
| 51 | +cargo +nightly doc --all-features --document-private-items --open |
| 52 | +``` |
| 53 | + |
| 54 | +_NOTE:_ You must have a nightly toolchain installed (`rustup install nightly`). |
| 55 | + |
| 56 | +## Style |
| 57 | + |
| 58 | +### Format |
| 59 | + |
| 60 | +This project uses [`rustfmt`](https://github.com/rust-lang/rustfmt) for code formatting. |
| 61 | +You can format your code via: |
| 62 | + |
| 63 | +```bash |
| 64 | +cargo +nightly fmt --all |
| 65 | +``` |
| 66 | + |
| 67 | +### Linting |
| 68 | + |
| 69 | +This project uses [`clippy`](https://github.com/rust-lang/rust-clippy) for linting, and |
| 70 | +it's enforced by CI. You can run it locally via: |
| 71 | + |
| 72 | +```bash |
| 73 | +cargo clippy |
| 74 | +``` |
| 75 | + |
| 76 | +### Code documentation |
| 77 | + |
| 78 | +All of a crate's public items are expected to be properly documented via Rust |
| 79 | +[doc comments](https://doc.rust-lang.org/rust-by-example/meta/doc.html#documentation). |
| 80 | +Private items are more flexible, but should still be documented unless the item's |
| 81 | +purpose is obvious. |
| 82 | + |
| 83 | +### Git hygiene |
| 84 | + |
| 85 | +This repo expects expressive commits where 1 commit = 1 logical change, with a |
| 86 | +clear status message and body explaining the purpose of the commit. |
| 87 | + |
| 88 | +We use [conventional commits](https://www.conventionalcommits.org) which are enforced by CI. |
0 commit comments