2021-02-08 23:31:38 -05:00
|
|
|
# pre_check stage
|
|
|
|
clang_tidy_check:
|
2020-11-30 04:40:24 -05:00
|
|
|
extends:
|
2022-07-28 03:32:13 -04:00
|
|
|
- .pre_check_template
|
2020-11-30 04:40:24 -05:00
|
|
|
- .rules:patterns:clang_tidy
|
|
|
|
artifacts:
|
|
|
|
paths:
|
2023-09-21 10:32:39 -04:00
|
|
|
- clang_tidy_reports/
|
2021-08-18 21:26:20 -04:00
|
|
|
when: always
|
2020-11-30 04:40:24 -05:00
|
|
|
expire_in: 1 day
|
2021-08-18 21:26:20 -04:00
|
|
|
variables:
|
2022-12-15 12:46:33 -05:00
|
|
|
IDF_TOOLCHAIN: clang
|
2020-11-30 04:40:24 -05:00
|
|
|
script:
|
2023-09-21 10:32:39 -04:00
|
|
|
- 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
|
2021-08-18 21:26:20 -04:00
|
|
|
--xtensa-include-dir
|
|
|
|
|
|
|
|
check_pylint:
|
|
|
|
extends:
|
2022-07-28 03:32:13 -04:00
|
|
|
- .pre_check_template
|
2021-08-18 21:26:20 -04:00
|
|
|
- .rules:patterns:python-files
|
2023-11-01 07:43:19 -04:00
|
|
|
needs:
|
|
|
|
- pipeline_variables
|
2021-08-18 21:26:20 -04:00
|
|
|
artifacts:
|
|
|
|
when: always
|
2023-08-10 23:05:58 -04:00
|
|
|
reports:
|
|
|
|
codequality: pylint.json
|
2021-08-18 21:26:20 -04:00
|
|
|
expire_in: 1 week
|
|
|
|
script:
|
|
|
|
- |
|
|
|
|
if [ -n "$CI_MERGE_REQUEST_IID" ]; then
|
2023-11-01 07:43:19 -04:00
|
|
|
export files=$(echo "$GIT_DIFF_OUTPUT" | grep ".py$" | xargs);
|
2021-08-18 21:26:20 -04:00
|
|
|
else
|
2023-10-19 05:53:18 -04:00
|
|
|
export files=$(git ls-files "*.py" | xargs);
|
2021-08-18 21:26:20 -04:00
|
|
|
fi
|
2023-08-10 23:03:52 -04:00
|
|
|
- if [ -z "$files" ]; then echo "No python files found"; exit 0; fi
|
2023-08-10 23:05:58 -04:00
|
|
|
- run_cmd pylint --exit-zero --load-plugins=pylint_gitlab --output-format=gitlab-codeclimate:pylint.json $files
|
2020-11-30 04:40:24 -05:00
|
|
|
|
|
|
|
# build stage
|
|
|
|
# Sonarqube related jobs put here for this reason:
|
|
|
|
# Here we have two jobs. code_quality_check and code_quality_report.
|
|
|
|
#
|
|
|
|
# code_quality_check will analyze the code changes between your MR and
|
|
|
|
# code repo stored in sonarqube server. The analysis result is only shown in
|
|
|
|
# the comments under this MR and won't be transferred to the server.
|
|
|
|
#
|
|
|
|
# code_quality_report will analyze and transfer both of the newly added code
|
|
|
|
# and the analysis result to the server.
|
|
|
|
#
|
|
|
|
# Put in the front to ensure that the newly merged code can be stored in
|
|
|
|
# sonarqube server ASAP, in order to avoid reporting unrelated code issues
|
|
|
|
.sonar_scan_template:
|
|
|
|
stage: build
|
2023-01-16 05:23:57 -05:00
|
|
|
extends: .pre_check_template
|
2020-11-30 04:40:24 -05:00
|
|
|
image:
|
2021-08-27 03:05:01 -04:00
|
|
|
name: $SONARQUBE_SCANNER_IMAGE
|
2020-11-30 04:40:24 -05:00
|
|
|
before_script:
|
|
|
|
- source tools/ci/utils.sh
|
|
|
|
- export PYTHONPATH="$CI_PROJECT_DIR/tools:$CI_PROJECT_DIR/tools/ci/python_packages:$PYTHONPATH"
|
|
|
|
- fetch_submodules
|
2021-08-30 05:39:40 -04:00
|
|
|
# Exclude the submodules, all paths ends with /**
|
|
|
|
- submodules=$(get_all_submodules)
|
|
|
|
# get all exclude paths specified in tools/ci/sonar_exclude_list.txt | ignore lines start with # | xargs | replace all <space> to <comma>
|
|
|
|
- custom_excludes=$(cat $CI_PROJECT_DIR/tools/ci/sonar_exclude_list.txt | grep -v '^#' | xargs | sed -e 's/ /,/g')
|
|
|
|
# Exclude the report dir as well
|
|
|
|
- export EXCLUSIONS="$custom_excludes,$submodules"
|
|
|
|
- export SONAR_SCANNER_OPTS="-Xmx2048m"
|
2020-11-30 04:40:24 -05:00
|
|
|
variables:
|
|
|
|
GIT_DEPTH: 0
|
2021-08-18 21:26:20 -04:00
|
|
|
REPORT_PATTERN: clang_tidy_reports/*.txt
|
|
|
|
artifacts:
|
|
|
|
when: always
|
|
|
|
paths:
|
|
|
|
- $REPORT_PATTERN
|
2022-02-09 05:00:54 -05:00
|
|
|
expire_in: 1 week
|
2020-11-30 04:40:24 -05:00
|
|
|
dependencies: # Here is not a hard dependency relationship, could be skipped when only python files changed. so we do not use "needs" here.
|
2021-02-08 23:31:38 -05:00
|
|
|
- clang_tidy_check
|
2020-11-30 04:40:24 -05:00
|
|
|
|
|
|
|
code_quality_check:
|
|
|
|
extends:
|
|
|
|
- .sonar_scan_template
|
|
|
|
- .rules:patterns:static-code-analysis-preview
|
2021-02-16 09:06:57 -05:00
|
|
|
allow_failure: true # since now it's using exit code to indicate the code analysis result,
|
|
|
|
# we don't want to block ci when critical issues founded
|
2020-11-30 04:40:24 -05:00
|
|
|
script:
|
2023-11-01 07:43:19 -04:00
|
|
|
- export CI_MERGE_REQUEST_COMMITS=$(python ${CI_PROJECT_DIR}/tools/ci/ci_get_mr_info.py commits --src-branch ${CI_COMMIT_REF_NAME} | tr '\n' ',')
|
2020-11-30 04:40:24 -05:00
|
|
|
# test if this branch have merge request, if not, exit 0
|
2021-02-01 02:47:31 -05:00
|
|
|
- test -n "$CI_MERGE_REQUEST_IID" || exit 0
|
|
|
|
- test -n "$CI_MERGE_REQUEST_COMMITS" || exit 0
|
2020-11-30 04:40:24 -05:00
|
|
|
- sonar-scanner
|
|
|
|
-Dsonar.analysis.mode=preview
|
2021-08-18 21:26:20 -04:00
|
|
|
-Dsonar.branch.name=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
|
|
|
|
-Dsonar.cxx.clangtidy.reportPath=$REPORT_PATTERN
|
2021-08-30 05:39:40 -04:00
|
|
|
-Dsonar.exclusions=$EXCLUSIONS
|
2021-02-01 02:47:31 -05:00
|
|
|
-Dsonar.gitlab.ci_merge_request_iid=$CI_MERGE_REQUEST_IID
|
|
|
|
-Dsonar.gitlab.commit_sha=$CI_MERGE_REQUEST_COMMITS
|
2021-08-30 05:39:40 -04:00
|
|
|
-Dsonar.gitlab.merge_request_discussion=true
|
2021-08-18 21:26:20 -04:00
|
|
|
-Dsonar.gitlab.ref_name=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
|
2021-02-01 02:47:31 -05:00
|
|
|
-Dsonar.host.url=$SONAR_HOST_URL
|
|
|
|
-Dsonar.login=$SONAR_LOGIN
|
2020-11-30 04:40:24 -05:00
|
|
|
|
|
|
|
code_quality_report:
|
|
|
|
extends:
|
|
|
|
- .sonar_scan_template
|
2021-02-08 23:31:38 -05:00
|
|
|
- .rules:protected
|
2021-02-16 09:06:57 -05:00
|
|
|
allow_failure: true # since now it's using exit code to indicate the code analysis result,
|
|
|
|
# we don't want to block ci when critical issues founded
|
2020-11-30 04:40:24 -05:00
|
|
|
script:
|
|
|
|
- sonar-scanner
|
2021-02-01 02:47:31 -05:00
|
|
|
-Dsonar.branch.name=$CI_COMMIT_REF_NAME
|
2021-08-18 21:26:20 -04:00
|
|
|
-Dsonar.cxx.clangtidy.reportPath=$REPORT_PATTERN
|
2021-08-30 05:39:40 -04:00
|
|
|
-Dsonar.exclusions=$EXCLUSIONS
|
2021-10-28 00:07:02 -04:00
|
|
|
-Dsonar.gitlab.commit_sha=$PIPELINE_COMMIT_SHA
|
2020-11-30 04:40:24 -05:00
|
|
|
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
|
2021-02-01 02:47:31 -05:00
|
|
|
-Dsonar.host.url=$SONAR_HOST_URL
|
|
|
|
-Dsonar.login=$SONAR_LOGIN
|