/
config.yml
366 lines (339 loc) · 10.7 KB
/
config.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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
---
version: 2.1
parameters:
memcached_image:
type: string
default: "memcached:1.5"
components_tag_name:
type: string
default: "latest"
components_imagestream_tag_name:
type: string
default: "master"
##################################### YAML ANCHORS ############################################
tag-trigger: &tag-trigger
tags:
only: /^v.*/
only-master-filter: &only-master-filter
filters:
branches:
only: master
nightly-trigger: &nightly-trigger
triggers:
- schedule:
cron: "0 0 * * *"
<<: *only-master-filter
commands:
attach-workspace:
steps:
- run:
name: Preparing workspace directory
command: |
sudo rm -rf /tmp/workspace
sudo mkdir -p /tmp/workspace
sudo chown -vf circleci:circleci /tmp/workspace
working_directory: /
- attach_workspace:
at: /tmp/workspace
docker-login:
steps:
- run:
name: Docker login
command: |
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}" "${DOCKER_REGISTRY}"
install-operator-sdk:
steps:
- run:
name: Install operator-sdk
command: |
export OPERATOR_SDK_RELEASE_VERSION=v1.2.0
curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_RELEASE_VERSION}/operator-sdk-${OPERATOR_SDK_RELEASE_VERSION}-x86_64-linux-gnu
chmod +x operator-sdk-${OPERATOR_SDK_RELEASE_VERSION}-x86_64-linux-gnu && sudo cp operator-sdk-${OPERATOR_SDK_RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/operator-sdk && rm operator-sdk-${OPERATOR_SDK_RELEASE_VERSION}-x86_64-linux-gnu
install-dependencies:
steps:
- restore_cache:
keys:
- threescale-operator-go-mod-v1-{{ arch }}-{{ checksum "go.sum" }}
# Find the most recently generated cache used from any branch
- threescale-operator-go-mod-v1-{{ arch }}
- run:
name: Install go dependencies
command: |
make download
- save_cache:
key: threescale-operator-go-mod-v1-{{ arch }}-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
install-golang:
steps:
- run:
name: Install Golang
command: |
curl --fail -L https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz | sudo tar -C /opt -xzf-
- run:
name: Setup GO env
command: |
mkdir -p ~/tmp
echo 'export TMPDIR=~/tmp/' >> $BASH_ENV
echo 'export GOROOT=/opt/go' >> $BASH_ENV
echo 'export GOPATH=/go' >> $BASH_ENV
echo 'export PATH=$GOROOT/bin:$PATH' >> $BASH_ENV
echo 'export PATH=$GOPATH/bin:$PATH' >> $BASH_ENV
- run:
name: Setup GOPATH
command: |
sudo mkdir -p "$GOPATH/src" "$GOPATH/bin"
sudo chmod -R 777 "$GOPATH"
push-3scale-images-to-quay:
steps:
- docker-login
- run:
name: Push nightly images to quay.io
command: |
oc whoami --show-token | docker login -u $(oc whoami) --password-stdin 172.30.1.1:5000
project=$(oc project -q)
imagestream_tag_name=<< pipeline.parameters.components_imagestream_tag_name >>
oc image mirror \
172.30.1.1:5000/$project/amp-apicast:${imagestream_tag_name}=quay.io/3scale/apicast:<< pipeline.parameters.components_tag_name >> \
172.30.1.1:5000/$project/amp-zync:${imagestream_tag_name}=quay.io/3scale/zync:<< pipeline.parameters.components_tag_name >> \
172.30.1.1:5000/$project/amp-backend:${imagestream_tag_name}=quay.io/3scale/apisonator:<< pipeline.parameters.components_tag_name >> \
172.30.1.1:5000/$project/amp-system:${imagestream_tag_name}=quay.io/3scale/porta:<< pipeline.parameters.components_tag_name >> \
--insecure
create-redhat-registry-io-secret:
steps:
- run:
name: Create registry.redhat.io secret
command: |
oc create secret docker-registry threescale-registry-auth \
--docker-password="${REGISTRY_REDHAT_IO_PASSWORD}" \
--docker-username="${REGISTRY_REDHAT_IO_USERNAME}" \
--docker-server="${REGISTRY_REDHAT_IO_SERVER}"
create-secrets:
steps:
- run:
name: Import OpenShift Secrets
command: |
oc create secret docker-registry quay-auth \
--docker-password="${DOCKER_PASSWORD}" \
--docker-username="${DOCKER_USERNAME}" \
--docker-server="${DOCKER_REGISTRY}"
build-operator-image:
steps:
- checkout
- install-operator-sdk
- install-dependencies
- run:
name: Build Operator
command: |
make docker-build-only IMG=172.30.1.1:5000/openshift/3scale-operator:test
unit-tests:
steps:
- checkout
- install-dependencies
- run:
name: Run unit tests
command: |
make test-unit
jobs:
install-operator:
docker:
- image: circleci/golang:1.13.7
working_directory: ~/project/3scale-operator
steps:
- setup_remote_docker:
docker_layer_caching: true
- build-operator-image
- run:
name: Sharing requirements to downstream job
command: |
mkdir -p /tmp/workspace/images
docker save -o /tmp/workspace/images/3scaleoperator-image.tar 172.30.1.1:5000/openshift/3scale-operator:test
- persist_to_workspace:
root: /tmp/workspace
paths:
- images/3scaleoperator-image.tar
build-operator-image-only:
docker:
- image: circleci/golang:1.13.7
working_directory: ~/project/3scale-operator
steps:
- setup_remote_docker:
docker_layer_caching: true
- build-operator-image
tag-operator-image-master:
machine:
image: ubuntu-2004:202201-02
docker_layer_caching: true
steps:
- attach-workspace
- run:
name: Unpack docker image
command: |
docker load -i /tmp/workspace/images/3scaleoperator-image.tar
- run:
name: Tag image as master
command: |
docker tag 172.30.1.1:5000/openshift/3scale-operator:test quay.io/3scale/3scale-operator:master
- docker-login
- run:
name: Push master image
command: |
docker push quay.io/3scale/3scale-operator:master
- run:
name: Tag image as latest
command: |
docker tag quay.io/3scale/3scale-operator:master quay.io/3scale/3scale-operator:latest
- run:
name: Push latest image
command: |
docker push quay.io/3scale/3scale-operator:latest
tag-operator-image-release:
machine:
image: ubuntu-2004:202201-02
docker_layer_caching: true
steps:
- attach-workspace
- run:
name: Unpack docker image
command: |
docker load -i /tmp/workspace/images/3scaleoperator-image.tar
- run:
name: Tag image as release ${CIRCLE_TAG}
command: |
docker tag 172.30.1.1:5000/openshift/3scale-operator:test quay.io/3scale/3scale-operator:${CIRCLE_TAG}
- docker-login
- run:
name: Push ${CIRCLE_TAG} tag
command: |
docker push quay.io/3scale/3scale-operator:${CIRCLE_TAG}
run-unit-tests:
docker:
- image: circleci/golang:1.13.7
resource_class: large
steps:
- unit-tests
- run:
command: cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes
when: always
generator:
docker:
- image: circleci/golang:1.13.7
steps:
- checkout
- install-dependencies
- run: make templates
- run: make test -j 2 --directory pkg/3scale/amp
test-crds:
docker:
- image: circleci/golang:1.13.7
steps:
- checkout
- install-dependencies
- run: make test-crds
test-manifests-version:
docker:
- image: circleci/golang:1.13.7
steps:
- checkout
- install-dependencies
- run: make test-manifests-version
license-check:
docker:
- image: circleci/golang:1.13.7
steps:
- run:
name: Installing ruby
command: |
# Determine if sudo is neccessary
SUDO=""
if [[ $EUID -ne 0 ]]; then
SUDO=sudo
fi
# Install ruby
$SUDO apt-get update --allow-releaseinfo-change && $SUDO apt-get install -y ruby-full
- run:
name: Installing License tool
command: |
# Determine if sudo is neccessary
SUDO=""
if [[ $EUID -ne 0 ]]; then
SUDO=sudo
fi
# Install ruby
$SUDO gem install license_finder --version 5.7.1
- checkout
- install-dependencies
- run: make licenses-check
unit-tests-coverage:
docker:
- image: circleci/golang:1.13.7
resource_class: large
steps:
- unit-tests
- run:
name: Report to Codecov
command: |
cp _output/unit.cov coverage.txt
bash <(curl -s https://codecov.io/bash)
bundle-validate:
docker:
- image: circleci/golang:1.13.7
working_directory: /go/src/github.com/3scale/3scale-operator
steps:
- checkout
- install-operator-sdk
- run: make bundle
- run: make bundle-update-test
assets-validate:
docker:
- image: circleci/golang:1.13.7
steps:
- checkout
- install-operator-sdk
- run: make assets-update-test
prometheusrules-validate:
docker:
- image: circleci/golang:1.13.7
steps:
- checkout
- run: make prometheusrules-update-test
workflows:
version: 2
operator:
jobs:
- license-check
- test-crds
- test-manifests-version
- run-unit-tests
- bundle-validate
- assets-validate
- prometheusrules-validate
- build-operator-image-only
- unit-tests-coverage:
requires:
- run-unit-tests
<<: *only-master-filter
nightly:
jobs:
- build-operator-image-only
<<: *nightly-trigger
operator-release:
jobs:
- install-operator:
filters:
<<: *tag-trigger
- tag-operator-image-master:
context: org-global
requires:
- install-operator
filters:
branches:
only: master
- tag-operator-image-release:
context: org-global
requires:
- install-operator
filters:
<<: *tag-trigger
branches:
ignore: /.*/