From 4dbe541f8096ab5d5ea6a64479304353dacb8249 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Thu, 21 Sep 2023 16:32:39 +0200 Subject: [PATCH] ci: replace internal clang-tidy runner with the pypi project --- .gitlab-ci.yml | 2 -- .gitlab/ci/static-code-analysis.yml | 15 ++++----------- docs/en/api-guides/tools/idf-clang-tidy.rst | 8 -------- docs/zh_CN/api-guides/tools/idf-clang-tidy.rst | 8 -------- tools/ci/utils.sh | 10 ---------- tools/requirements/requirements.core.txt | 1 + 6 files changed, 5 insertions(+), 39 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ffce6e9b4..061a6f75b3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,8 +58,6 @@ variables: CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py" PYTHON_VER: 3.8.17 - CLANG_TIDY_RUNNER_PROJ: 2107 # idf/clang-tidy-runner - # Docker images BOT_DOCKER_IMAGE_TAG: ":latest" diff --git a/.gitlab/ci/static-code-analysis.yml b/.gitlab/ci/static-code-analysis.yml index 212911ecb7..7ad423e62c 100644 --- a/.gitlab/ci/static-code-analysis.yml +++ b/.gitlab/ci/static-code-analysis.yml @@ -5,23 +5,16 @@ clang_tidy_check: - .rules:patterns:clang_tidy artifacts: paths: - - $OUTPUT_DIR + - clang_tidy_reports/ when: always expire_in: 1 day variables: - CLANG_TIDY_DIRS_TXT: ${CI_PROJECT_DIR}/tools/ci/clang_tidy_dirs.txt - RULES_FILE: ${CI_PROJECT_DIR}/tools/ci/static-analysis-rules.yml - OUTPUT_DIR: ${CI_PROJECT_DIR}/clang_tidy_reports IDF_TOOLCHAIN: clang script: - - internal_pip_install $CLANG_TIDY_RUNNER_PROJ pyclang - - export PATH=$PATH:$(python -c "import sys; print(sys.executable.rsplit('/', 1)[0])") - - dirs=$(cat ${CLANG_TIDY_DIRS_TXT} | while read line; do echo ${CI_PROJECT_DIR}/${line}; done | xargs) - - run_cmd idf_clang ${dirs} - --output-path ${OUTPUT_DIR} - --limit-file ${RULES_FILE} + - run_cmd idf_clang_tidy $(cat tools/ci/clang_tidy_dirs.txt | xargs) + --output-path clang_tidy_reports + --limit-file tools/ci/static-analysis-rules.yml --xtensa-include-dir - --run-clang-tidy-py run-clang-tidy check_pylint: extends: diff --git a/docs/en/api-guides/tools/idf-clang-tidy.rst b/docs/en/api-guides/tools/idf-clang-tidy.rst index 812009e7d6..7d3e7a802d 100644 --- a/docs/en/api-guides/tools/idf-clang-tidy.rst +++ b/docs/en/api-guides/tools/idf-clang-tidy.rst @@ -21,20 +21,12 @@ Prerequisites If you have never run this tool before, take the following steps to get this tool prepared. -#. Run the export scripts (``export.sh``, ``export.bat``, or others) to set up the environment variables. -#. Run ``pip install --upgrade pyclang`` to install this plugin. The extra commands would be activated in ``idf.py`` automatically. #. Run ``idf_tools.py install esp-clang`` to install the clang-tidy required binaries .. note:: This toolchain is still under development. After the final release, you do not have to install them manually. -#. Get the file from the `llvm repository `__ and add the folder of this script to the ``$PATH``. Or you could pass an optional argument ``--run-clang-tidy-py`` later when you call ``idf.py clang-check``. Please do not forget to make the script executable. - - .. note:: - - 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. Extra Commands diff --git a/docs/zh_CN/api-guides/tools/idf-clang-tidy.rst b/docs/zh_CN/api-guides/tools/idf-clang-tidy.rst index 1c837eda97..e66f75fbaa 100644 --- a/docs/zh_CN/api-guides/tools/idf-clang-tidy.rst +++ b/docs/zh_CN/api-guides/tools/idf-clang-tidy.rst @@ -21,20 +21,12 @@ IDF clang-tidy 是使用 `clang-tidy ` 初次运行此工具时,请按照以下步骤准备该工具: -#. 运行导出脚本(如 ``export.sh``、``export.bat`` 等),设置环境变量。 -#. 运行 ``pip install --upgrade pyclang`` 安装插件,其他命令将在 ``idf.py`` 中自动激活。 #. 运行 ``idf_tools.py install esp-clang`` 安装 clang-tidy 所需的二进制文件。 .. note:: 该工具链尚在开发中,最终版本发布后,将无需手动安装工具链。 -#. 从 `llvm 仓库 `__ 获取文件,并将该脚本所在的文件夹添加到 ``$PATH`` 中,或在调用 ``idf.py clang-check`` 时传递可选参数 ``--run-clang-tidy-py``。请将脚本设置为可执行。 - - .. note:: - - 在未来工具链版本中,该文件将一并捆绑。目前为临时解决方案。 - #. 再次运行导出脚本(如 ``export.sh``、``export.bat`` 等),刷新环境变量。 其他命令 diff --git a/tools/ci/utils.sh b/tools/ci/utils.sh index 719d68adf9..f860fef110 100644 --- a/tools/ci/utils.sh +++ b/tools/ci/utils.sh @@ -117,16 +117,6 @@ function retry_failed() { 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 { local d=${1-} f=${2-} if shift 2; then diff --git a/tools/requirements/requirements.core.txt b/tools/requirements/requirements.core.txt index 1c0ba96bc5..d1d4c930c2 100644 --- a/tools/requirements/requirements.core.txt +++ b/tools/requirements/requirements.core.txt @@ -16,6 +16,7 @@ esp-idf-kconfig esp-idf-monitor esp-idf-size esp-idf-panic-decoder +pyclang # gdb extensions dependencies freertos_gdb