-
Notifications
You must be signed in to change notification settings - Fork 4
chore: add pre-commit hooks and commitlint configuration #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
default_install_hook_types: [pre-commit, commit-msg] | ||
default_stages: [pre-commit] | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v6.0.0 | ||
hooks: | ||
- id: check-added-large-files | ||
args: ['--maxkb=5120'] | ||
- id: check-ast | ||
- id: end-of-file-fixer | ||
- id: mixed-line-ending | ||
args: ['--fix=lf'] | ||
- id: no-commit-to-branch | ||
- id: trailing-whitespace | ||
exclude: '\.(md|rst)$' | ||
- repo: https://github.com/gitleaks/gitleaks | ||
rev: v8.28.0 | ||
hooks: | ||
- id: gitleaks | ||
- repo: https://github.com/pycqa/isort | ||
rev: 7.0.0 | ||
hooks: | ||
- id: isort | ||
args: ['--profile=black'] | ||
- repo: https://github.com/psf/black | ||
rev: 25.9.0 | ||
hooks: | ||
- id: black | ||
- repo: local | ||
hooks: | ||
- id: pylint | ||
name: pylint | ||
entry: static-checks/check-lint | ||
language: python | ||
additional_dependencies: | ||
- pylint==4.0.0 | ||
pass_filenames: false | ||
Comment on lines
+31
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainDocument submodule path requirement and verify Python environment usage. The Additionally, the check-lint script uses Consider one of the following approaches:
Run this script to check how pre-commit sets up the environment: 🏁 Script executed: #!/bin/bash
# Verify pre-commit Python environment setup
echo "Checking pre-commit hook configuration..."
# Check if check-lint script exists
if [ -f "check-lint" ]; then
echo "✓ Found check-lint script"
# Check the python command used
if grep -q "python3 -m" check-lint; then
echo "⚠ Script uses 'python3 -m pylint' which may not use pre-commit's virtualenv"
echo " Consider changing to 'python -m pylint' to use the virtualenv Python"
fi
else
echo "✗ check-lint not found in root"
echo " This is expected if it's in a submodule at static-checks/"
fi
# Verify the pre-commit config structure
if [ -f ".pre-commit-config.yaml" ]; then
echo "✓ Found .pre-commit-config.yaml"
# Check for the pylint hook configuration
if grep -A 5 "id: pylint" .pre-commit-config.yaml | grep -q "language: python"; then
echo "✓ Pylint hook uses language: python (creates virtualenv)"
fi
if grep -A 5 "id: pylint" .pre-commit-config.yaml | grep -q "static-checks/check-lint"; then
echo "⚠ Entry path assumes submodule at static-checks/"
fi
fi Length of output: 352
Length of output: 674 Fix broken pylint hook entry and ensure venv Python is used
🤖 Prompt for AI Agents
|
||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.4.1 | ||
hooks: | ||
- id: codespell | ||
args: ['-I=spell.ignore'] | ||
exclude: 'static-checks/.*' | ||
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook | ||
rev: v9.23.0 | ||
hooks: | ||
- id: commitlint | ||
additional_dependencies: ['@commitlint/config-conventional'] | ||
stages: [commit-msg] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { UserConfig } from '@commitlint/types' | ||
|
||
const config: UserConfig = { | ||
extends: ['@commitlint/config-conventional'], | ||
rules: { | ||
// Body | ||
'body-leading-blank': [2, 'always'], | ||
'body-empty': [0, 'never'], | ||
'body-min-length': [0, 'always', 1], | ||
'body-case': [0, 'always', 'lower-case'], | ||
|
||
// Footer | ||
'footer-leading-blank': [2, 'always'], | ||
'footer-empty': [0, 'never'], | ||
'footer-max-length': [0, 'always', 72], | ||
|
||
// Header | ||
'header-case': [0, 'always', 'lower-case'], | ||
'header-full-stop': [2, 'never', '.'], | ||
'header-max-length': [2, 'always', 72], | ||
'header-min-length': [2, 'always', 1], | ||
|
||
// Scope / Subject | ||
'scope-case': [0, 'always', 'lower-case'], | ||
'scope-empty': [0, 'always'], | ||
'subject-case': [0, 'always', 'lower-case'], | ||
'subject-empty': [0, 'never'], | ||
'subject-full-stop': [2, 'never', '.'], | ||
|
||
// Type | ||
'type-case': [0, 'always', 'lower-case'], | ||
'type-empty': [0, 'always'], | ||
'type-enum': [0, 'always', []], | ||
|
||
// Signed-off-by | ||
'signed-off-by': [2, 'always', 'Signed-off-by:'], | ||
}, | ||
helpUrl: | ||
'https://avocado-framework.readthedocs.io/en/latest/guides/contributor/chapters/styleguides.html#commit-style-guide', | ||
} | ||
|
||
export default config | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we are using black version 22.3.0, but probably we can do update with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your confirmation. Indeed, IIRC,
22.3.0
is to keep maintain the compatibility of python3.8, as we dropped its support, so I hope we can upgrade some toolchains to align tool's bug fix or style rules.E.g.
22.3.0
will format multiple string line but has an issue likeWe can consider which version to use, not necessarily the latest version I put here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure we can upgrade to the latest version