forked from prplfoundation/prplMesh
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
213 lines (191 loc) · 5.64 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
.in-prplmesh-builder:
image:
name: prplfoundationinc/prplmesh-builder:ubuntu-18.04
entrypoint: [""]
tags:
- docker
cppcheck:
stage: build
image: prplfoundationinc/prplmesh-builder:alpine-3.11.3
script:
# cppcheck runs in the alpine image because every new release brings useful improvements
# (the versions from Ubuntu get old too quickly)
- tools/docker/static-analysis/cppcheck.sh common framework controller
artifacts:
paths:
- cppcheck_results.txt
when: always
tags:
- docker
flake8:
stage: build
image: pipelinecomponents/flake8:f087c4c
variables:
FLAKE8_FILES: "tests/capi.py"
script:
- flake8 --verbose $FLAKE8_FILES
flake8-diff:
stage: build
image: pipelinecomponents/flake8:f087c4c
script:
- apk add --update --no-cache git
- git diff -U0 origin/master | flake8 --verbose --diff
clang-format:
extends: .in-prplmesh-builder
stage: build
script:
# Run clang-format and check there are no modified files
- ./clang-format.sh
# `diff-index` doesn't update the index so doesn't actually see changes. Need to manually update index.
- git update-index -q --refresh
# Use `diff-index` instead of `status` or `diff` because it gives more predictable output and exit code.
- |
git diff-index --exit-code HEAD || {
ret=$?
echo "Inconsistent formatting, please apply patch from artifacts"
git diff > correct-formatting.patch
exit $ret
}
artifacts:
paths:
- correct-formatting.patch
when: on_failure
build-in-docker:
extends: .in-prplmesh-builder
stage: build
variables:
CMAKE_BUILD_TYPE: "Release"
EXTRA_CMAKE_FLAGS: ""
script:
- cmake -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_INSTALL_PREFIX=build/install \
$EXTRA_CMAKE_FLAGS -H. -Bbuild -G Ninja
- ninja -C build install
# Check that the AutoGenerated files are correct by checking git status
- git update-index -q --refresh
- git diff-index --exit-code HEAD
artifacts:
paths:
- build/install
build-in-docker-alpine:
extends: build-in-docker
image: prplfoundationinc/prplmesh-builder:alpine-3.11.3
only:
- schedules
build-in-docker-static:
extends: build-in-docker
variables:
EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=OFF"
.run-test-in-docker:
stage: test
extends: .in-prplmesh-builder
script:
- cd build/install
- ./bin/tests/${CI_JOB_NAME}
needs:
- job: build-in-docker
tlvf_test:
extends: .run-test-in-docker
run-tests:
stage: test
image: $CI_REGISTRY_IMAGE/tests-runner:18.09.7-dind
script:
# Try to pull from dockerhub, if it fails, the run should fail
- tools/docker/image-pull.sh
- tests/test_flows.py -v -u $RANDOM
artifacts:
paths:
- logs
when: always
tags:
- docker
- docker-build
after_script:
- tools/docker/stop.sh -k -r
needs:
- job: build-in-docker
.build-for-openwrt:
stage: build
script:
- mkdir -p "build/$TARGET_DEVICE"
- tools/docker/builder/openwrt/build.sh -v -d "$TARGET_DEVICE" -t "prplmesh-builder-$TARGET_DEVICE:$CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID" 2>&1 | tee "build/$TARGET_DEVICE/openwrt-build.log" | grep -E '^[[:blank:]]?make\[[12]\]|^Step|^ --->' --color=never --line-buffered
artifacts:
paths:
- "build/$TARGET_DEVICE/"
expire_in: 4 weeks
when: always
tags:
- shell
- docker-build
.test-on-target:
stage: test
before_script:
# we need a list of all the targets to be able to kill them
- ALL_TARGETS="turris-omnia-1 glinet-b1300-1 netgear-rax40-1"
# kill prplmesh on each target to make sure they don't interfere with the test
- for i in $ALL_TARGETS ; do ssh "$i" 'pgrep -f beerocks | xargs kill -9 2>/dev/null' || true ; done
script:
- tools/deploy_ipk.sh $TARGET_DEVICE_NAME "build/$TARGET_DEVICE/"prplmesh.ipk
- tests/openwrt/test_status.sh $TARGET_DEVICE_NAME
artifacts:
paths:
- ${TARGET_DEVICE_NAME}_logs.tar.gz
- ${TARGET_DEVICE_NAME}_diags.log
when: always
tags:
- targets
build-for-turris-omnia:
extends: .build-for-openwrt
variables:
TARGET_DEVICE: "turris-omnia"
build-for-glinet-b1300:
extends: .build-for-openwrt
variables:
TARGET_DEVICE: "glinet-b1300"
build-for-netgear-rax40:
extends: .build-for-openwrt
variables:
TARGET_DEVICE: "netgear-rax40"
test-on-turris-omnia:
extends: .test-on-target
variables:
TARGET_DEVICE: turris-omnia
TARGET_DEVICE_NAME: turris-omnia-1
needs: ["build-for-turris-omnia"]
test-on-glinet-b1300:
extends: .test-on-target
variables:
TARGET_DEVICE: glinet-b1300
TARGET_DEVICE_NAME: glinet-b1300-1
needs: ["build-for-glinet-b1300"]
test-on-netgear-rax40:
extends: .test-on-target
variables:
TARGET_DEVICE: netgear-rax40
TARGET_DEVICE_NAME: netgear-rax40-1
needs: ["build-for-netgear-rax40"]
run-certification-tests:
stage: test
variables:
# TESTS_TO_RUN needs to be set by the user (or the pipeline schedule)
GIT_CLONE_PATH: "/builds/prpl-foundation/prplMesh/"
# device to test with: prplmesh for dummy bwl, netgear-rax40 for dwpal on rax40
DEVICE_UNDER_TEST: prplmesh
script:
- |
if [ "$DEVICE_UNDER_TEST" != prplmesh ] ; then
echo "Deploying to $DEVICE_UNDER_TEST"
tools/deploy_ipk.sh --certification-mode $DEVICE_UNDER_TEST build/$DEVICE_UNDER_TEST/prplmesh.ipk
fi
- /easymesh_cert/run_test_file.sh -o logs -d $DEVICE_UNDER_TEST $TESTS_TO_RUN
artifacts:
paths:
- logs
when: always
needs:
- job: build-in-docker
- job: build-for-netgear-rax40
tags:
- certs-tests
timeout: 24h
rules:
- if: '$TESTS_TO_RUN'