diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6197ec1..bd766c5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -157,6 +157,35 @@ after_script: - ${IDF_PATH}/tools/idf_tools.py --non-interactive install esp-clang - . $IDF_PATH/export.sh +.check_pre_commit_template: + stage: pre_check + image: $ESP_DOCS_ENV_IMAGE + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + script: + - pip install pre-commit + - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME --depth=1 + - git fetch origin $CI_COMMIT_REF_NAME --depth=1 + - | + 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 | tr '\n' ' ') + 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 + needs: [] + after_script: [] + build_static_analyzer_idf_latest: tags: - build diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ef303d0..a9241ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper'] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 + rev: v5.0.0 hooks: - id: trailing-whitespace # Removes trailing whitespaces from lines exclude: &whitespace_excludes | @@ -45,6 +45,7 @@ repos: rev: v2.4.1 hooks: - id: codespell # Code spell checker + stages: [pre-commit] args: ["--write-changes"] additional_dependencies: [tomli] exclude: | diff --git a/test_apps/unit_tests/test_config_parser/main/test_config_parser.c b/test_apps/unit_tests/test_config_parser/main/test_config_parser.c index 326ab7f..c93da81 100644 --- a/test_apps/unit_tests/test_config_parser/main/test_config_parser.c +++ b/test_apps/unit_tests/test_config_parser/main/test_config_parser.c @@ -31,7 +31,7 @@ TEST_CASE("Test tcp configuration parser.", "[MB_CONFIGURATION]") TEST_ASSERT(uid_info.port == 502); free(uid_info.node_name_str); - // UID, Hostname, Port, the incorect UID provided (only decimal representation is supported) + // UID, Hostname, Port, the incorrect UID provided (only decimal representation is supported) result = port_scan_addr_string("c8;mb_slave_tcp_c8;1502", &uid_info); TEST_ASSERT(uid_info.node_name_str); printf("Test config parser result: %d, index: %d, host: %s, port: %d \r\n", result, uid_info.uid, uid_info.node_name_str, uid_info.port); @@ -42,7 +42,7 @@ TEST_CASE("Test tcp configuration parser.", "[MB_CONFIGURATION]") TEST_ASSERT(uid_info.port == 502); // default port free(uid_info.node_name_str); - // UID, Hostname, Port, the incorect host name + // UID, Hostname, Port, the incorrect host name result = port_scan_addr_string("15;mb_slave**_tcp_c8;1502", &uid_info); TEST_ASSERT(uid_info.node_name_str); printf("Test config parser result: %d, index: %d, host: %s, port: %d \r\n", result, uid_info.uid, uid_info.node_name_str, uid_info.port);