From 523c7b157f27363f8501b3c7b2c52ae1bea082a2 Mon Sep 17 00:00:00 2001 From: Damiano Amatruda <damiano.amatruda@skywarder.eu> Date: Tue, 7 Dec 2021 02:31:47 +0100 Subject: [PATCH] Add pre-commit hook --- .pre-commit-config.yaml | 49 +++++++++++++++++++++++++++++++++++++++++ README.md | 12 ++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..6877fbd4a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,49 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://gitlab.com/daverona/pre-commit/cpp + rev: 0.8.0 + hooks: + - id: cppcheck + args: [ + --quiet, + --language=c++, + --enable=all, + --inline-suppr, + --suppress=unusedFunction, + --suppress=missingInclude + ] + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v13.0.0 + hooks: + - id: clang-format + args: [ + --dry-run, + --Werror + ] + - repo: local + hooks: + - id: copyright + name: Copyright + entry: scripts/linter.py + args: [ + --copyright, + src + ] + pass_filenames: false + language: python + - repo: local + hooks: + - id: find + name: Find + entry: scripts/linter.py + args: [ + --find, + src + ] + pass_filenames: false + language: python diff --git a/README.md b/README.md index 962ea8630..aa7d817f1 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ In the main folder you will find **CMakeLists.txt** which is used to configure t * Git * Miosix Toolchain -Also, Ccache, Ninja, OpenOCD, Cppcheck and clang-format are recommended for a better experience. +Also, Ccache, Ninja, OpenOCD, Cppcheck, clang-format and pre-commit are recommended for a better experience. #### Cloning the repo @@ -53,12 +53,20 @@ cmake --build . ``` Or using the SBS wrapper script: -``` +```sh ./sbs ``` The build system will start building all the targets (entrypoints and tests). Depending on how many targets there are, this operation may take several minutes. +### Contributing + +You can install a pre-commit hook to ensure changes to the code will pass CI: + +```sh +pre-commit install +``` + ### What's next? In the [Wiki](https://git.skywarder.eu/scs/skyward-boardcore/wikis/home) you will find some first-steps **guides** (configuring the IDE, building a firmware, etc.) as well as the **coding guidelines** and some **best practices** we adopt. -- GitLab