From 93be4b125a7b3e9a7e2ae8a61bef4723b36054e0 Mon Sep 17 00:00:00 2001 From: "liying@espressif.com" Date: Tue, 25 Nov 2025 15:54:00 +0800 Subject: [PATCH] add codespell --- .codespellrc | 3 +++ .gitignore | 4 +++- .gitlab-ci.yml | 4 ++++ .pre-commit-config.yaml | 6 ++++++ tools/ci/pre_commit.yml | 26 ++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .codespellrc create mode 100644 .pre-commit-config.yaml create mode 100644 tools/ci/pre_commit.yml diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 00000000..e7de85c5 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,3 @@ +[codespell] +skip = build,*.drawio,*.svg,*.pdf +write-changes = true \ No newline at end of file diff --git a/.gitignore b/.gitignore index ac4dec2e..4ee09075 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,6 @@ docs/doxygen_sqlite3.db .settings # MacOS directory files -.DS_Store \ No newline at end of file +.DS_Store + +docs/_build/ \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ede03ce8..616cb6f0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..76131163 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: + - repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell + args: [--config=.codespellrc] \ No newline at end of file diff --git a/tools/ci/pre_commit.yml b/tools/ci/pre_commit.yml new file mode 100644 index 00000000..8df58278 --- /dev/null +++ b/tools/ci/pre_commit.yml @@ -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 \ No newline at end of file