@@ -23,6 +23,18 @@ include:
2323 anod-args : run test_als_$ACI_TRACK
2424 image : systemgtk
2525
26+ # Testing of the ALS with coverage
27+ - component : $CI_SERVER_FQDN/eng/gitlab-templates/test@~latest
28+ inputs :
29+ job-name : als-cov
30+ anod-args : run test_als_cov_$ACI_TRACK
31+ image : systemgtk
32+ # This job needs to rebuild ALS in coverage mode, so it doesn't need to
33+ # depend on the build job. The following will get it to run in parallel
34+ # with the build job.
35+ needs : []
36+ stage : build
37+
2638 # Testing of the VSCode extension
2739 - component : $CI_SERVER_FQDN/eng/gitlab-templates/test@~latest
2840 inputs :
@@ -57,3 +69,104 @@ include:
5769 - if : $CI_PIPELINE_SOURCE == 'merge_request_event'
5870 when : manual
5971 allow_failure : true
72+
73+ als-cov :
74+ after_script :
75+ # Source the env prepared by generic_anod_ci
76+ - cat /tmp/ci_env.sh
77+ - . /tmp/ci_env.sh
78+
79+ - ALS_BUILD_SPACE=$(anod info test als $ACI_TRACK_QUALIFIER -Q coverage --show working_dir)
80+ - RESULTS_DIR=$ALS_BUILD_SPACE/results/new
81+
82+ # Include Anod logs
83+ - cp -rv $ANOD_DEFAULT_SANDBOX_DIR/log $CI_PROJECT_DIR/anod-logs
84+
85+ # Include coverage report
86+ - mkdir -v $CI_PROJECT_DIR/coverage
87+
88+ # save coverage results
89+ - cp -v $RESULTS_DIR/coverage-cobertura/cobertura.xml $CI_PROJECT_DIR/coverage
90+ - cp -vr $RESULTS_DIR/coverage-dhtml $CI_PROJECT_DIR/coverage/dhtml
91+
92+ # export to gitlab pages
93+ - |
94+ if [[ $CI_PIPELINE_SOURCE = "merge_request_event" ]]; then
95+ target_subdir=MRs/$CI_MERGE_REQUEST_IID
96+ else
97+ target_subdir=$CI_COMMIT_BRANCH
98+ fi
99+
100+ - target_subdir=$target_subdir/ada-coverage
101+ - publish-pages $CI_PROJECT_DIR/coverage/dhtml/ --target-subdir $target_subdir --expires 30
102+ - >
103+ echo "Coverage report: https://pages.gitlab.adacore-it.com/$CI_PROJECT_PATH/$target_subdir/index.html"
104+
105+ # display coverage stats for global reporting
106+ - echo_coverage_stats --coverage-file $RESULTS_DIR/coverage-xml/index.xml
107+ coverage : ' /^Stmt Coverage:\s+(\d+\.\d+\%) \(\d+ \/ \d+\)$/'
108+ artifacts :
109+ when : always # Upload on errors too
110+ reports :
111+ junit : xunit-*.xml
112+ coverage_report :
113+ coverage_format : cobertura
114+ path : coverage/cobertura.xml
115+ paths :
116+ - anod-logs/
117+ # Also archive the report file for debugging the CI integration
118+ - coverage/cobertura.xml
119+
120+ vscode-extension :
121+ after_script :
122+ # Source the env prepared by generic_anod_ci
123+ - cat /tmp/ci_env.sh
124+ - . /tmp/ci_env.sh
125+
126+ - VSCODE_BUILD_SPACE=$(anod info test vscode-extension -Q coverage $ACI_TRACK_QUALIFIER --show working_dir)
127+
128+ # Include Anod logs
129+ - cp -rv $ANOD_DEFAULT_SANDBOX_DIR/log $CI_PROJECT_DIR/anod-logs
130+
131+ # Copy coverage reports
132+ - cp -rv $VSCODE_BUILD_SPACE/test/integration/vscode/ada/coverage $CI_PROJECT_DIR
133+
134+ # export to gitlab pages
135+ - |
136+ if [[ $CI_PIPELINE_SOURCE = "merge_request_event" ]]; then
137+ target_subdir=MRs/$CI_MERGE_REQUEST_IID
138+ else
139+ target_subdir=$CI_COMMIT_BRANCH
140+ fi
141+ - target_subdir=$target_subdir/ts-coverage
142+ - publish-pages $CI_PROJECT_DIR/coverage/ --target-subdir $target_subdir --expires 30
143+ - >
144+ echo "Coverage report: https://pages.gitlab.adacore-it.com/$CI_PROJECT_PATH/$target_subdir/index.html"
145+
146+ # Compute coverage percentage
147+ - line_rate=$(cat $CI_PROJECT_DIR/coverage/cobertura-coverage.xml | grep -o 'line-rate="\([^"]\+\)"' | head -1 | grep -o '[0-9.]\+')
148+ - line_perc=$(python -c "print($line_rate * 100)")
149+ - >
150+ echo "Line Coverage: $line_perc"
151+
152+ # The Cobertura report coming from the VS Code test infra has a <source>
153+ # element specifying the root path of all sources.
154+ #
155+ # This needs to be replaced with the CI_PROJECT_DIR in order for GitLab to
156+ # understand it.
157+ #
158+ # In this sed command we use '|' instead of '/' as a separator for the 's'
159+ # command to avoid interpreting path separators in the pattern and
160+ # replacement.
161+ - sed -e "s|$VSCODE_BUILD_SPACE/test|$CI_PROJECT_DIR|" -i $CI_PROJECT_DIR/coverage/cobertura-coverage.xml
162+ coverage : ' /^Line Coverage:\s+(\d+\.\d+)$/'
163+ artifacts :
164+ when : always # Upload on errors too
165+ reports :
166+ junit : xunit-*.xml
167+ coverage_report :
168+ coverage_format : cobertura
169+ path : coverage/cobertura-coverage.xml
170+ paths :
171+ - anod-logs/
172+ - coverage/cobertura-coverage.xml
0 commit comments