From 0fba23087fdb9cbbb63e64feffa730159ebed492 Mon Sep 17 00:00:00 2001 From: Ivan <45982459+ivntsng@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:02:19 -0700 Subject: [PATCH] Documentation for pre-commit (#474) * test * Added documentation for pre-commit --- .gitignore | 3 +++ CONTRIBUTING.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/.gitignore b/.gitignore index 4aa501bd..ec5017e2 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ out*/ # .DS_Store .DS_Store + +# pre-commit +.pre-commit-config.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1db4090d..d327a9c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -223,3 +223,31 @@ make test make test-frontend # Run only the frontend tests make test-backend # Run only the backend tests ``` + +## Optional + +Install pre-commit from [here](https://pre-commit.com/) to run the formatting and static checks automatically when you commit. + +Here's the pre-commit yaml configuration: + +```yaml +fail_fast: true +repos: + - repo: local + hooks: + - id: format + name: Format + entry: bash -c 'make format || (echo "❌ Formatting failed. Please run make format manually and commit the changes." && exit 1) && git diff --exit-code || (echo "❌ Formatting failed but formatted file. Please add and commit again." && exit 1)' + language: system + pass_filenames: false + - id: static-checks + name: Static Checks + entry: bash -c 'make static-checks || (echo "❌ Static checks failed. Please fix the issues and try again." && exit 1)' + language: system + pass_filenames: false + - id: test + name: Run Tests + entry: bash -c 'make test || (echo "❌ Tests failed. Please fix the failing tests and try again." && exit 1)' + language: system + pass_filenames: false +```