mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 11:03:05 +00:00
ci: remove redundant check_typos job, superseded by pre_commit_check
This commit is contained in:
@@ -1,49 +0,0 @@
|
|||||||
# Copyright 2025 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
name: Check Typos
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- 'release/**'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check_typos:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.x'
|
|
||||||
- name: Install codespell
|
|
||||||
run: pip install codespell
|
|
||||||
- name: Fetch main branch
|
|
||||||
run: git fetch origin main
|
|
||||||
- name: Check typos in changed files
|
|
||||||
run: |
|
|
||||||
FILES=$(git diff --name-only origin/main...HEAD)
|
|
||||||
echo "Changed files: $FILES"
|
|
||||||
if [ -n "$FILES" ]; then
|
|
||||||
./tools/check_typos.sh $FILES
|
|
||||||
else
|
|
||||||
echo "No files changed, skipping typo check"
|
|
||||||
fi
|
|
||||||
+1
-19
@@ -248,7 +248,6 @@ build_image:
|
|||||||
needs:
|
needs:
|
||||||
- job: build_image
|
- job: build_image
|
||||||
optional: true
|
optional: true
|
||||||
- job: check_typos
|
|
||||||
- job: pre_commit_check
|
- job: pre_commit_check
|
||||||
tags:
|
tags:
|
||||||
- build
|
- build
|
||||||
@@ -645,7 +644,6 @@ build_managed_component_light:
|
|||||||
needs:
|
needs:
|
||||||
- job: build_image
|
- job: build_image
|
||||||
optional: true
|
optional: true
|
||||||
- job: check_typos
|
|
||||||
- job: pre_commit_check
|
- job: pre_commit_check
|
||||||
script:
|
script:
|
||||||
- cd ${ESP_MATTER_PATH}/examples/managed_component_light
|
- cd ${ESP_MATTER_PATH}/examples/managed_component_light
|
||||||
@@ -681,7 +679,6 @@ build_esp_rainmaker_apps:
|
|||||||
needs:
|
needs:
|
||||||
- job: build_image
|
- job: build_image
|
||||||
optional: true
|
optional: true
|
||||||
- job: check_typos
|
|
||||||
- job: pre_commit_check
|
- job: pre_commit_check
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
@@ -723,7 +720,7 @@ build_docs:
|
|||||||
tags:
|
tags:
|
||||||
- build
|
- build
|
||||||
needs:
|
needs:
|
||||||
- job: check_typos
|
- job: pre_commit_check
|
||||||
variables:
|
variables:
|
||||||
ESP_DOCS_LATEST_BRANCH_NAME: "main"
|
ESP_DOCS_LATEST_BRANCH_NAME: "main"
|
||||||
artifacts:
|
artifacts:
|
||||||
@@ -786,21 +783,6 @@ deploy_docs_production:
|
|||||||
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
|
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
|
||||||
DOCS_DEPLOY_URL_BASE: "https://$DOCS_PROD_SERVER/$DOCS_PROD_PATH"
|
DOCS_DEPLOY_URL_BASE: "https://$DOCS_PROD_SERVER/$DOCS_PROD_PATH"
|
||||||
|
|
||||||
check_typos:
|
|
||||||
image: $CI_DOCKER_REGISTRY/esp-env-v6.0:1
|
|
||||||
stage: pre_check
|
|
||||||
script:
|
|
||||||
- pip install codespell
|
|
||||||
- git fetch origin main
|
|
||||||
- |
|
|
||||||
FILES=$(git diff --name-only origin/main...HEAD)
|
|
||||||
echo "change files: $FILES"
|
|
||||||
if [ -n "$FILES" ]; then
|
|
||||||
./tools/check_typos.sh $FILES
|
|
||||||
fi
|
|
||||||
tags:
|
|
||||||
- build
|
|
||||||
|
|
||||||
pre_commit_check:
|
pre_commit_check:
|
||||||
image: $CI_DOCKER_REGISTRY/esp-env-v6.0:1
|
image: $CI_DOCKER_REGISTRY/esp-env-v6.0:1
|
||||||
stage: pre_check
|
stage: pre_check
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Usage: tools/check_typos.sh [source_file_or_directory] ...
|
|
||||||
|
|
||||||
CODESPELL_SKIP_LIST=()
|
|
||||||
ERROR_FOUND=0
|
|
||||||
|
|
||||||
parse_codespellrc_skips() {
|
|
||||||
if [ -f .codespellrc ]; then
|
|
||||||
local skip_files
|
|
||||||
skip_files=$(grep -E "^skip\s*=" .codespellrc | cut -d '=' -f2 | tr -d ' ')
|
|
||||||
IFS=',' read -ra CODESPELL_SKIP_LIST <<< "$skip_files"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
should_skip_file() {
|
|
||||||
local file_path="$1"
|
|
||||||
for pattern in "${CODESPELL_SKIP_LIST[@]}"; do
|
|
||||||
if [[ "$file_path" == $pattern* ]]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
process_file() {
|
|
||||||
local SRC_FILE="$1"
|
|
||||||
cat "$SRC_FILE" | \
|
|
||||||
python3 -c "
|
|
||||||
import sys, re
|
|
||||||
ignore_directive = re.compile(r\"[^\w\s]\s*codespell:ignore\b\")
|
|
||||||
def split_line(line):
|
|
||||||
if ignore_directive.search(line):
|
|
||||||
return line.rstrip()
|
|
||||||
tokens = re.findall(r\"\b[\w']+\b\", line)
|
|
||||||
result = []
|
|
||||||
for token in tokens:
|
|
||||||
if \"'\" in token:
|
|
||||||
result.append(token)
|
|
||||||
else:
|
|
||||||
result.extend(re.findall(r\"\d+[a-zA-Z]+|[A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+\", token))
|
|
||||||
return \" \".join(result)
|
|
||||||
for line in sys.stdin:
|
|
||||||
print(split_line(line))
|
|
||||||
" | codespell --check-hidden --stdin-single-line -q 32 - 2>&1 | sed "s|^|$SRC_FILE: |"
|
|
||||||
if [ "${PIPESTATUS[2]}" -ne 0 ]; then
|
|
||||||
ERROR_FOUND=1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
is_valid_file() {
|
|
||||||
local file="$1"
|
|
||||||
|
|
||||||
case "$file" in
|
|
||||||
*.c|*.h|*.cpp|*.py|*.txt|*.md|*.yml|*.ini|*.json|*.sh|*.cmake) ;;
|
|
||||||
*) return 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if should_skip_file "$file"; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
process_directory() {
|
|
||||||
local DIR="$1"
|
|
||||||
local file
|
|
||||||
|
|
||||||
find "$DIR" -type f | while read -r file; do
|
|
||||||
if is_valid_file "$file"; then
|
|
||||||
process_file "$file"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local TARGETS=("$@")
|
|
||||||
|
|
||||||
parse_codespellrc_skips
|
|
||||||
|
|
||||||
if [ "$#" -eq 0 ]; then
|
|
||||||
TARGETS=(./components ./examples)
|
|
||||||
fi
|
|
||||||
|
|
||||||
for TARGET in "${TARGETS[@]}"; do
|
|
||||||
if [ -f "$TARGET" ]; then
|
|
||||||
if is_valid_file "$TARGET"; then
|
|
||||||
process_file "$TARGET"
|
|
||||||
fi
|
|
||||||
elif [ -d "$TARGET" ]; then
|
|
||||||
process_directory "$TARGET"
|
|
||||||
else
|
|
||||||
echo "Warning: '$TARGET' is not a valid file or directory, skipping"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$ERROR_FOUND" == "1" ]; then
|
|
||||||
echo "Typos found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
Reference in New Issue
Block a user