Skip to content

Commit

Permalink
chore: add commitlint
Browse files Browse the repository at this point in the history
The commit messages have to conform to the conventional commit
standard.
https://www.conventionalcommits.org/en/v1.0.0/
  • Loading branch information
mkanoor committed Sep 1, 2023
1 parent 98345aa commit 7c3b1b7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
1 change: 1 addition & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.conventionalcommits.org/en/v1.0.0/>`__


Submit Feedback
Expand Down
36 changes: 12 additions & 24 deletions docs/development_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.
Expand All @@ -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 <https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks>`_.
This project provides a configuration for `pre-commit <https://pre-commit.com/>`_
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:

Expand Down
2 changes: 2 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ coverage

# For building DEs
ansible-builder

pre-commit

0 comments on commit 7c3b1b7

Please sign in to comment.