This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
.gitlab-ci.yml
211 lines (196 loc) · 5.38 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
image: zephyrprojectrtos/ci:v0.26.5
variables:
MODULE_PATH: modules/lib/golioth
WEST_MANIFEST: .ci-west-zephyr.yml
.west-init: &west-init
- rm -rf .west $MODULE_PATH
- west init -m $CI_REPOSITORY_URL --mf ${WEST_MANIFEST} --mr $CI_COMMIT_REF_NAME
- (cd $MODULE_PATH; 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
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
.west-prepare:
variables:
GIT_STRATEGY: none
needs: []
cache:
<<: *cache-deps
policy: pull
before_script:
- *west-init
- west update -o=--depth=1 -n
- git config --global user.email [email protected]
- git config --global user.name "Git User"
- west patch
.west-build:
extends: .west-prepare
stage: build
cache-deps:
extends: .west-build
stage: cache
cache:
<<: *cache-deps
policy: pull-push
script:
- rm -rf $MODULE_PATH
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
checkpatch:
extends: [.check, .west-prepare]
before_script:
- *west-init
- west update $MODULE_PATH
- >
west update zephyr -o=--depth=1 -n
script:
- cd $MODULE_PATH
- git fetch
- CHECKPATCH="../../../zephyr/scripts/checkpatch.pl --color=always --quiet"
- EXITCODE=0
- $CHECKPATCH --git origin/$CI_DEFAULT_BRANCH.. || EXITCODE=$?
- exit $EXITCODE
gitlint:
extends: .check
variables:
GIT_DEPTH: 0
script:
- gitlint --commits origin/$CI_DEFAULT_BRANCH..
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/$CI_DEFAULT_BRANCH..`; 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/**/*.log
reports:
junit: reports/**/twister.xml
#
# Job depends on following environment variables:
# - GOLIOTH_PROJECT_ID: used to setup 'golioth' Python script (in this job script)
# - GOLIOTH_DEVICE_NAME: used by 'golioth' Python script (in tests scripts)
#
# - GOLIOTH_SYSTEM_SERVER_HOST: used to setup 'golioth' Python script (in this job script) and by device firmware
# - GOLIOTH_SYSTEM_SERVER_API_PORT: used to setup 'golioth' Python script (in this job script)
#
# - GOLIOTH_SAMPLE_HARDCODED_PSK_ID: used by device firmware
# - GOLIOTH_SAMPLE_HARDCODED_PSK: used by device firmware
#
# It is also assumed that a self-hosted goliothd is used and there is no authentication required by
# 'golioth' Python script 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_SAMPLE_HARDCODED_PSK_ID} and ${GOLIOTH_SAMPLE_HARDCODED_PSK} as
# DTLS credentials.
#
twister-qemu-goliothd:
extends: .twister
tags: [dev-tun]
resource_group: goliothd
script:
# Set credentials to goliothd
- mkdir -p ${HOME}/.golioth
- |
cat << EOF > ${HOME}/.golioth/.goliothctl.yaml
apiurl: http://${GOLIOTH_SYSTEM_SERVER_HOST}:${GOLIOTH_SYSTEM_SERVER_API_PORT}
projectid: ${GOLIOTH_PROJECT_ID}
EOF
# Install samples/tests requirements
- pip3 install -r modules/lib/golioth/scripts/requirements-tests.txt
- pip3 install git+https://github.com/golioth/[email protected]
# 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
--overflow-as-errors
-t goliothd
-j 1
-p qemu_x86
-o reports
-T $MODULE_PATH
artifacts:
reports:
junit: reports/**/twister_report.xml
twister:
extends: .twister
script:
- west blobs fetch hal_espressif
- rm -rf reports twister-out
# Build and run all non-goliothd samples/tests
- >
zephyr/scripts/twister
--force-color
--no-clean
--overflow-as-errors
-e goliothd
-p esp32_devkitc_wroom
-p nrf52840dk_nrf52840
-p qemu_x86
-o reports/non_goliothd
-T $MODULE_PATH
# Build-only all goliothd samples/tests
- >
zephyr/scripts/twister
--force-color
--no-clean
--overflow-as-errors
-t goliothd -b
-p esp32_devkitc_wroom
-p nrf52840dk_nrf52840
-p qemu_x86
-o reports/goliothd
-T $MODULE_PATH
twister-ncs:
extends: .twister
variables:
WEST_MANIFEST: west-ncs.yml
script:
- >
zephyr/scripts/twister
--force-color
--overflow-as-errors
-p nrf9160dk_nrf9160_ns
-o reports
-T $MODULE_PATH