forked from mendersoftware/mender-convert
-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
253 lines (226 loc) · 9.1 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
variables:
DOCKER_REPOSITORY: mendersoftware/mender-convert
S3_BUCKET_NAME: mender-convert-images
# These variables are present elsewhere in the repository too. Make sure to
# search for and change them too.
MENDER_ARTIFACT_VERSION: master
MENDER_CLIENT_VERSION: latest
MENDER_ADDON_CONNECT_VERSION: latest
MENDER_ADDON_CONFIGURE_VERSION: latest
# Make sure to update the link in mender-docs to the new one when changing
# this.
RASPBIAN_URL: https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-01-12/2021-01-11-raspios-buster-armhf-lite.zip
RASPBIAN_NAME: 2021-01-11-raspios-buster-armhf-lite
DEBIAN_FRONTEND: noninteractive
# Docker dind configuration.
# To use dind, make sure gitlab-runner's configuration
# has a common mount for /certs (i.e. runners.docker.volumes) directory
# and that the dind service name is always docker (default hostname).
DOCKER_HOST: "tcp://docker:2376"
DOCKER_CERT_PATH: "/certs/client"
DOCKER_TLS_VERIFY: "1"
DOCKER_TLS_CERTDIR: "/certs"
include:
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-commits.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-license.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-github-status-updates.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-shell-format.yml'
stages:
- test
- build
- convert
- test_acceptance
- publish
build:
stage: build
needs: []
image: docker:git
services:
- docker:19.03.5-dind
script:
- IMAGE_NAME=$DOCKER_REPOSITORY:pr ./docker-build --build-arg MENDER_ARTIFACT_VERSION=${MENDER_ARTIFACT_VERSION}
- docker save $DOCKER_REPOSITORY:pr > image.tar
artifacts:
expire_in: 2w
paths:
- image.tar
test:check-shell-formatting:
before_script:
- SHELL_SCRIPTS=$(find mender-convert* modules configs scripts
-type f
-not -name "*.md"
-not -path "scripts/linkbot/*"
-not -wholename "scripts/test/*")
.template_convert_raspbian: &convert_raspbian
stage: convert
needs:
- job: build
artifacts: true
image: ubuntu:18.04
services:
- docker:19.03-dind
tags:
- mender-qa-slave
before_script:
- export AWS_ACCESS_KEY_ID=$TMP_STORAGE_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$TMP_STORAGE_AWS_SECRET_ACCESS_KEY
- apt update && apt install -yy bash wget unzip awscli docker.io
- export IMAGE_NAME=$DOCKER_REPOSITORY:pr
- docker load -i image.tar
- wget -q ${RASPBIAN_URL}
- unzip ${RASPBIAN_NAME}.zip
script:
- echo "MENDER_CLIENT_VERSION=${MENDER_CLIENT_VERSION}" > versions_override_config
- echo "MENDER_ADDON_CONNECT_VERSION=${MENDER_ADDON_CONNECT_VERSION}" >> versions_override_config
- echo "MENDER_ADDON_CONFIGURE_VERSION=${MENDER_ADDON_CONFIGURE_VERSION}" >> versions_override_config
- env MENDER_ARTIFACT_NAME=${RASPBIAN_NAME}-mender-${MENDER_CLIENT_VERSION}
./docker-mender-convert -d ${RASPBIAN_NAME}.img
-c configs/${RASPBERRYPI_PLATFORM}_config
-c configs/images/raspberrypi_raspbian_config
-c versions_override_config
# Upload to temporary S3 bucket
- mv deploy ${RASPBERRYPI_PLATFORM}
- tar czf ${RASPBERRYPI_PLATFORM}.tar.gz ${RASPBERRYPI_PLATFORM}
- aws s3 cp ${RASPBERRYPI_PLATFORM}.tar.gz s3://mender-gitlab-tmp-storage/$CI_PROJECT_NAME/$CI_PIPELINE_ID/${RASPBERRYPI_PLATFORM}.tar.gz
convert_raspbian_raspberrypi3:
<<: *convert_raspbian
variables:
RASPBERRYPI_PLATFORM: raspberrypi3
convert_raspbian_raspberrypi4:
<<: *convert_raspbian
variables:
RASPBERRYPI_PLATFORM: raspberrypi4
.template_test_acceptance: &test_acceptance
stage: test_acceptance
needs:
- job: build
artifacts: true
image: ubuntu:18.04
services:
- docker:19.03-dind
tags:
- mender-qa-slave
timeout: 2h
before_script:
- export AWS_ACCESS_KEY_ID=$TMP_STORAGE_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$TMP_STORAGE_AWS_SECRET_ACCESS_KEY
# Install dependencies
- apt update
- apt install -qyy bash wget git util-linux mtools python3 python3-pip
gcc python3-dev libffi-dev liblzo2-dev libc-dev libssl-dev make sudo
awscli unzip qemu-system-x86 ovmf curl docker.io
# Python3 dependencies
- python3 -m pip install -U pip
- pip3 install --ignore-installed -r https://raw.githubusercontent.com/mendersoftware/meta-mender/master/tests/acceptance/requirements_py3.txt
# Load image under test
- export IMAGE_NAME=$DOCKER_REPOSITORY:pr
- docker load -i image.tar
# Set mender-image-tests submodule to correct version
- git submodule update --init --recursive
# Get mender-artifact for the tests
- curl -f -O https://mender.s3.amazonaws.com/mender-artifact/$MENDER_ARTIFACT_VERSION/linux/mender-artifact
- chmod ugo+x mender-artifact
- mv mender-artifact /usr/bin/
# Get Update Modules Artifact generators for the tests
- if [ "${MENDER_CLIENT_VERSION}" = "latest" ]; then
- mender_version=master
- else
- mender_version="${MENDER_CLIENT_VERSION}"
- fi
- curl -f -O https://raw.githubusercontent.com/mendersoftware/mender/${mender_version}/support/modules-artifact-gen/directory-artifact-gen
- chmod ugo+x directory-artifact-gen
- mv directory-artifact-gen /usr/bin/
- curl -f -O https://raw.githubusercontent.com/mendersoftware/mender/${mender_version}/support/modules-artifact-gen/single-file-artifact-gen
- chmod ugo+x single-file-artifact-gen
- mv single-file-artifact-gen /usr/bin/
artifacts:
expire_in: 2w
when: always
paths:
- results_*.xml
- report_*.html
reports:
junit: results_*.xml
.template_test_acceptance_prebuilt_raspberrypi: &test_acceptance_prebuilt_raspberrypi
<<: *test_acceptance
script:
# Fetch artifacts from temporary S3 bucket
- aws s3 cp s3://mender-gitlab-tmp-storage/$CI_PROJECT_NAME/$CI_PIPELINE_ID/${RASPBERRYPI_PLATFORM}.tar.gz ${RASPBERRYPI_PLATFORM}.tar.gz
- tar xzf ${RASPBERRYPI_PLATFORM}.tar.gz
- mv ${RASPBERRYPI_PLATFORM} deploy
# Extract converted Raspbian artifacts
- unxz deploy/${RASPBIAN_NAME}-${RASPBERRYPI_PLATFORM}-mender.img.xz
- ./scripts/test/run-tests.sh --prebuilt-image raspberrypi ${RASPBIAN_NAME}-${RASPBERRYPI_PLATFORM}-mender
test_acceptance_prebuilt_raspberrypi3:
<<: *test_acceptance_prebuilt_raspberrypi
needs:
- job: build
artifacts: true
- job: convert_raspbian_raspberrypi3
artifacts: true
variables:
RASPBERRYPI_PLATFORM: raspberrypi3
test_acceptance_prebuilt_raspberrypi4:
<<: *test_acceptance_prebuilt_raspberrypi
needs:
- job: build
artifacts: true
- job: convert_raspbian_raspberrypi4
artifacts: true
variables:
RASPBERRYPI_PLATFORM: raspberrypi4
test_acceptance_qemux86_64:
<<: *test_acceptance
script:
- ./scripts/test/run-tests.sh --only qemux86_64
test_acceptance_raspberrypi:
<<: *test_acceptance
script:
- ./scripts/test/run-tests.sh --only raspberrypi3
test_acceptance_beaglebone:
<<: *test_acceptance
script:
- ./scripts/test/run-tests.sh --only beaglebone
test_acceptance_ubuntu:
<<: *test_acceptance
script:
- ./scripts/test/run-tests.sh --only ubuntu
publish:s3:
when: manual
stage: publish
image: debian:buster
before_script:
- export PUBLISH_AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
- export PUBLISH_AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
- export AWS_ACCESS_KEY_ID=$TMP_STORAGE_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$TMP_STORAGE_AWS_SECRET_ACCESS_KEY
- apt update && apt install -yyq awscli
# Fetch artifacts from temporary S3 bucket
- for RASPBERRYPI_PLATFORM in raspberrypi3 raspberrypi4; do
- aws s3 cp s3://mender-gitlab-tmp-storage/$CI_PROJECT_NAME/$CI_PIPELINE_ID/${RASPBERRYPI_PLATFORM}.tar.gz ${RASPBERRYPI_PLATFORM}.tar.gz
- tar xzf ${RASPBERRYPI_PLATFORM}.tar.gz
- done
script:
# Prepare high privilege S3 keys (the TMP_STORAGE keys are for the tmp storage only)
- export AWS_ACCESS_KEY_ID=$PUBLISH_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$PUBLISH_AWS_SECRET_ACCESS_KEY
- for RASPBERRYPI_PLATFORM in raspberrypi3 raspberrypi4; do
- PUBLISH_NAME=${RASPBIAN_NAME}-${RASPBERRYPI_PLATFORM}-mender-${MENDER_CLIENT_VERSION}.img.xz
- echo "Publishing ${PUBLISH_NAME} version to S3"
- aws s3 cp ${RASPBERRYPI_PLATFORM}/${RASPBIAN_NAME}-${RASPBERRYPI_PLATFORM}-mender.img.xz
s3://$S3_BUCKET_NAME/${RASPBIAN_NAME}/arm/${PUBLISH_NAME}
- aws s3api put-object-acl --acl public-read --bucket $S3_BUCKET_NAME
--key ${RASPBIAN_NAME}/arm/${PUBLISH_NAME}
- PUBLISH_NAME=${RASPBIAN_NAME}-${RASPBERRYPI_PLATFORM}-mender-${MENDER_CLIENT_VERSION}.mender
- echo "Publishing ${PUBLISH_NAME} version to S3"
- aws s3 cp ${RASPBERRYPI_PLATFORM}/${RASPBIAN_NAME}-${RASPBERRYPI_PLATFORM}-mender.mender
s3://$S3_BUCKET_NAME/${RASPBIAN_NAME}/arm/${PUBLISH_NAME}
- aws s3api put-object-acl --acl public-read --bucket $S3_BUCKET_NAME
--key ${RASPBIAN_NAME}/arm/${PUBLISH_NAME}
- done
only:
- /^(master|[0-9]+\.[0-9]+\.x)$/