-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathcodefresh.yml
373 lines (350 loc) · 9.42 KB
/
codefresh.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
367
368
369
370
371
372
373
# this pipeline should not be run on version tag releases (it may cause a non correct sha to override version tagged image in dockerhub)
version: "1.0"
mode: parallel
stages:
- prepare
- test
- build
- push
- docker
- final
steps:
main_clone:
stage: prepare
title: 'Cloning main repository...'
type: git-clone
repo: codefresh-io/cli
revision: ${{CF_BRANCH}}
git: cf_github
extract_version:
stage: prepare
title: "Exporting package.json version"
image: codefresh/build-cli
commands:
- 'export PACKAGE_VERSION=$(jq -r ".version" package.json)'
- "echo Current version: $PACKAGE_VERSION"
- "cf_export PACKAGE_VERSION"
when:
steps:
- name: main_clone
on:
- success
check_version:
stage: prepare
title: 'Checking if version already exists'
image: codefresh/build-cli
fail_fast: false
commands:
- >-
RELEASE_ID="$(curl -s https://api.github.com/repos/codefresh-io/cli/releases/tags/v${{PACKAGE_VERSION}} | jq .id)"
echo "Release id: $RELEASE_ID"
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = 'null' ]; then
echo "Version is ok: ${{PACKAGE_VERSION}}"
else
echo "Release already exists ${{PACKAGE_VERSION}}"
exit 1
fi
when:
condition:
all:
skipVersionCheck: '"${{SKIP_VERSION_CHECK}}" != "true"'
steps:
- name: extract_version
on:
- success
install_dependencies:
stage: test
title: 'Installing testing dependencies'
image: codefresh/build-cli
commands:
- yarn install --frozen-lockfile
when:
steps:
- name: extract_version
on:
- success
parallel_tests:
stage: test
type: parallel
steps:
eslint:
title: 'Running linting logic'
image: codefresh/build-cli
commands:
- yarn eslint
unit_tests:
title: 'Running unit tests'
image: codefresh/build-cli
commands:
- yarn test
# Disabled e2e tests because of flakyness
# need to fix flakyness before enabling again.
#
# e2e_tests:
# title: 'Running e2e tests'
# image: codefresh/build-cli
# commands:
# - "echo Running e2e on account: ${{CF_ACCOUNT}}"
# - CF_API_KEY=${{CF_E2E_API_KEY}} yarn e2e
when:
branch:
ignore: [ master ]
steps:
- name: install_dependencies
on:
- success
build_images:
stage: build
type: parallel
steps:
build_step_alpine:
type: build
dockerfile: Dockerfile
image-name: codefresh/cli
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
build_step_debian:
type: build
dockerfile: Dockerfile-debian
image-name: codefresh/cli
tag: ${{CF_BRANCH_TAG_NORMALIZED}}${{DEBIAN_TAG_POSTFIX}}
build_step_alpine_rootless:
type: build
dockerfile: Dockerfile-rootless
image-name: codefresh/cli
tag: ${{CF_BRANCH_TAG_NORMALIZED}}${{ROOTLESS_TAG_POSTFIX}}
build_step_debian_rootless:
type: build
dockerfile: Dockerfile-debian-rootless
image-name: codefresh/cli
tag: ${{CF_BRANCH_TAG_NORMALIZED}}${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}
when:
steps:
- name: extract_version
on:
- success
run_arm_build:
stage: build
type: codefresh-run
arguments:
PIPELINE_ID: codefresh-io/cli/build-arm
TRIGGER_ID: codefresh-io/cli
BRANCH: ${{CF_BRANCH}}
DETACH: false
VARIABLE:
- CF_REPO_OWNER=${{CF_REPO_OWNER}}
- CF_REPO_NAME=${{CF_REPO_NAME}}
- CF_REVISION=${{CF_REVISION}}
- CF_BRANCH=${{CF_BRANCH}}
- CF_SHORT_REVISION=${{CF_SHORT_REVISION}}
- GIT_CONTEXT=cf_github
- IMAGE_NAME=codefresh/cli
- WORKDIR=${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}
- ARM_TAG_POSTFIX="${{ARM_TAG_POSTFIX}}"
- DEBIAN_TAG_POSTFIX="${{DEBIAN_TAG_POSTFIX}}"
- ROOTLESS_TAG_POSTFIX="${{ROOTLESS_TAG_POSTFIX}}"
- PACKAGE_VERSION=${{PACKAGE_VERSION}}
when:
steps:
- name: extract_version
on:
- success
push_step_alpine:
stage: push
type: push
tag: '${{CF_SHORT_REVISION}}'
candidate: ${{build_step_alpine}}
scale:
push_to_dockerhub:
registry: dockerhub
title: "push to dockerhub"
push_to_gcr:
title: "push to gcr"
push_to_quay:
registry: cf-quay
title: "push to quay.io"
when:
steps:
- name: build_images
on:
- success
push_step_debian:
stage: push
type: push
tag: '${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}'
candidate: ${{build_step_debian}}
scale:
push_to_dockerhub_debian:
registry: dockerhub
title: "push to dockerhub"
push_to_gcr_debian:
title: "push to gcr"
push_to_quay_debian:
registry: cf-quay
title: "push to quay.io"
when:
steps:
- name: build_images
on:
- success
push_step_alpine_rootless:
stage: push
type: push
tag: '${{CF_SHORT_REVISION}}${{ROOTLESS_TAG_POSTFIX}}'
candidate: ${{build_step_alpine_rootless}}
scale:
push_to_dockerhub_rootless:
registry: dockerhub
title: "push to dockerhub"
push_to_gcr_rootless:
title: "push to gcr"
push_to_quay_rootless:
registry: cf-quay
title: "push to quay.io"
when:
steps:
- name: build_images
on:
- success
push_step_debian_rootless:
stage: push
type: push
tag: '${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}'
candidate: ${{build_step_debian_rootless}}
scale:
push_to_dockerhub_debian_rootless:
registry: dockerhub
title: "push to dockerhub"
push_to_gcr_debian_rootless:
title: "push to gcr"
push_to_quay_debian_rootless:
registry: cf-quay
title: "push to quay.io"
when:
steps:
- name: build_images
on:
- success
create_manifest_list:
stage: docker
type: "codefresh-inc/multiarch-manifester"
arguments:
image_name: codefresh/cli
arch_tag_postfixes:
arm64: "${{ARM_TAG_POSTFIX}}"
registries:
- name: 'quay.io'
username: '${{QUAY_USERNAME}}'
password: '${{QUAY_PASSWORD}}'
- name: 'docker.io'
username: '${{DOCKERHUB_USERNAME}}'
password: '${{DOCKERHUB_PASSWORD}}'
- name: 'gcr.io'
path_prefix: codefresh-inc
username: '${{GCR_CODEFRESH_INC_USERNAME}}'
password: '${{GCR_CODEFRESH_INC_PASSWORD}}'
scale:
dev_branches_tags:
when:
branch:
ignore: [ master ]
arguments:
tags:
- ${{CF_SHORT_REVISION}}
dev_branches_tags_debian:
when:
branch:
ignore: [ master ]
arguments:
tags:
- ${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}
dev_branches_tags_rootless:
when:
branch:
ignore: [ master ]
arguments:
tags:
- ${{CF_SHORT_REVISION}}${{ROOTLESS_TAG_POSTFIX}}
dev_branches_tags_debian_rootless:
when:
branch:
ignore: [ master ]
arguments:
tags:
- ${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}
when:
steps:
- name: push_step_alpine
on:
- success
- name: push_step_debian
on:
- success
- name: push_step_alpine_rootless
on:
- success
- name: push_step_debian_rootless
on:
- success
- name: run_arm_build
on:
- success
fail_on_bad_version:
stage: final
image: codefresh/build-cli
commands:
- exit 1
when:
condition:
all:
versionCheckFailed: steps.check_version.result == 'failure'
steps:
- name: create_manifest_list
on:
- success
execute_release_pipeline:
stage: final
title: "Execute release pipeline in case version was changed"
type: codefresh-run
arguments:
PIPELINE_ID: 'codefresh-io/cli/release'
TRIGGER_ID: codefresh-io/cli_1
BRANCH: master
VARIABLE:
- PACKAGE_VERSION=${{PACKAGE_VERSION}}
when:
branch:
only: [ master ]
condition:
all:
versionCheckSucceeded: steps.check_version.result != 'failure'
steps:
- name: create_manifest_list
on:
- success
execute_e2e_pipeline:
stage: final
title: "Execute E2E pipeline for image of this commit"
type: codefresh-run
arguments:
PIPELINE_ID: 'cli-v1-e2e/root'
VARIABLE:
- CLI_VERSION=${{CF_SHORT_REVISION}}
when:
steps:
- name: push_step_alpine
on:
- success
build_documentation:
stage: test
title: "build documentation http://cli.codefresh.io"
image: codefresh/build-cli
commands:
- "echo Building public docs"
- "yarn run build-public-docs"
environment:
- HUGO_VERSION=0.32.0
when:
steps:
- name: install_dependencies
on:
- success