-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
213 lines (198 loc) · 6.7 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/usr/bin/env groovy
pipeline {
agent { label 'colobot-build' }
options {
buildDiscarder(logRotator(artifactNumToKeepStr: '5'))
}
stages {
stage('Build') {
steps {
sh 'mkdir -p build'
dir('build') {
sh '''
cmake \
-DCMAKE_BUILD_TYPE=Release -DTESTS=1 \
-DCMAKE_CXX_FLAGS="-I/usr/lib/llvm-3.6/include -L/usr/lib/llvm-3.6/lib" \
..
make
'''
}
}
post {
success {
archiveArtifacts 'build/colobot-lint'
}
}
}
stage('Package HtmlReport') {
steps {
sh '''
rm -f build/html_report.tar.gz
tar -zcf build/html_report.tar.gz HtmlReport/
'''
}
post {
success {
archiveArtifacts 'build/html_report.tar.gz'
}
}
}
stage('Package count_errors.py') {
steps {
archiveArtifacts 'Tools/count_errors.py'
}
}
stage('Run unit tests') {
steps {
dir('build') {
sh '''
echo "Cleaning previous tests"
if [ -e ./Testing ]; then
find ./Testing -name Test.xml -delete;
fi
echo "Running colobot-lint unit tests"
ctest --no-compress-output -T Test . || true
'''
}
step([$class: 'XUnitPublisher',
testTimeMargin: '3000',
thresholdMode: 1,
thresholds: [
[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '1'],
[$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '1']
],
tools: [
[$class: 'CTestType', deleteOutputFiles: true, failIfNotNew: false, pattern: 'build/Testing/**/Test.xml', skipNoTestFiles: false, stopProcessingIfError: true]
]
])
}
}
stage('Test run on Colobot') {
when { branch 'dev' }
steps {
dir('build') {
sh '''#!/bin/bash
set -e +x
# Update colobot workspace
COLOBOT_REPO_URL="https://github.com/colobot/colobot.git"
COLOBOT_DIR="./colobot"
if [ ! -e "$COLOBOT_DIR" ]; then
echo "Cloning colobot"
git clone --branch=dev --recursive "$COLOBOT_REPO_URL" "$COLOBOT_DIR"
else
echo "Updating colobot"
cd "$COLOBOT_DIR"
git checkout dev
git pull origin dev
git submodule update
fi
'''
sh '''#!/bin/bash
set -e +x
# Run colobot-lint
COLOBOT_DIR="$WORKSPACE/build/colobot"
COLOBOT_BUILD_DIR="$WORKSPACE/build/colobot-build"
COLOBOT_LINT_BUILD_DIR="$WORKSPACE/build"
COLOBOT_LINT_REPORT_FILE="$WORKSPACE/build/colobot_lint_report.xml"
CLANG_PREFIX="/usr/lib/llvm-3.6"
echo "Running CMake for colobot"
rm -rf "$COLOBOT_BUILD_DIR"
mkdir -p "$COLOBOT_BUILD_DIR"
cd "$COLOBOT_BUILD_DIR"
cmake -DCOLOBOT_LINT_BUILD=1 -DTESTS=1 -DTOOLS=1 -DMUSIC=0 -DCMAKE_EXPORT_COMPILE_COMMANDS=1 "$COLOBOT_DIR"
echo "Running colobot-lint for colobot"
cd "$COLOBOT_LINT_BUILD_DIR"
# Workaround for Clang not finding system headers
rm -rf bin/
mkdir -p bin
mv ./colobot-lint ./bin/
rm -f ./lib
ln -s ${CLANG_PREFIX}/lib ./lib
find "$WORKSPACE" \\( -wholename "$COLOBOT_DIR/src/*.cpp" \
-or -wholename "$COLOBOT_DIR/test/unit/*.cpp" \
-or -wholename "$COLOBOT_BUILD_DIR/fake_header_sources/src/*.cpp" \
-or -wholename "$COLOBOT_BUILD_DIR/fake_header_sources/test/unit/*.cpp" \\) \
-exec ./bin/colobot-lint \
-verbose \
-output-format xml \
-output-file "$COLOBOT_LINT_REPORT_FILE" \
-p "$COLOBOT_BUILD_DIR" \
-project-local-include-path "$COLOBOT_DIR/src" -project-local-include-path "$COLOBOT_BUILD_DIR/src" \
-license-template-file "$COLOBOT_DIR/LICENSE-HEADER.txt" \
{} +
'''
sh '''#!/bin/bash
set -e +x
# Update stable/unstable build status
COLOBOT_LINT_REPORT_FILE="$WORKSPACE/build/colobot_lint_report.xml"
COLOBOT_LINT_DIR="$WORKSPACE"
OVERALL_STABLE_RULES=(
"class naming"
"code block placement"
"compile error"
# "compile warning"
# "enum naming"
# "function naming"
"header file not self-contained"
# "implicit bool cast"
# "include style"
# "inconsistent declaration parameter name"
"license header"
# "naked delete"
# "naked new"
# "old style function"
"old-style null pointer"
# "possible forward declaration"
"undefined function"
# "uninitialized field"
# "uninitialized local variable"
# "unused forward declaration"
# "variable naming"
"whitespace"
)
echo "Checking rule stability (overall)"
for ((i = 0; i < ${#OVERALL_STABLE_RULES[@]}; i++)); do
rule="${OVERALL_STABLE_RULES[$i]}"
count="$("$COLOBOT_LINT_DIR/Tools/count_errors.py" --rule-filter="$rule" --xml-report-file "$COLOBOT_LINT_REPORT_FILE")"
if [ "$count" != "0" ]; then
echo "UNSTABLE RULE: $rule ($count occurences)"
fi
done
STABLE_RULES_WITHOUT_CBOT=(
"class naming"
"code block placement"
"compile error"
"compile warning"
# "enum naming"
# "function naming"
"header file not self-contained"
# "implicit bool cast"
"include style"
"inconsistent declaration parameter name"
"license header"
"naked delete"
"naked new"
# "old style function"
"old-style null pointer"
# "possible forward declaration"
"undefined function"
"uninitialized field"
# "uninitialized local variable"
"unused forward declaration"
# "variable naming"
"whitespace"
)
echo "Checking rule stability (without CBOT)"
for ((i = 0; i < ${#STABLE_RULES_WITHOUT_CBOT[@]}; i++)); do
rule="${STABLE_RULES_WITHOUT_CBOT[$i]}"
count="$("$COLOBOT_LINT_DIR/Tools/count_errors.py" --rule-filter="$rule" --file-filter="-.*CBot.*" --xml-report-file "$COLOBOT_LINT_REPORT_FILE")"
if [ "$count" != "0" ]; then
echo "UNSTABLE RULE: $rule (without CBOT, $count occurences)"
fi
done
'''
}
}
}
}
}