forked from KiCad/kicad-source-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
225 lines (204 loc) · 6.06 KB
/
.gitlab-ci.yml
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
214
215
216
217
218
219
220
221
222
223
224
225
stages:
- build
- test
- report
default:
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:31
##########################################################################
# This will allow the job to run whenever code events trigger it.
##########################################################################
.only_code:
only:
- master
- branches
- merge_requests
- pushes
##########################################################################
# Define a template for all the unit tests, since each one is run in a separate
# job to make the display nicer.
##########################################################################
.unit_test:
stage: test
when: on_success
needs:
- job: build_linux
artifacts: true
# We define this using a before script because GitLab cannot merge variable
# definitions across inheritance (so the variables block from this would disappear)
before_script:
- export BOOST_TEST_LOGGER='JUNIT,all,test_results.${TEST}.xml:HRF,warning'
- export CTEST_OUTPUT_ON_FAILURE=1
script:
- cd build/linux/qa
- ctest -R ${TEST}
# GitLab supports displaying the results in the GUI through JUNIT artifacts
# (https://docs.gitlab.com/ee/ci/junit_test_reports.html)
# so we upload the JUNIT results. Note that there is a bug with how paths
# are processed in the junit report (https://gitlab.com/gitlab-org/gitlab/issues/23835)
# so we can't use a glob and have to list out each hierarchy separately.
artifacts:
reports:
junit:
- build/linux/qa/*/*.xml
- build/linux/qa/*/*/*.xml
##########################################################################
# Test the formatting in a merge request using clang-format
##########################################################################
# The variable CI_COMMIT_BEFORE_SHA is not available in normal merge requests
# so we must build the commit hash ourselves, see:
# https://gitlab.com/gitlab-org/gitlab/issues/12850
test_formatting:
stage: test
only:
- merge_requests
allow_failure: true
before_script:
# We must manually add the KiCad remote to ensure it is named sensibly
- git remote add product https://gitlab.com/kicad/code/kicad.git
- git fetch -n product
- git fetch -n origin
# Get the SHAs of the commits
- "TARGET_HEAD_SHA=$(git rev-parse product/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME})"
- "SOURCE_HEAD_SHA=$(git rev-parse origin/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME})"
- "MERGE_BASE_SHA=$(git merge-base ${TARGET_HEAD_SHA} ${SOURCE_HEAD_SHA})"
script:
- echo "Testing formatting from commit ${MERGE_BASE_SHA}"
- ./tools/check_coding.sh --diff --ci --commit ${MERGE_BASE_SHA}
##########################################################################
# Build KiCad and save the results
##########################################################################
build_linux:
stage: build
extends: .only_code
interruptible: true
cache:
key: "cache-linux"
paths:
- ccache/
before_script:
# CCache Config
- mkdir -p ccache
- export CCACHE_BASEDIR=${PWD}
- export CCACHE_DIR=${PWD}/ccache
script:
- mkdir -p build/linux
- cd build/linux
- cmake
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_BUILD_TYPE=Debug
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_SCRIPTING=ON
-DKICAD_SCRIPTING_MODULES=ON
-DKICAD_SCRIPTING_PYTHON3=ON
-DKICAD_SCRIPTING_WXPYTHON=ON
-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
-DKICAD_SCRIPTING_ACTION_MENU=ON
-DBUILD_GITHUB_PLUGIN=ON
-DKICAD_USE_OCE=OFF
-DKICAD_USE_OCC=ON
-DKICAD_SPICE=ON
../../
- make 2>&1 | tee compilation_log.txt
- cd ../../
artifacts:
# Only save the artifacts that are needed for running the tests in the next stage
# and the compilation log. The entire build directory is too large to save as an
# artifact.
expire_in: 2 hrs
when: always
paths:
- build/linux/3d-viewer/
- build/linux/pcbnew/pcbnew.py
- build/linux/pcbnew/_pcbnew.so
- build/linux/qa/
- build/linux/compilation_log.txt
# Upload the compilation log in an easily downloadable form
report_build_warn:
stage: report
extends: .only_code
when: always
needs:
- job: build_linux
artifacts: true
script:
- echo "Uploading compilation log"
- cp build/linux/compilation_log.txt compilation_log.txt
artifacts:
expire_in: 1 year
expose_as: 'Build log'
name: "build_log.txt"
paths:
- compilation_log.txt
# Report on the metrics of the code
report_metrics:
stage: report
extends: .only_code
when: always
needs:
- job: build_linux
artifacts: true
script:
- cat build/linux/compilation_log.txt | grep "warning:" | awk '{total+=1}END{print "number_of_warnings "total}' > metrics.txt
- cat metrics.txt
artifacts:
reports:
metrics: metrics.txt
##########################################################################
# Run the code unit tests. Each QA executable is split into a separate job so that the display
# gives the test results broken down by the test executable.
##########################################################################
qa_python:
extends:
- .unit_test
- .only_code
variables:
TEST: 'qa_python'
qa_common_eeschema:
extends:
- .unit_test
- .only_code
variables:
TEST: 'common_eeschema'
qa_common_pcbnew:
extends:
- .unit_test
- .only_code
variables:
TEST: 'common_pcbnew'
qa_common_gerbview:
extends:
- .unit_test
- .only_code
variables:
TEST: 'qa_common_gerbview'
qa_pcbnew:
extends:
- .unit_test
- .only_code
variables:
TEST: 'pcbnew'
qa_eeschema:
extends:
- .unit_test
- .only_code
variables:
TEST: 'eeschema'
qa_kimath:
extends:
- .unit_test
- .only_code
variables:
TEST: 'kimath'
qa_sexpr:
extends:
- .unit_test
- .only_code
variables:
TEST: 'sexpr'
qa_kicad2step:
extends:
- .unit_test
- .only_code
variables:
TEST: 'kicad2step'