forked from mendersoftware/workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
169 lines (155 loc) · 5.11 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
variables:
DOCKER_REPOSITORY: mendersoftware/workflows # server; worker image defined in required jobs
MULTIPLATFORM_BUILD: "true"
MULTIPLATFORM_PLATFORMS: "linux/amd64,linux/arm64"
stages:
- test
- build
- publish
include:
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-golang-lint.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-golang-unittests.yml'
- 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-apidocs.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-docker-build.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-github-status-updates.yml'
.dind-login: &dind-login
- mkdir -p $HOME/.docker && echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
test:prepare_acceptance:
stage: .pre
image: docker
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
variables:
DOCKER_HOST: "tcp://docker:2376"
DOCKER_CERT_PATH: "/certs/client"
DOCKER_TLS_VERIFY: "1"
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- export WORKER_DOCKER_REPOSITORY="mendersoftware/workflows-worker"
- *dind-login
script:
- docker build -f Dockerfile.acceptance-testing -t $DOCKER_REPOSITORY:prtest .
- docker build -f Dockerfile.acceptance-testing.worker -t $WORKER_DOCKER_REPOSITORY:prtest .
- docker save $DOCKER_REPOSITORY:prtest > prtest_image.tar
- docker save $WORKER_DOCKER_REPOSITORY:prtest > prtest_worker_image.tar
artifacts:
expire_in: 2w
paths:
- prtest_image.tar
- prtest_worker_image.tar
test:unit:
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/mongo:4.4
alias: mongo
variables:
WORKFLOWS_MONGO_URL: "mongodb://mongo"
test:acceptance_tests:
stage: test
tags:
- hetzner-amd-beefy
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:26-cli
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:26-dind
alias: docker
variables:
DOCKER_HOST: "tcp://docker:2376"
DOCKER_CERT_PATH: "/certs/client"
DOCKER_TLS_VERIFY: "1"
DOCKER_TLS_CERTDIR: "/certs"
dependencies:
- test:prepare_acceptance
before_script:
- apk add --no-cache make
- docker load -i prtest_image.tar
- docker load -i prtest_worker_image.tar
- *dind-login
script:
- make acceptance-testing-up
- sh -c "sleep 10"
- make acceptance-testing-run
after_script:
- make acceptance-testing-logs
- make acceptance-testing-down
artifacts:
expire_in: 2w
paths:
- tests/coverage
# excludes non multiplatform build job
build:docker:
rules:
- when: never
# excludes non multiplatform build job
publish:image:
rules:
- when: never
# excludes non multiplatform job
publish:image:saas:
rules:
- when: never
# excludes non multiplatform build job
publish:image:mender:
rules:
- when: never
# workflows (server) is built and published by the template; specify
# jobs only for the worker
build:docker-multiplatform:worker:
extends: build:docker-multiplatform
variables:
DOCKER_REPOSITORY: mendersoftware/workflows-worker
DOCKERFILE: Dockerfile.worker
GITLAB_REGISTRY_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-worker'
publish:image-multiplatform:worker:
extends: publish:image-multiplatform
dependencies:
- build:docker-multiplatform:worker
variables:
DOCKER_REPOSITORY: mendersoftware/workflows-worker
GITLAB_REGISTRY_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-worker'
publish:image-multiplatform:mender:worker:
extends: publish:image-multiplatform:mender
dependencies:
- build:docker-multiplatform:worker
variables:
DOCKER_REPOSITORY: mendersoftware/workflows-worker
GITLAB_REGISTRY_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-worker'
publish:acceptance:
stage: publish
rules:
- if: $CI_COMMIT_BRANCH !~ /^saas-[a-zA-Z0-9.]+$/
image: golang:1.22.2-alpine3.19
dependencies:
- test:acceptance_tests
before_script:
- apk add --no-cache git
# Coveralls env variables:
# According to https://docs.coveralls.io/supported-ci-services
# we should set CI_NAME, CI_BUILD_NUMBER, etc. But according
# to goveralls source code (https://github.com/mattn/goveralls)
# many of these are not supported. Set CI_BRANCH, CI_PR_NUMBER,
# and pass few others as command line arguments.
# See also https://docs.coveralls.io/api-reference
- export CI_BRANCH=${CI_COMMIT_BRANCH}
- export CI_PR_NUMBER=${CI_COMMIT_BRANCH#pr_}
- go install github.com/mattn/goveralls@latest
# Convert coverage directory to text format
- go tool covdata textfmt -i tests/coverage -o coverage.txt
script:
- |-
goveralls \
-repotoken ${COVERALLS_TOKEN} \
-service gitlab-ci \
-jobid $CI_PIPELINE_ID \
-covermode set \
-flagname acceptance \
-parallel \
-coverprofile coverage.txt