We generally follow the GitHub flow in our project. In a nutshell, this requires the following steps to contribute:
- Fork the repository (only required if you don't have write access to the repository).
- Create a feature branch.
- Make changes and create a commit
- Push your changes to GitHub and create a pull request (PR); note that we enforce a particular style for the PR titles, see below.
- Wait for maintainers to review your changes and, if necessary, revise your PR.
- When all requirements are met, a reviewer or the PR author (if they have write permissions) can merge the PR.
To ensure a consistent Git history (from which we can later easily generate changelogs automatically), we always squash commits when merging a PR and enforce that all PR titles comply with the conventional-commit format. For examples, please take a look at our commit history.
We have CI jobs running for every PR to test and lint the repository. You can install Git pre-commit hooks to ensure that these check pass even before pushing your changes to GitHub. To use this, the following steps are required:
- Install Rust.
- Install pre-commit using
pip
or your OS's package manager. - Run
pre-commit install
in the repository.
After this setup, the code will be checked, reformatted, and tested whenever you create a Git commit.
You can also use a custom pre-commit configuration if you wish:
- Create a file
.custom-pre-commit-config.yaml
(this is set to be ignored by Git). - Run
pre-commit install -c .custom-pre-commit-config.yaml
.
We use a few unstable formatting options of Rustfmt. Unfortunately, these can only be used with a
stable toolchain when specified via the --config
command-line option. This is done in
CI and in our pre-commit hooks (see also
above).
If you want the same behavior in your IDE, you need to modify the corresponding formatting setting.
For example, when using rust-analyzer
with VSCode, you need to add the following to your
settings.json
:
"rust-analyzer.rustfmt.extraArgs": [
"--config",
"group_imports=StdExternalCrate,imports_granularity=Crate,imports_layout=HorizontalVertical"
]
Also make sure you use the correct version of Rustfmt. See rust-toolchain.toml for the current version. This also impacts other checks, for example Clippy.
The majority of our code is covered by automatic unit and integration tests which you can run
through cargo test
.
Integration and end-to-end tests are excluded by default when running cargo test
as they depend on
additional packages and take longer to run. You can run these test as follows:
cargo test -- --ignored
We appreciate it if you configure Git to sign your commits.