forked from golioth/golioth-zephyr-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
217 lines (202 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
image: zephyrprojectrtos/ci:v0.24.2
variables:
WEST_MANIFEST: .ci-west-zephyr.yml
.west-init: &west-init
- rm -rf .west modules/lib/golioth
- west init -m $CI_REPOSITORY_URL --mf ${WEST_MANIFEST} --mr $CI_COMMIT_REF_NAME
- (cd modules/lib/golioth; git checkout $CI_COMMIT_SHA)
.cache-deps: &cache-deps
key: west-modules
paths:
- bootloader
- modules
- tools
- zephyr
stages:
- cache
- check
- build
- test
.check:
stage: check
needs: []
allow_failure: true
except:
- main
- tags
.west-prepare:
variables:
GIT_STRATEGY: none
needs: []
cache:
<<: *cache-deps
policy: pull
before_script:
- *west-init
- >
west update -o=--depth=1 -n ||
(west forall -c 'git clean -ffdx && git reset --hard' &&
west update -o=--depth=1 -n)
- west forall -c 'git clean -ffdx && git reset --hard'
- west patch --apply
.west-build:
extends: .west-prepare
stage: build
cache-deps:
extends: .west-build
stage: cache
cache:
<<: *cache-deps
policy: pull-push
script:
- west forall -c 'git clean -ffdx && git reset --hard'
- rm -rf modules/lib/golioth
only:
refs:
- main
checkpatch:
extends: [.check, .west-prepare]
before_script:
- *west-init
- west update modules/lib/golioth
- >
west update zephyr -o=--depth=1 -n ||
(west forall -c 'git clean -ffdx && git reset --hard' &&
west update zephyr -o=--depth=1 -n)
- west forall -c 'git clean -ffdx && git reset --hard'
script:
- cd modules/lib/golioth
- git fetch
- CHECKPATCH="../../../zephyr/scripts/checkpatch.pl --color=always --quiet"
- EXITCODE=0
- $CHECKPATCH --git origin/main.. || EXITCODE=$?
- exit $EXITCODE
gitlint:
extends: .check
variables:
GIT_DEPTH: 0
script:
- pip3 install gitlint
- gitlint --commits origin/main..
pre-commit:
extends: .check
variables:
GIT_DEPTH: 0
script:
- pip3 install pre-commit
- |
CODE=0 # run pre-commit
for CID in `git rev-list --reverse origin/main..`; do
git show $CID -s --format=' pre-commit %h ("%s")'
git checkout -f -q $CID
pre-commit run --color always --show-diff-on-failure --from-ref $CID^ --to-ref $CID || CODE=$?
done
exit $CODE
.twister:
extends: .west-prepare
stage: test
artifacts:
when: always
paths:
- reports/*
- twister-out/**/build.log
- twister-out/**/handler.log
reports:
junit: reports/twister.xml
#
# Job depends on following environment variables:
# - GOLIOTH_PROJECT_ID: used by 'goliothctl' (in this job script)
# - GOLIOTH_DEVICE_NAME: used by 'goliothctl' (in tests scripts)
#
# - GOLIOTH_SYSTEM_SERVER_HOST: used by 'goliothctl' (in this job script) and by device firmware
# - GOLIOTH_SYSTEM_SERVER_API_PORT: used by 'goliothctl' (in this job script)
#
# - GOLIOTH_SYSTEM_CLIENT_PSK_ID: used by device firmware
# - GOLIOTH_SYSTEM_CLIENT_PSK: used by device firmware
#
# It is also assumed that a self-hosted goliothd is used and there is no authentication required by
# 'goliothctl' at api URL http://${GOLIOTH_SYSTEM_SERVER_HOST}:${GOLIOTH_SYSTEM_SERVER_API_PORT}.
#
# Project with id ${GOLIOTH_PROJECT_ID} needs to exist and device with ${GOLIOTH_DEVICE_NAME} name
# needs to be provisioned with ${GOLIOTH_SYSTEM_CLIENT_PSK_ID} and ${GOLIOTH_SYSTEM_CLIENT_PSK} as
# DTLS credentials.
#
twister-qemu-goliothd:
extends: .twister
tags: [dev-tun]
resource_group: goliothd
script:
# Download 'goliothctl' and expose to $PATH
- mkdir -p bin
- >
wget https://storage.googleapis.com/golioth-cli-releases/goliothctl/latest/goliothctl_latest_linux_64bit.tar.gz
-O goliothctl.tar.gz
- tar -xzf goliothctl.tar.gz -C bin goliothctl
- PATH=$PWD/bin:$PATH
# Login to goliothd
- >
goliothctl --apiUrl "http://${GOLIOTH_SYSTEM_SERVER_HOST}:${GOLIOTH_SYSTEM_SERVER_API_PORT}"
config set projectId ${GOLIOTH_PROJECT_ID}
- goliothctl project list
# Install samples/tests requirements
- pip3 install -r modules/lib/golioth/scripts/requirements-tests.txt
- pip3 install modules/lib/golioth/scripts/python/golioth
# Start QEMU networking utilities
- make -C tools/net-tools tunslip6
- tools/net-tools/loop-socat.sh &
- sleep 1
- sudo tools/net-tools/loop-slip-tap.sh &
- sleep 1
# Setup port forwarding for external network access and start network traffic recording
- apt-get update && apt-get install -y iptables tshark
- modules/lib/golioth/scripts/nat_config.py tap0
- mkdir -p reports
- tshark -f 'port 5684' -w reports/traffic.pcapng &
# Run tests
- >
zephyr/scripts/twister
--force-color
-vvv
-t goliothd
-j 1
-p qemu_x86
-o reports
-T modules/lib/golioth
artifacts:
reports:
junit: reports/twister_report.xml
twister:
extends: .twister
script:
- west blobs fetch hal_espressif
# Build and run all non-goliothd samples/tests
- >
zephyr/scripts/twister
--force-color
-e goliothd
-p esp32
-p nrf52840dk_nrf52840
-p qemu_x86
-o reports
-T modules/lib/golioth
# Build-only all goliothd samples/tests
- >
zephyr/scripts/twister
--force-color
-t goliothd -b
-p esp32
-p nrf52840dk_nrf52840
-p qemu_x86
-o reports
-T modules/lib/golioth
twister-ncs:
extends: .twister
variables:
WEST_MANIFEST: west-ncs.yml
script:
- >
zephyr/scripts/twister
--force-color
-p nrf9160dk_nrf9160_ns
-o reports
-T modules/lib/golioth