add codespell

This commit is contained in:
liying@espressif.com
2025-11-25 15:54:00 +08:00
parent d412ac601b
commit 93be4b125a
5 changed files with 42 additions and 1 deletions

3
.codespellrc Normal file
View File

@@ -0,0 +1,3 @@
[codespell]
skip = build,*.drawio,*.svg,*.pdf
write-changes = true

4
.gitignore vendored
View File

@@ -41,4 +41,6 @@ docs/doxygen_sqlite3.db
.settings
# MacOS directory files
.DS_Store
.DS_Store
docs/_build/

View File

@@ -1,4 +1,5 @@
stages:
- check
- build
- deploy
@@ -83,6 +84,9 @@ push_master_to_github:
# and then pushes that ref to a corresponding github branch
- eval $(git for-each-ref --shell bash --format 'if [ $CI_COMMIT_SHA == %(objectname) ]; then git checkout -B %(refname:strip=3); git push --follow-tags github %(refname:strip=3); fi;' $GITHUB_PUSH_REFS)
include:
- local: tools/ci/pre_commit.yml
build_docs:
stage: build
image: $ESP_IDF_DOC_ENV_IMAGE

6
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
args: [--config=.codespellrc]

26
tools/ci/pre_commit.yml Normal file
View File

@@ -0,0 +1,26 @@
.check_pre_commit_template:
stage: check # or "pre-check", depending on your pipeline structure
image: python:3.8
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Run this job only for merge request pipelines.
script:
- pip install pre-commit
- git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME --depth=1 # Fetch target branch latest commit
- git fetch origin $CI_COMMIT_REF_NAME --depth=1 # Fetch source branch latest commit
- |
echo "Target branch: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
echo "Source branch: $CI_COMMIT_REF_NAME"
MODIFIED_FILES=$(git diff --name-only origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME..origin/$CI_COMMIT_REF_NAME)
echo "Modified files to check:"
echo "$MODIFIED_FILES"
if [ -n "$MODIFIED_FILES" ]; then
CI=true pre-commit run --files $MODIFIED_FILES
else
echo "No modified files to check."
fi
check_pre_commit:
extends:
- .check_pre_commit_template # All configured pre-commit hooks will run under this job