-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.drone.yml
190 lines (163 loc) · 4.29 KB
/
.drone.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
---
kind: pipeline
type: docker
name: build_files
steps:
- name: build_tests
image: monotok/wsp:3.0.1
volumes:
- name: cache
path: /wsp
commands:
- ver=$( cat version.txt)
- echo $ver
- changes=`awk -v ver=$ver '/^## Version / { if (p) { exit }; if ($3 == ver) { p=1; next } } p && NF' CHANGELOG.md`
- mkdir -p build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Debug ..
- cmake --build . --target test_all_unit -j 4
- cmake --build . --target weatherStationPlus -j 4
- cp ../test/unit/bin/test_all_unit /wsp/test_all_unit
- cp ../bin/debug/weatherStationPlus /wsp/weatherStationPlus
- name: copy test to test raspberry pi
image: appleboy/drone-scp
volumes:
- name: cache
path: /wsp
settings:
host: 172.16.20.105
username: drone_ci
password:
from_secret: test_pi_password
port: 22
target: /home/drone_ci/
source: /wsp/test_all_unit
when:
event:
exclude:
- tag
- name: copy weather station to test raspberry pi
image: appleboy/drone-scp
volumes:
- name: cache
path: /wsp
settings:
host: 172.16.20.105
username: drone_ci
password:
from_secret: test_pi_password
port: 22
target: /home/drone_ci/
source: /wsp/weatherStationPlus
when:
event:
exclude:
- tag
- name: gitea_release
image: plugins/gitea-release
settings:
api_key:
from_secret: gitea_release
base_url: https://vcs.monotok.org
files: /wsp/weatherStationPlus
title: ${DRONE_TAG##v}
note: ${DRONE_COMMIT_MESSAGE}
when:
event: tag
trigger:
event:
- pull_request
- tag
- cron
volumes:
- name: cache
temp: {}
node:
server: build
---
kind: pipeline
type: exec
name: test
platform:
os: linux
arch: arm
steps:
- name: run tests
commands:
- chmod +x /home/drone_ci/wsp/test_all_unit
- /home/drone_ci/wsp/test_all_unit
- name: deploy test weather station
commands:
- ver=$( cat version.txt)
- echo $ver
- cp /home/drone_ci/wsp/weatherStationPlus /opt/wsp/weatherStationPlus_$ver
- cp /opt/wsp/weatherStationPlus_$ver /mnt/software/Artifact_Repository/WeatherStationPlus/
- chmod +x /opt/wsp/weatherStationPlus_$ver
- mv /opt/wsp/weatherStationPlus /opt/wsp/weatherStationPlus.bak || echo "Nothing to backup"
- ln -s /opt/wsp/weatherStationPlus_$ver /opt/wsp/weatherStationPlus
- mkdir -p /opt/wsp/yang
- cp yang/settings.yang /opt/wsp/yang/settings.yang
- mkdir -p /opt/wsp/conf
- cp test/settings.xml /opt/wsp/conf/settings.xml
- cp wsp.service /etc/systemd/system/wsp.service
- systemctl daemon-reload
- systemctl restart wsp.service
- name: check if weather station running
commands:
- sleep 20
- systemctl is-active --quiet wsp
- name: shutdown weather station
commands:
- systemctl stop wsp.service
when:
status:
- success
- failure
trigger:
event:
- pull_request
- cron
node:
server: test
depends_on:
- build_files
---
kind: pipeline
type: exec
name: deploy
platform:
os: linux
arch: arm
steps:
- name: disable and stop weather station
commands:
- systemctl stop wsp.service
- systemctl disable wsp.service
- name: deploy test weather station
commands:
- ver=$( cat version.txt)
- cp /mnt/software/Artifact_Repository/WeatherStationPlus/weatherStationPlus_$ver /opt/wsp/weatherStationPlus_$ver
- chmod +x /opt/wsp/weatherStationPlus_$ver
- mv /opt/wsp/weatherStationPlus /opt/wsp/weatherStationPlus.bak || echo "Nothing to backup"
- ln -s /opt/wsp/weatherStationPlus_$ver /opt/wsp/weatherStationPlus
- mkdir -p /opt/wsp/yang
- cp yang/settings.yang /opt/wsp/yang/settings.yang
- cp wsp.service /etc/systemd/system/wsp.service
- systemctl daemon-reload
- systemctl start wsp.service
- name: check if weather station running
commands:
- sleep 20
- systemctl is-active --quiet wsp
- name: enable weather station
commands:
- systemctl enable wsp.service
trigger:
event:
- promote
target:
- production
node:
server: prod
depends_on:
- test