This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
175 lines (161 loc) · 4.22 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
# This file is a template, and might need editing before it works on your project.
# use the official gcc image, based on debian
# can use verions as well, like gcc:5.2
# see https://hub.docker.com/_/gcc/
#
# This base image is based on debian:buster-slim and contains:
# * gcc 8.3.0
# * clang 7.0.1
# * cmake 3.13.4
# * and more
#
# For details see https://github.com/ska-telescope/cpp_build_base
#
image: nexus.engageska-portugal.pt/ska-docker/cpp_build_base
variables:
# Needed if you want automatic submodule checkout
# For details see https://docs.gitlab.com/ee/ci/yaml/README.html#git-submodule-strategy
GIT_SUBMODULE_STRATEGY: normal
.common: {tags: [engageska, docker]}
stages:
- build
- linting
- test
- pages
build_debug:
extends: .common
stage: build
# instead of calling g++ directly you can also use some build toolkit like make
# install the necessary build tools when needed
script:
- mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-coverage" -DCMAKE_EXE_LINKER_FLAGS="-coverage"
- make
artifacts:
paths:
- build
build_release:
extends: .common
stage: build
script:
- mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Release
- make
artifacts:
paths:
- build
build_export_compile_commands:
extends: .common
stage: build
script:
- rm -rf build && mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_COMPILER=clang++
artifacts:
paths:
- build
lint_clang_tidy:
extends: .common
stage: linting
dependencies:
- build_export_compile_commands
script:
- cd build
- run-clang-tidy -checks='cppcoreguidelines-*,performance-*,readibility-*,modernize-*,misc-*,clang-analyzer-*,google-*'
lint_iwyu:
extends: .common
stage: linting
dependencies:
- build_export_compile_commands
script:
- cd build
- iwyu_tool -p .
lint_cppcheck:
extends: .common
stage: linting
dependencies:
- build_export_compile_commands
script:
- cd build
- cppcheck --error-exitcode=1 --project=compile_commands.json -q --std=c++14 -i $PWD/../external -i $PWD/../src/ska/helloworld/test
test:
extends: .common
stage: test
dependencies:
- build_debug
script:
- cd build
- ctest -T test --no-compress-output
after_script:
- cd build
- ctest2junit > ctest.xml
artifacts:
paths:
- build/
reports:
junit: build/ctest.xml
test_installation:
extends: .common
stage: test
dependencies:
- build_release
script:
- cd build
- cmake . -DCMAKE_INSTALL_PREFIX=/opt
- make install
- cd ../examples/helloworld-user
- if [ -d build ]; then rm -rf build; fi
- mkdir build
- cd build
- cmake .. -DCMAKE_PREFIX_PATH=/opt
- make all
test_as_subproject:
extends: .common
stage: test
script:
- cp -r examples/helloworld-user ..
- cd ../helloworld-user
- sed -i 's/find_package(HelloWorld)/add_subdirectory(..\/cpp-template helloworld EXCLUDE_FROM_ALL)/' CMakeLists.txt
- if [ -d build ]; then rm -rf build; fi
- mkdir build
- cd build
- cmake ..
- make all
# A job that runs the tests under valgrid
# It might take a while, so not always run by default
test_memcheck:
extends: .common
stage: test
dependencies:
- build_debug
before_script:
- apt update && apt install -y valgrind
script:
- cd build
- ctest -T memcheck
only:
- tags
- schedules
pages:
extends: .common
stage: pages
dependencies:
- test
before_script:
- apt update && apt install -y curl
script:
- mkdir -p .public/build/reports
- cd .public
- gcovr -r ../ -e '.*/external/.*' -e '.*/CompilerIdCXX/.*' -e '.*/tests/.*' --html --html-details -o index.html
- gcovr -r ../ -e '.*/external/.*' -e '.*/CompilerIdCXX/.*' -e '.*/tests/.*' --xml -o build/reports/code-coverage.xml
- cp ../build/ctest.xml build/reports/unit-tests.xml
# Create and upload GitLab badges
- python ../.produce-ci-metrics.py build/reports > ci-metrics.json
- curl -s https://gitlab.com/ska-telescope/ci-metrics-utilities/raw/master/scripts/ci-badges-func.sh | sh
- cd ..
- mv .public public
artifacts:
paths:
- public