From 095fd1129fe0c4b6aca5d2e4832f423e5415fa48 Mon Sep 17 00:00:00 2001 From: Madhu Kanoor Date: Thu, 14 Sep 2023 16:41:00 -0400 Subject: [PATCH] chore: added pre-commit hooks commitlint, black, flake8 Added pre-commit hooks for commitlint, black and flake8 --- .github/workflows/python_package.yml | 4 +++- .pre-commit-config.yaml | 29 ++++++++++++++++++++++++++++ README.md | 5 +++-- pyproject.toml | 1 + 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/python_package.yml b/.github/workflows/python_package.yml index c2a4d1f..4202a19 100644 --- a/.github/workflows/python_package.yml +++ b/.github/workflows/python_package.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Install Java + - name: Install Java uses: actions/setup-java@v3 with: distribution: 'zulu' @@ -36,6 +36,8 @@ jobs: run: black --check . - name: Run isort run: isort --check . + - name: Run commitlint + uses: wagoid/commitlint-github-action@v5 - name: Install package run: python3 -m build - name: Run tox diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9300dc7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - repo: https://github.com/psf/black + rev: 22.6.0 + hooks: + - id: black + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + - repo: https://github.com/pycqa/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + additional_dependencies: + - flake8-bugbear + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.5.0 + hooks: + - id: commitlint + stages: [commit-msg] diff --git a/README.md b/README.md index ef43345..033a24a 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Needs * Java 17+ * Maven 3.8.1+ * Environment variable **JAVA_HOME** should be set appropriately + * Uses conventional commit. commitlint (use **npm install commitlint**) # Setup and Testing @@ -14,8 +15,8 @@ Needs python3 -m pip install --upgrade pip python3 -m pip install --upgrade build python3 -m pip install -e '.[dev]' + pre-commit install tox - python3 -m build ``` # Check code coverage @@ -31,7 +32,7 @@ Needs ``` black . flake8 . - isort . + isort . ``` # To publish the package to PyPi diff --git a/pyproject.toml b/pyproject.toml index f61779c..1be52f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,7 @@ local = [ 'isort', 'tox', 'pyyaml', + 'pre-commit', ] tests = [ 'coverage>=5.0.3',