Merge branch 'ci/replace_internal_clang-tidy-runner_v5.0' into 'release/v5.0'

ci: replace internal clang-tidy runner with the pypi project (v5.0)

See merge request espressif/esp-idf!34369
This commit is contained in:
Anton Maklakov 2024-10-23 14:34:10 +08:00
commit 20efbad741
6 changed files with 59 additions and 26 deletions

View File

@ -55,9 +55,6 @@ variables:
V: "0" V: "0"
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py" CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
CLANG_TIDY_RUNNER_PROJ: 2107 # idf/clang-tidy-runner
IDF_BUILD_APPS_PROJ: 2818 # espressif/idf-build-apps
# Docker images # Docker images
BOT_DOCKER_IMAGE_TAG: ":latest" BOT_DOCKER_IMAGE_TAG: ":latest"

View File

@ -6,20 +6,15 @@ clang_tidy_check:
image: ${CLANG_STATIC_ANALYSIS_IMAGE} image: ${CLANG_STATIC_ANALYSIS_IMAGE}
artifacts: artifacts:
paths: paths:
- $OUTPUT_DIR - clang_tidy_reports/
when: always when: always
expire_in: 1 day expire_in: 1 day
variables: variables:
CLANG_TIDY_DIRS_TXT: ${CI_PROJECT_DIR}/tools/ci/clang_tidy_dirs.txt IDF_TOOLCHAIN: clang
RULES_FILE: ${CI_PROJECT_DIR}/tools/ci/static-analysis-rules.yml
OUTPUT_DIR: ${CI_PROJECT_DIR}/clang_tidy_reports
script: script:
- internal_pip_install $CLANG_TIDY_RUNNER_PROJ pyclang - run_cmd idf_clang_tidy $(cat tools/ci/clang_tidy_dirs.txt | xargs)
- export PATH=$PATH:$(python -c "import sys; print(sys.executable.rsplit('/', 1)[0])") --output-path clang_tidy_reports
- dirs=$(cat ${CLANG_TIDY_DIRS_TXT} | while read line; do echo ${CI_PROJECT_DIR}/${line}; done | xargs) --limit-file tools/ci/static-analysis-rules.yml
- run_cmd idf_clang ${dirs}
--output-path ${OUTPUT_DIR}
--limit-file ${RULES_FILE}
--xtensa-include-dir --xtensa-include-dir
--run-clang-tidy-py ${RUN_CLANG_TIDY_PY} --run-clang-tidy-py ${RUN_CLANG_TIDY_PY}

View File

@ -11,7 +11,7 @@ The IDF Clang Tidy is a tool that uses `clang-tidy <https://clang.llvm.org/extra
.. only:: esp32c3 or esp32h2 .. only:: esp32c3 or esp32h2
.. warning:: .. warning::
This tool does not support RISC-V based chips yet. For now, we don't provide clang based toolchain for RISC-V. This tool does not support RISC-V based chips yet. For now, we don't provide clang based toolchain for RISC-V.
Prerequisites Prerequisites
@ -32,7 +32,7 @@ If you have never run this tool before, take the following steps to get this too
.. note:: .. note::
This file would be bundled in future toolchain releases. This is a temporary workaround. This file would be bundled in future toolchain releases. This is a temporary workaround.
#. Run the export scripts (``export.sh`` / ``export.bat`` / ... ) again to refresh the environment variables. #. Run the export scripts (``export.sh`` / ``export.bat`` / ... ) again to refresh the environment variables.
Extra Commands Extra Commands

View File

@ -1 +1,51 @@
.. include:: ../../../en/api-guides/tools/idf-clang-tidy.rst ******************
IDF clang-tidy
******************
:link_to_translation:`en:[English]`
IDF clang-tidy 是使用 `clang-tidy <https://clang.llvm.org/extra/clang-tidy/>`__ 对当前应用程序进行静态分析的工具。
.. warning::
IDF clang-tidy 的功能及其依赖的工具链尚在开发中,最终版本发布前可能有重大变更。
.. only:: CONFIG_IDF_TARGET_ARCH_RISCV
.. warning::
当前工具尚不支持基于 RISC-V 的芯片。目前,乐鑫尚未针对 RISC-V 提供基于 clang 的工具链。
准备工作
=============
初次运行此工具时,请按照以下步骤准备该工具:
#. 运行 ``idf_tools.py install esp-clang`` 安装 clang-tidy 所需的二进制文件。
.. note::
该工具链尚在开发中,最终版本发布后,将无需手动安装工具链。
#. 再次运行导出脚本(如 ``export.sh````export.bat`` 等),刷新环境变量。
其他命令
==============
``clang-check``
---------------
运行 ``idf.py clang-check`` 可以重新生成编译数据库,并在当前项目文件夹下运行 ``clang-tidy``,所得输出写入 ``<project_dir>/warnings.txt``
运行 ``idf.py clang-check --help`` 查看完整文档。
``clang-html-report``
---------------------
#. 运行 ``pip install codereport`` 安装附加依赖关系。
#. 运行 ``idf.py clang-html-report`` 会根据 ``warnings.txt````<project_dir>/html_report`` 文件夹内生成 HTML 报告。请在浏览器中打开 ``<project_dir>/html_report/index.html`` 查看报告。
错误报告
==========
此工具托管在 `espressif/clang-tidy-runner <https://github.com/espressif/clang-tidy-runner>`__。如遇到任何错误,或有任何功能请求,请通过 `Github issues <https://github.com/espressif/clang-tidy-runner/issues>`__ 提交报告。

View File

@ -117,16 +117,6 @@ function retry_failed() {
return $exitCode return $exitCode
} }
function internal_pip_install() {
project=$1
package=$2
token_name=${3:-${BOT_TOKEN_NAME}}
token=${4:-${BOT_TOKEN}}
python=${5:-python}
$python -m pip install --index-url https://${token_name}:${token}@${GITLAB_HTTPS_HOST}/api/v4/projects/${project}/packages/pypi/simple --force-reinstall --no-deps ${package}
}
function join_by { function join_by {
local d=${1-} f=${2-} local d=${1-} f=${2-}
if shift 2; then if shift 2; then

View File

@ -14,6 +14,7 @@ idf-component-manager
esp-coredump esp-coredump
esptool esptool
construct construct
pyclang
# kconfig and menuconfig dependencies # kconfig and menuconfig dependencies
kconfiglib kconfiglib