forked from mendersoftware/integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
242 lines (213 loc) · 7.69 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
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-check-python3-format.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-github-status-updates.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-docker-build.yml'
stages:
- test
- build
- publish
variables:
LICENSE_HEADERS_IGNORE_FILES_REGEXP: '\./extra/gitdm.*'
test:check-commits:
except:
refs:
- /^(master|[0-9]+\.[0-9]+\.x)$/
variables:
- $RUN_TESTS_STAGING == "true"
test:check-python3-formatting:
except:
refs:
- /^(master|[0-9]+\.[0-9]+\.x)$/
variables:
- $RUN_TESTS_STAGING == "true"
test:extra-tools:
image: "python:3"
stage: test
except:
variables:
- $RUN_TESTS_STAGING == "true"
before_script:
- pip install pytest pyyaml
# Rename the branch we're on, so that it's not in the way for the
# subsequent fetch. It's ok if this fails, it just means we're not on any
# branch.
- git branch -m temp-branch || true
# Set up git identity
- git config --global user.name "Northern.tech" && git config --global user.email "[email protected]"
# Needed for the statistics generator
- git config --global mailmap.file $(pwd)/extra/gitdm/mailmap
# Add github remote for tests using --integration-versions-including
- git remote add github https://github.com/mendersoftware/integration.git
- git fetch github
# Fetch master branch for tests using --in-integration-version
- git fetch origin master:master
- git fetch origin --tags
- git submodule update --init --recursive
script:
- ( cd extra/changelog-generator && ./test-changelog-generator )
- python3 -m pytest extra/test_release_tool.py
- python3 -m pytest extra/test_statistics_generator.py
test:docs:
image: tiangolo/docker-with-compose
services:
- docker:19.03.5-dind
except:
variables:
- $RUN_TESTS_STAGING == "true"
before_script:
- apk add bash git openssl pwgen python3 jq
- git config --global user.name "user"
- git config --global user.email "[email protected]"
- git clone --depth=1 https://github.com/mendersoftware/mender-docs.git mender-docs
script:
- cd mender-docs
- ./run-tests.sh
test:staging:backend-tests:
image: debian:bullseye
stage: test
timeout: 4h
only:
variables:
- $RUN_TESTS_STAGING == "true"
services:
- docker:19.03.5-dind
variables:
K8S: "staging"
AWS_ACCESS_KEY_ID: $CI_JOBS_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $CI_JOBS_AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $CI_JOBS_AWS_REGION
AWS_EKS_CLUSTER_NAME: $CI_JOBS_AWS_EKS_CLUSTER_NAME
GATEWAY_HOSTNAME: "staging.hosted.mender.io"
DOCKER_HOST: tcp://docker:2375
before_script:
- apt update
- apt install -yyq curl gnupg
# Install docker
- curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
- apt-key fingerprint 0EBFCD88
- echo "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" >> /etc/apt/sources.list
- apt update
- apt install -yyq docker-ce=5:19.03.15~3-0~debian-buster docker-ce-cli=5:19.03.15~3-0~debian-buster containerd.io
# Install docker-compose
- curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
- chmod 775 /usr/bin/docker-compose
# Install python dependencies
- apt install -yyq python3-yaml
# Export AWS keys, as group takes precedence over yaml specified ones
# See https://docs.gitlab.com/ee/ci/variables/#priority-of-cicd-variables
- export AWS_ACCESS_KEY_ID=$CI_JOBS_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_JOBS_AWS_SECRET_ACCESS_KEY
script:
- cd backend-tests
- ./run -s enterprise
artifacts:
expire_in: 2w
when: always
paths:
- backend-tests/acceptance.*
- backend-tests/results_backend_integration_*.xml
- backend-tests/report_backend_integration_*.html
reports:
junit: backend-tests/results_backend_integration_*.xml
test:staging:integration-tests:
# Integration tests depends on running ssh to containers, we're forced to
# run dockerd on the same host.
image: docker:19.03.15-dind-alpine3.13
stage: test
timeout: 4h
only:
variables:
- $RUN_TESTS_STAGING == "true"
tags:
- mender-qa-slave-highmem
variables:
K8S: "staging"
AWS_ACCESS_KEY_ID: $CI_JOBS_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $CI_JOBS_AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $CI_JOBS_AWS_REGION
AWS_EKS_CLUSTER_NAME: $CI_JOBS_AWS_EKS_CLUSTER_NAME
GATEWAY_HOSTNAME: "staging.hosted.mender.io"
DOCKER_CLIENT_TIMEOUT: 300
COMPOSE_HTTP_TIMEOUT: 300
SPECIFIC_INTEGRATION_TEST: "Enterprise"
TESTS_IN_PARALLEL: "1"
before_script:
- unset DOCKER_HOST
- unset DOCKER_TLS_VERIFY
- unset DOCKER_CERT_PATH
# Dependencies for post job status
- apk --update add curl jq
# Start dockerd in the background
- /usr/local/bin/dockerd &
# Wait for dockerd to start
- |-
MAX_WAIT=30
while [ ! -e "/var/run/docker.sock" ] && [ $MAX_WAIT -gt 0 ]; do
MAX_WAIT=$(($MAX_WAIT - 1))
sleep 1
done
- docker version # Verify that the docker server is up and running
# Get and install the integration test requirements
- apk add python3-dev py3-pip
- apk add $(cat tests/requirements/apk-requirements.txt | grep -v py-pip)
- CRYPTOGRAPHY_DONT_BUILD_RUST=1 pip3 install -r tests/requirements/python-requirements.txt
# Install awscli, kubectl and aws-iam-authenticator
- pip3 install awscli
- curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- install -o root -g root -m 0755 kubectl /usr/bin/kubectl
- curl -LO "https://amazon-eks.s3.us-west-2.amazonaws.com/1.17.9/2020-08-04/bin/linux/amd64/aws-iam-authenticator"
- install -o root -g root -m 0755 kubectl /usr/bin/aws-iam-authenticator
# Export AWS keys, as group takes precedence over yaml specified ones
# See https://docs.gitlab.com/ee/ci/variables/#priority-of-cicd-variables
- export AWS_ACCESS_KEY_ID=$CI_JOBS_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_JOBS_AWS_SECRET_ACCESS_KEY
script:
- cd tests
- ./run.sh
artifacts:
expire_in: 2w
when: always
paths:
- tests/mender_test_logs
- tests/results_full_integration.xml
- tests/report_full_integration.html
reports:
junit: tests/results_full_integration.xml
# Smoke test to verify requirements.txt are sane
test:integration-tests:requirements:
stage: test
rules:
- changes:
- tests/requirements/apk-requirements.txt
- tests/requirements/python-requirements.txt
# Use same image as in mender-qa
image: docker:19.03-dind
script:
# Get and install the integration test requirements
- apk add $(cat tests/requirements/apk-requirements.txt)
- pip install -r tests/requirements/python-requirements.txt
build:docker:
variables:
DOCKER_REPOSITORY: mendersoftware/mender-client-docker-addons
DOCKER_DIR: extra/mender-client-docker-addons
publish:image:
variables:
DOCKER_REPOSITORY: mendersoftware/mender-client-docker-addons
DOCKER_DIR: extra/mender-client-docker-addons
publish:image:mender:
variables:
DOCKER_REPOSITORY: mendersoftware/mender-client-docker-addons
DOCKER_DIR: extra/mender-client-docker-addons
trigger:saas:sync-staging-component:
rules:
- when: never
publish:image:saas:
rules:
- when: never