@@ -38,84 +38,3 @@ check_pylint:
3838 fi
3939 - if [ -z "$files" ]; then echo "No python files found"; exit 0; fi
4040 - run_cmd pylint --exit-zero --load-plugins=pylint_gitlab --output-format=gitlab-codeclimate:pylint.json $files
41-
42- # build stage
43- # Sonarqube related jobs put here for this reason:
44- # Here we have two jobs. code_quality_check and code_quality_report.
45- #
46- # code_quality_check will analyze the code changes between your MR and
47- # code repo stored in sonarqube server. The analysis result is only shown in
48- # the comments under this MR and won't be transferred to the server.
49- #
50- # code_quality_report will analyze and transfer both of the newly added code
51- # and the analysis result to the server.
52- #
53- # Put in the front to ensure that the newly merged code can be stored in
54- # sonarqube server ASAP, in order to avoid reporting unrelated code issues
55- .sonar_scan_template :
56- stage : build
57- extends : .pre_check_template
58- # full clone since this image does not support fetch --shallow-since-cutoff
59- # shiny runners are used for full clone
60- tags : [build, shiny]
61- image : $SONARQUBE_SCANNER_IMAGE
62- before_script :
63- - source tools/ci/utils.sh
64- - export PYTHONPATH="$CI_PROJECT_DIR/tools:$CI_PROJECT_DIR/tools/ci/python_packages:$PYTHONPATH"
65- - fetch_submodules
66- # Exclude the submodules, all paths ends with /**
67- - submodules=$(get_all_submodules)
68- # get all exclude paths specified in tools/ci/sonar_exclude_list.txt | ignore lines start with # | xargs | replace all <space> to <comma>
69- - custom_excludes=$(cat $CI_PROJECT_DIR/tools/ci/sonar_exclude_list.txt | grep -v '^#' | xargs | sed -e 's/ /,/g')
70- # Exclude the report dir as well
71- - export EXCLUSIONS="$custom_excludes,$submodules"
72- - export SONAR_SCANNER_OPTS="-Xmx2048m"
73- variables :
74- GIT_DEPTH : 0
75- REPORT_PATTERN : clang_tidy_reports/**/*.txt
76- artifacts :
77- paths :
78- - $REPORT_PATTERN
79- expire_in : 1 week
80- when : always
81- dependencies : # Here is not a hard dependency relationship, could be skipped when only python files changed. so we do not use "needs" here.
82- - clang_tidy_check
83-
84- code_quality_check :
85- extends :
86- - .sonar_scan_template
87- - .rules:patterns:static-code-analysis-preview
88- allow_failure : true # it's using exit code to indicate the code analysis result,
89- # we don't want to block ci when critical issues founded
90- script :
91- - 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' ',')
92- # test if this branch have merge request, if not, exit 0
93- - test -n "$CI_MERGE_REQUEST_IID" || exit 0
94- - test -n "$CI_MERGE_REQUEST_COMMITS" || exit 0
95- - sonar-scanner
96- -Dsonar.analysis.mode=preview
97- -Dsonar.branch.name=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
98- -Dsonar.cxx.clangtidy.reportPath=$REPORT_PATTERN
99- -Dsonar.exclusions=$EXCLUSIONS
100- -Dsonar.gitlab.ci_merge_request_iid=$CI_MERGE_REQUEST_IID
101- -Dsonar.gitlab.commit_sha=$CI_MERGE_REQUEST_COMMITS
102- -Dsonar.gitlab.merge_request_discussion=true
103- -Dsonar.gitlab.ref_name=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
104- -Dsonar.host.url=$SONAR_HOST_URL
105- -Dsonar.login=$SONAR_LOGIN
106-
107- code_quality_report :
108- extends :
109- - .sonar_scan_template
110- - .rules:protected
111- allow_failure : true # it's using exit code to indicate the code analysis result,
112- # we don't want to block ci when critical issues founded
113- script :
114- - sonar-scanner
115- -Dsonar.branch.name=$CI_COMMIT_REF_NAME
116- -Dsonar.cxx.clangtidy.reportPath=$REPORT_PATTERN
117- -Dsonar.exclusions=$EXCLUSIONS
118- -Dsonar.gitlab.commit_sha=$PIPELINE_COMMIT_SHA
119- -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
120- -Dsonar.host.url=$SONAR_HOST_URL
121- -Dsonar.login=$SONAR_LOGIN
0 commit comments