-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
306 lines (286 loc) · 8.03 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
stages:
- .pre
- ade
- build
- test
- deploy
.ade_base:
variables:
DOCKER_DRIVER: overlay2
ROS_DISTRO: foxy
UBUNTU_DISTRO: focal
stage: ade
image: docker
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- apk add --update-cache git
- mv ros-deps tools/ade_image
- cp autoware.auto.foxy.repos tools/ade_image
- cd tools/ade_image
- export ADE_SHA=$(find . -type f | sort | xargs sha256sum | sha256sum | rev | cut -c 4- | rev)
- '
if [[ -n "$FORCE" ]]; then
chmod og-w . -R;
docker build
--build-arg ROS_DISTRO=${ROS_DISTRO}
--build-arg CODENAME=${UBUNTU_DISTRO}
--label ade_image_commit_sha="$CI_COMMIT_SHA"
--label ade_image_commit_tag="$CI_COMMIT_TAG"
-t image .;
else
(
docker pull $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:change-$ADE_SHA &&
docker tag $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:change-$ADE_SHA image
) || (
chmod og-w . -R;
docker build
--build-arg ROS_DISTRO=${ROS_DISTRO}
--build-arg CODENAME=${UBUNTU_DISTRO}
--label ade_image_commit_sha="$CI_COMMIT_SHA"
--label ade_image_commit_tag="$CI_COMMIT_TAG"
-t image .;
);
fi
'
- docker tag image $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:change-$ADE_SHA
- docker tag image $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:commit-$CI_COMMIT_SHA
- docker tag image $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:change-$ADE_SHA
- docker push $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:commit-$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:$CI_COMMIT_REF_NAME
after_script:
- docker container rm -f $(docker container ls --filter "status=exited" -q)
- docker image rm $(docker image ls -q)
needs:
- gen_ros_deps_foxy
.build_base:
variables:
RMW_IMPLEMENTATION: rmw_cyclonedds_cpp
ROS_DISTRO: foxy
stage: build
image: $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:commit-$CI_COMMIT_SHA
script:
- 'apt-get update && apt-get -y --no-install-recommends install
clang-tidy
git
git-lfs
'
- 'git lfs install'
- 'git lfs pull --include="*" --exclude=""'
- 'vcs import < autoware.auto.$ROS_DISTRO.repos'
# build and test
- 'colcon build
--merge-install
--install-base /opt/AutowareAuto
--cmake-args -DCMAKE_BUILD_TYPE=Release
'
- chmod -R og-w /opt/AutowareAuto
- tar czf opt.tar.gz /opt/AutowareAuto
- grep -h -r -o -P "(?<=\<name\>).*(?=\<\/name\>)" $(find src/external -name package.xml) | sort >> external_deps.txt
artifacts:
name: "$CI_JOB_NAME"
paths:
- build/
- external_deps.txt
- opt.tar.gz
.gen_deps_base:
stage: .pre
script:
- apt-get update && apt-get install python3-vcstool
- vcs import < autoware.auto.$ROS_DISTRO.repos
- rosdep update
- rosdep install --as-root "apt:false pip:false" --simulate --reinstall --ignore-src -y --from-paths src | sort >> ros-deps
artifacts:
name: "$CI_JOB_NAME"
paths:
- ros-deps
.test_base:
variables:
RMW_IMPLEMENTATION: rmw_cyclonedds_cpp
ROS_DISTRO: foxy
stage: test
image: $CI_REGISTRY_IMAGE/$ARCH/ade-$ROS_DISTRO:commit-$CI_COMMIT_SHA
script:
- tar xzf opt.tar.gz -C /
- rm opt.tar.gz
- source /opt/AutowareAuto/setup.bash
- 'colcon test
--merge-install
--install-base /opt/AutowareAuto
--packages-skip $(cat external_deps.txt)
--return-code-on-test-failure
'
- 'colcon test-result --all |grep xml |cut -d":" -f1 |xargs .gitlab-ci/merge-test-results test-results.xml || true'
# Test package
- 'ros2 run autoware_auto_create_pkg main.py
--pkg-name my_cool_pkg
--destination /tmp/tmp_ws/src
--description "My cool package does cool stuff"
--maintainer "Jane Doe"
--email "[email protected]"
'
- cd /tmp/tmp_ws
- colcon build --packages-select my_cool_pkg
- colcon test --packages-select my_cool_pkg
- cd -
# prepare volume artifact
- mkdir /opt/AutowareAuto/src
- '(cd src && git archive --format=tar HEAD | (cd /opt/AutowareAuto/src && tar xf -))'
- cp -a LICENSE /opt/AutowareAuto
- chmod -R og-w /opt/AutowareAuto
- tar cfz opt.tar.gz /opt/AutowareAuto
after_script:
- colcon test-result --verbose
artifacts:
name: "$CI_JOB_NAME"
paths:
- log
- opt.tar.gz
reports:
junit: test-results.xml
.volume_base:
variables:
DOCKER_DRIVER: overlay2
RMW_IMPLEMENTATION: rmw_cyclonedds_cpp
ROS_DISTRO: foxy
UBUNTU_DISTRO: focal
stage: deploy
image: docker
services:
- docker:dind
script:
- 'echo -e "*\n!opt.tar.gz" > .dockerignore'
- |
cat >Dockerfile <<EOF
FROM alpine
ADD opt.tar.gz /
VOLUME /opt/AutowareAuto
CMD ["/bin/sh", "-c", "trap 'exit 147' TERM; tail -f /dev/null & wait ${!}"]
EOF
- 'docker build
--build-arg ROS_DISTRO=${ROS_DISTRO}
--build-arg CODENAME=${UBUNTU_DISTRO}
--label ade_image_commit_sha="$CI_COMMIT_SHA"
--label ade_image_commit_tag="$CI_COMMIT_TAG"
-t image .
'
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker tag image $CI_REGISTRY_IMAGE/$ARCH/binary-$ROS_DISTRO:commit-$CI_COMMIT_SHA
- docker tag image $CI_REGISTRY_IMAGE/$ARCH/binary-$ROS_DISTRO:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE/$ARCH/binary-$ROS_DISTRO:commit-$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE/$ARCH/binary-$ROS_DISTRO:$CI_COMMIT_REF_NAME
after_script:
- docker container rm -f $(docker container ls --filter "status=exited" -q)
- docker image rm $(docker image ls -q)
.arm64:
variables:
ARCH: arm64
tags:
- arm64
only:
- branches@autowarefoundation/autoware.auto/AutowareAuto
- tags@autowarefoundation/autoware.auto/AutowareAuto
gen_ros_deps_foxy:
image: ros:foxy
extends: .gen_deps_base
ade_amd64_foxy:
variables:
ARCH: amd64
extends: .ade_base
ade_arm64_foxy:
extends:
- .arm64
- .ade_base
build_amd64_foxy:
variables:
ARCH: amd64
tags:
- shared
extends: .build_base
needs:
- job: ade_amd64_foxy
build_arm64_foxy:
extends:
- .arm64
- .build_base
needs:
- job: ade_arm64_foxy
test_amd64_foxy:
variables:
ARCH: amd64
tags:
- shared
extends: .test_base
needs:
- build_amd64_foxy
test_arm64_foxy:
extends:
- .arm64
- .test_base
needs:
- build_arm64_foxy
coverage:
stage: test
image: $CI_REGISTRY_IMAGE/amd64/ade-foxy:commit-$CI_COMMIT_SHA
tags:
- shared
script:
- 'apt-get update && apt-get -y --no-install-recommends install
clang-tidy
git
git-lfs
'
- 'git lfs install'
- 'git lfs pull --include="*" --exclude=""'
- 'vcs import < autoware.auto.$ROS_DISTRO.repos'
- './tools/coverage/coverage.sh -u'
after_script:
- colcon test-result --verbose
artifacts:
name: "$CI_JOB_NAME"
paths:
- coverage
- log
coverage: /\s*lines.*:\s(\d+\.\d+\%\s\(\d+\sof\s\d+.*\))/
needs:
- ade_amd64_foxy
docs:
stage: build
image: $CI_REGISTRY_IMAGE/amd64/ade-foxy:commit-$CI_COMMIT_SHA
script:
- docs/.doxygen/build.py
artifacts:
name: "$CI_JOB_NAME"
paths:
- docs/_build/html
needs:
- ade_amd64_foxy
pages:
stage: deploy
image: alpine
script:
- mv docs/_build/html public
- mv coverage public
artifacts:
name: "$CI_JOB_NAME"
paths:
- public
only:
- master
needs:
- coverage
- docs
volume_amd64_foxy:
variables:
ARCH: amd64
extends: .volume_base
needs:
- test_amd64_foxy
volume_arm64_foxy:
extends:
- .arm64
- .volume_base
needs:
- test_arm64_foxy