-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
197 lines (167 loc) · 5.57 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
# 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/
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/wsp
stages:
- clean
- build
- test
- deploy
build:alltests_pi:
tags:
- raspberrypi
only:
- schedules
- merge_requests
stage: build
script:
- rm -f $CI_PROJECT_DIR/test/unit/bin/*
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Debug ..
- cmake --build . --target test_all_unit
artifacts:
paths:
- $CI_PROJECT_DIR/build/test/CMakeFiles/test_all_unit.dir/__/src
- $CI_PROJECT_DIR/test/unit/bin
after_script:
- sudo chown -R gitlab-runner:gitlab-runner $CI_PROJECT_DIR/build
when: manual
test:alltests_pi:
tags:
- raspberrypi
only:
- schedules
- merge_requests
stage: test
before_script:
- sudo killall 'weatherStationPlus' || echo "No process found"
script:
- cd test/unit/bin
- sudo ./test_all_unit --gtest_filter=*:-RetrieveSensorData.store_* --gtest_output="xml:report.xml"
- sudo chown -R gitlab-runner:gitlab-runner $CI_PROJECT_DIR/build/test/CMakeFiles/test_all_unit.dir/__/src/
- cd $CI_PROJECT_DIR/build
- mkdir coverage
- gcovr -r .. -e "../include/easylogging*" -e "../src/logging/*" --html --html-details -o coverage/weatherstation.html
- gcovr -r .. -e "../include/easylogging*" -e "../src/logging/*"
dependencies:
- build:alltests_pi
artifacts:
paths:
- $CI_PROJECT_DIR/build/coverage
reports:
junit: $CI_PROJECT_DIR/test/unit/bin/report.xml
when: manual
clean_docker:
tags:
- crossplatform
only:
- schedules
- merge_requests
stage: clean
script:
- docker-compose down
- docker-compose up -d
build:alltests_quick:
tags:
- crossplatform
only:
- schedules
- merge_requests
stage: build
script:
- docker cp . arm_v6_raspberrypi_one:/home/gitlab-runner/builds/wsp
- docker exec -i --user gitlab-runner arm_v6_raspberrypi_one bash -c "cd /home/gitlab-runner/builds/wsp && mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .."
- docker exec -i --user gitlab-runner arm_v6_raspberrypi_one bash -c "cd /home/gitlab-runner/builds/wsp && mkdir -p build && cd build && cmake --build . --target test_all_unit -j 4"
- docker cp arm_v6_raspberrypi_one:/home/gitlab-runner/builds/wsp/test/unit/bin/test_all_unit test/unit/bin/test_all_unit
- mkdir -p build/test/CMakeFiles/test_all_unit.dir/__/
- docker cp arm_v6_raspberrypi_one:/home/gitlab-runner/builds/wsp/build/test/CMakeFiles/test_all_unit.dir/__/src build/test/CMakeFiles/test_all_unit.dir/__/src
artifacts:
paths:
- $CI_PROJECT_DIR/build/test/CMakeFiles/test_all_unit.dir/__/src
- $CI_PROJECT_DIR/test/unit/bin/test_all_unit
test:alltests_quick:
tags:
- raspberrypi
only:
- schedules
- merge_requests
stage: test
before_script:
- sudo killall 'weatherStationPlus' || echo "No process found"
script:
- cd test/unit/bin
- sudo -E ./test_all_unit --gtest_filter=*:-RetrieveSensorData.store_* --gtest_output="xml:report.xml"
- sudo chown -R gitlab-runner:gitlab-runner $CI_PROJECT_DIR/build/test/CMakeFiles/test_all_unit.dir/__/src/
- cd $CI_PROJECT_DIR/build
- mkdir coverage
- gcovr -r .. -e "../include/easylogging*" -e "../src/logging/*" --html --html-details -o coverage/weatherstation.html
- gcovr -r .. -e "../include/easylogging*" -e "../src/logging/*"
dependencies:
- build:alltests_quick
artifacts:
paths:
- $CI_PROJECT_DIR/build/coverage
reports:
junit: $CI_PROJECT_DIR/test/unit/bin/report.xml
after_script:
- sudo chown -R gitlab-runner:gitlab-runner $CI_PROJECT_DIR/build
build:mainapp_quick:
tags:
- crossplatform
only:
- schedules
- merge_requests
stage: build
script:
- docker cp . arm_v6_raspberrypi_one:/home/gitlab-runner/builds/wsp/
- docker exec -i --user gitlab-runner arm_v6_raspberrypi_one bash -c "cd /home/gitlab-runner/builds/wsp && mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .."
- docker exec -i --user gitlab-runner arm_v6_raspberrypi_one bash -c "cd /home/gitlab-runner/builds/wsp && mkdir -p build && cd build && cmake --build . --target weatherStationPlus -j 4"
- mkdir -p bin/debug
- docker cp arm_v6_raspberrypi_one:/home/gitlab-runner/builds/wsp/bin/debug/weatherStationPlus bin/debug/
artifacts:
paths:
- $CI_PROJECT_DIR/bin/debug/weatherStationPlus
deploy:
tags:
- raspberrypi
only:
- schedules
- merge_requests
stage: deploy
before_script:
- sudo systemctl stop wsp.service || echo "Failed to stop service"
script:
- sudo cp bin/debug/weatherStationPlus /opt/wsp/weatherStationPlus
- sudo cp wsp.service /etc/systemd/system/
- sudo systemctl daemon-reload
- sudo systemctl start wsp.service
- sleep 5s
- sudo systemctl is-active --quiet wsp
dependencies:
- build:mainapp_quick
environment:
name: staging
deploy_weatherstation:
tags:
- weatherstation
only:
- schedules
- merge_requests
stage: deploy
before_script:
- sudo systemctl stop wsp.service || echo "Failed to stop service"
script:
- sudo cp bin/debug/weatherStationPlus /opt/wsp/weatherStationPlus
- sudo cp wsp.service /etc/systemd/system/
- sudo systemctl daemon-reload
- sudo systemctl start wsp.service
- sleep 5s
- sudo systemctl is-active --quiet wsp
dependencies:
- build:mainapp_quick
environment:
name: live
when: manual