Debian Codegraph @

build/jenkins/pipelines/static-analysis.Jenkinsfile

raw
1 /* Copyright (C) 2025 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 // This pipeline is used to build the documentation.
19
20 pipeline {
21 agent {
22 node {
23 label 'LinuxSlave'
24 }
25 }
26 environment {
27 INFO_FILE = 'coverage.info'
28 REPORT_PATH = '../../../coverage-results/'
29 }
30 stages {
31 stage('Setup') {
32 steps {
33 sh 'sudo zfs clone zpool0/gcc7@latest zpool0/docker-coverage'
34 }
35 }
36 stage('Build') {
37 steps {
38 ws('/zpool0/docker-coverage') {
39 dir('build/workspaces/') {
40 sh './update-workspaces.sh -j1 --coverage'
41 dir('gcc/') {
42 // Reset everything in case there were ever leftovers
43 sh 'lcov --directory . --zerocounters'
44 sh 'make -B -j1 test'
45 }
46 }
47 }
48 }
49 }
50 stage('Generation') {
51 steps {
52 ws('/zpool0/docker-coverage') {
53 dir('build/workspaces/gcc') {
54 // The executable must be launched from the same path
55 // as where it was built else nothing is generated.
56 sh '../../../binaries/system/test'
57 // Capture the symbols.
58 sh "lcov --directory . --capture --output-file ${INFO_FILE}"
59 // Remove things we don't need to analyze like external
60 // libraries or system ones.
61 sh "lcov --remove ${INFO_FILE} \"*/*/*/tests/*\" \"*/*/*/libraries/*\" \"/usr/*\" --output-file ${INFO_FILE}"
62 sh "mkdir -p ${REPORT_PATH}"
63 sh "genhtml --o ${REPORT_PATH} -t \"0 A.D. test coverage report\" --num-spaces 4 --demangle-cpp ${INFO_FILE}"
64 }
65 }
66 }
67 }
68 stage('Upload') {
69 steps {
70 ws('/zpool0/docker-coverage') {
71 sh 'rsync -airt --progress coverage-results/* docs.wildfiregames.com:~/www/coverage/'
72 }
73 }
74 }
75 }
76 post {
77 always {
78 ws('/zpool0/trunk') {
79 sleep 10
80 sh 'sudo zfs destroy zpool0/docker-coverage'
81 }
82 }
83 }
84 }