From 6d3ba6b507aa5997d23d9c0d991b09b970c6e2a8 Mon Sep 17 00:00:00 2001 From: Yihuang Yu Date: Thu, 16 Oct 2025 17:43:19 +0800 Subject: [PATCH 1/2] feat: skip pylint when configuration file is missing Change check-lint script behavior to exit gracefully when pylint configuration file is not found, rather than running with default config on all files. Signed-off-by: Yihuang Yu --- check-lint | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/check-lint b/check-lint index 72c2ccf..104b4db 100755 --- a/check-lint +++ b/check-lint @@ -87,13 +87,9 @@ if [ -f "$CONFIG_FILE" ]; then fi done < "$CONFIG_FILE" else - # If the configuration file does not exist, print a message and use default config for all files - echo "Configuration file '$CONFIG_FILE' not found. Running $TOOL_NAME with default config on all files..." - if ! $TOOL_CMD --rcfile="$DEFAULT_CONFIG_PATH" $ALL_FILES; then - overall_exit_status=1 # Set to 1 if there were any issues - fi - - exit $overall_exit_status + # If the configuration file does not exist, print a message and exit + echo "Configuration file '$CONFIG_FILE' not found. Skipping pylint." + exit 0 fi # Calculate remaining files that weren't checked with a custom config From 8ce0939e7d8b0267ecd6e7bbeff7687e0a7ced14 Mon Sep 17 00:00:00 2001 From: Yihuang Yu Date: Fri, 15 Aug 2025 11:26:38 +0800 Subject: [PATCH 2/2] chore: add pre-commit hooks and commitlint configuration - Add comprehensive pre-commit configuration with hooks for: - Code quality checks (black, isort, pylint, codespell) - Security scanning (gitleaks) - Line ending and whitespace fixes - Add commitlint configuration with conventional commit format - Configure signed-off-by trailer requirement for commits Signed-off-by: Yihuang Yu --- .pre-commit-config.yaml | 49 +++++++++++++++++++++++++++++++++++++++++ commitlint.config.ts | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 commitlint.config.ts diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..2f09c5d --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 +- 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] diff --git a/commitlint.config.ts b/commitlint.config.ts new file mode 100644 index 0000000..cd0f618 --- /dev/null +++ b/commitlint.config.ts @@ -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 +