From 7c3b1b791443221f3e07efb317d16c8cbb11256c Mon Sep 17 00:00:00 2001 From: Madhu Kanoor Date: Wed, 30 Aug 2023 13:22:48 -0400 Subject: [PATCH] chore: add commitlint The commit messages have to conform to the conventional commit standard. https://www.conventionalcommits.org/en/v1.0.0/ --- .github/workflows/ci.yml | 9 ++++++++ .pre-commit-config.yaml | 5 +++++ docs/contributing.rst | 1 + docs/development_environment.rst | 36 +++++++++++--------------------- requirements_dev.txt | 2 ++ 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f1e9cae..783dfd4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,15 @@ on: workflow_dispatch: jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: run commitlint + uses: wagoid/commitlint-github-action@v5 + flake8: runs-on: ubuntu-latest steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6748b7c0..7cbf129d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,3 +33,8 @@ repos: - id: pretty-format-json language_version: python3 args: ['--autofix', '--no-sort-keys', '--indent', '4'] + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.5.0 + hooks: + - id: commitlint + stages: [commit-msg] diff --git a/docs/contributing.rst b/docs/contributing.rst index 84f3d3df..641ecb14 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -53,6 +53,7 @@ Before you submit a pull request, check that it meets these guidelines: your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 3.9 +4. Commit messages must conform to `conventional commit `__ Submit Feedback diff --git a/docs/development_environment.rst b/docs/development_environment.rst index c9aaf242..d05c9039 100644 --- a/docs/development_environment.rst +++ b/docs/development_environment.rst @@ -29,6 +29,7 @@ Ready to contribute? Here's how to set up `ansible_rulebook` for local developme pip install -e . pip install -r requirements_dev.txt ansible-galaxy collection install ansible.eda + npm install commitlint 5. Create a branch for local development: @@ -50,11 +51,15 @@ Now you can make your changes locally. To get flake8 and tox, just pip install them into your virtualenv. 7. Commit your changes and push your branch to GitHub: + We follow the conventionalcommit_ standards for commit message + During the pre-commit phase we will validate the commit message + +.. _conventionalcommit : https://www.conventionalcommits.org/en/v1.0.0/ .. code-block:: console git add . - git commit -m "Your detailed description of your changes." + git commit -m "fix: title about the bug fix" git push origin name-of-your-bugfix-or-feature 8. Submit a pull request through the GitHub website. @@ -74,33 +79,16 @@ The dockerfile points to the required collection_ of ansible which provides sour -Git pre-commit hooks (optional) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Git pre-commit hooks +~~~~~~~~~~~~~~~~~~~~ -To automatically run linters and code formatter you may use +To automatically run linters and code formatter we use `git pre-commit hooks `_. This project provides a configuration for `pre-commit `_ -framework to automatically setup hooks for you. - -1. First install the ``pre-commit`` tool: - - a. Into your virtual environment: - - .. code-block:: console - - pip install pre-commit - - b. Into your user directory: - - .. code-block:: console - - pip install --user pre-commit - - c. Via ``pipx`` tool: - - .. code-block:: console +framework to automatically setup hooks for you. Using the pre-commit is recommended +to conform to the PR guidelines. - pipx install pre-commit +1. The pre-commit package is installed when you create the dev env (Step 4 above) 2. Then generate git pre-commit hooks: diff --git a/requirements_dev.txt b/requirements_dev.txt index ea791ae6..aaec948b 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -14,3 +14,5 @@ coverage # For building DEs ansible-builder + +pre-commit