COMMIT_LINT.md
This document explains how to run the commit message linter locally to validate your commits before pushing.
The commit prefix checker (commit_prefix_check.py) validates commit messages according to Fluent Bit standards:
Install the required Python dependency:
pip install gitpython
From the repository root directory, run:
python .github/scripts/commit_prefix_check.py
GITHUB_EVENT_NAME environment variable is set to pull_request, it validates only commits that are part of the PR:
GITHUB_BASE_REF environment variable to be set (automatically set in CI)0 if validation passes1 if validation failsSuccess:
✅ Commit prefix validation passed.
Failure:
❌ Commit deadbeef12 failed:
Subject prefix 'wrong_prefix:' does not match files changed.
Expected one of: router:
Commit prefix validation failed.
The commit linter has comprehensive unit tests. To run them:
Install the test dependencies:
pip install pytest gitpython
From the repository root directory, run:
# Run all tests
pytest .github/scripts/tests/test_commit_lint.py -v
# Run a specific test
pytest .github/scripts/tests/test_commit_lint.py::test_valid_commit_single_prefix -v
# Run with more detailed output
pytest .github/scripts/tests/test_commit_lint.py -v -s
Alternatively, you can run from the scripts directory:
cd .github/scripts
pytest tests/test_commit_lint.py -v
The test suite covers:
To test a specific commit, you can temporarily checkout that commit:
# Checkout the commit you want to test
git checkout <commit-hash>
# Run the validator
python .github/scripts/commit_prefix_check.py
# Return to your branch
git checkout <your-branch>
This script is automatically run in CI via the .github/workflows/commit-lint.yaml workflow on:
master branchSee CONTRIBUTING.md for the full commit message format requirements.