-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
86 lines (78 loc) · 2.27 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
# NOTE: customize `example-project-image` name below before deploying to a new
# project.
# NOTE: if you modify this file, be sure to build and push the new image tag to
# the corresponding GitLab project's container registry:
#
# $ docker login <gitlab_registry_url>
# $ docker build -t <gitlab_registry_url>/<group>/<project> .
# $ docker push <gitlab_registry_url>/<group>/<project>
# $ docker logout
#
# image: "<gitlab_registry_url>/toolchain/cmake-project-template"
stages:
- build
- test
- quality_metrics
variables:
CMAKE_FLAGS_BUILD: "-DCMAKE_BUILD_TYPE=Debug"
CMAKE_FLAGS_STATIC_ANALYSIS: >
-DCMAKE_C_CLANG_TIDY=clang-tidy;-warnings-as-errors=*
-DCMAKE_CXX_CLANG_TIDY=clang-tidy;-warnings-as-errors=*
-DCMAKE_C_CPPLINT=cpplint;--quiet
-DCMAKE_CXX_CPPLINT=cpplint;--quiet
FAIL_BUILD_ON_VIOLATION: "True" # fail job on static analysis violation
CMAKE_FLAGS_COVERAGE: "-DCODE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug"
build:
stage: build
tags:
- docker # gitlab runner instance: docker executor with 'docker' tag
script:
- mkdir -p build && cd build
- cmake $CMAKE_FLAGS_BUILD ..
- cmake --build .
artifacts:
paths:
- build
# it's most likely a good idea to cache outputs to reduce the build time
cache:
paths:
- build
# run tests using the binary built before
test:
stage: test
needs: ["build"]
tags:
- docker
script:
- cd build
- ctest --build-config Debug --test-action test --output-on-failure
static_analysis:
stage: quality_metrics
needs: []
tags:
- docker
script:
- mkdir -p build_static_analysis && cd build_static_analysis
- cmake $CMAKE_FLAGS_STATIC_ANALYSIS ..
- cmake --build .
artifacts:
paths:
- build_static_analysis
coverage:
stage: quality_metrics
needs: []
tags:
- docker
script:
- mkdir -p build_coverage && cd build_coverage
- cmake $CMAKE_FLAGS_COVERAGE ..
- cmake --build . --target ctest_coverage
# generate coverage.xml:
- cd ..
- python3 -m lcov_cobertura build_coverage/ctest_coverage.info --base-dir=./ --output=build_coverage/coverage.xml
coverage: '/lines[\.]+\: (\d+\.\d+)\%/'
artifacts:
paths:
- build_coverage
reports:
cobertura: build_coverage/coverage.xml # coverage report