From 041acf2a65ac6c6587f6c664a952bc9379a60adf Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 15 Aug 2022 13:59:42 +0100 Subject: [PATCH] CONTRIBUTING.md: Add sample pre-commit hook If contributors add this pre-commit hook we should have fewer issues with build churn on our CI as the most basic checks will pass. Signed-off-by: Rob Bradford --- CONTRIBUTING.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 67a4a72aa..a740e99ea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,6 +17,23 @@ We follow the [Rust Style](https://github.com/rust-dev-tools/fmt-rfcs/blob/maste convention and enforce it through the Continuous Integration (CI) process calling into `rustfmt` for each submitted Pull Request (PR). +## Basic Checks + +Please consider creating the following hook as `.git/hooks/pre-commit` in order +to ensure basic correctness of your code. You can extend this further if you +have specific features that you regularly develop against. + +```sh +#!/bin/sh + +cargo fmt -- --check || exit 1 +cargo check --locked --all --all-targets --tests || exit 1 +cargo clippy --locked --all --all-targets --tests -- -D warnings || exit 1 +``` + +You will need to `chmod +x .git/hooks/pre-commit` to have it run on every +commit you make. + ## Certificate of Origin In order to get a clear contribution chain of trust we use the [signed-off-by language](https://01.org/community/signed-process)