-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcodefresh-template-test.yaml
More file actions
167 lines (166 loc) · 5.2 KB
/
codefresh-template-test.yaml
File metadata and controls
167 lines (166 loc) · 5.2 KB
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
version: "1.0"
stages:
- prepare
- build
- unittest
- deploy
- qa
steps:
main_clone:
title: Clone main repository
type: git-clone
stage: prepare
repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}"
revision: "${{CF_BRANCH}}"
git: github
post_main_clone:
title: Post main clone
type: parallel
stage: prepare
steps:
clone_cloud_harness:
title: Cloning cloud-harness repository...
type: git-clone
stage: prepare
repo: "https://github.com/MetaCell/cloud-harness.git"
revision: "${{CLOUDHARNESS_BRANCH}}"
working_directory: .
git: github
prepare_deployment:
title: "Prepare helm chart"
image: python:3.12
stage: prepare
working_directory: .
commands:
- bash cloud-harness/install.sh
- export HELM_NAME_ARG="$( [ -n "${{CHART_NAME}}" ] && printf -- "--name %s" "${{CHART_NAME}}" )"
- export HELM_CHART_VERSION_ARG="$( [ -n "${{CHART_VERSION}}" ] && printf -- "--chart-version %s" "${{CHART_VERSION}}" )"
- export HELM_APP_VERSION_ARG="$( APP_VERSION_RESOLVED="${{APP_VERSION}}"; [ -z "$APP_VERSION_RESOLVED" ] && APP_VERSION_RESOLVED="${{DEPLOYMENT_TAG}}"; [ -n "$APP_VERSION_RESOLVED" ] && printf -- "--app-version %s" "$APP_VERSION_RESOLVED" )"
- export HELM_META_ARGS="$HELM_NAME_ARG $HELM_CHART_VERSION_ARG $HELM_APP_VERSION_ARG"
- harness-deployment $PATHS -n test-${{NAMESPACE_BASENAME}} -d ${{DOMAIN}} -r ${{REGISTRY}} -rsn ${{REGISTRY_SECRET}} -e $ENV --write-env --cache-url '${{IMAGE_CACHE_URL}}' -N $HELM_META_ARGS $PARAMS
- cat deployment/.env >> ${{CF_VOLUME_PATH}}/env_vars_to_export
- cat ${{CF_VOLUME_PATH}}/env_vars_to_export
prepare_deployment_view:
commands:
- "helm template ./deployment/helm --debug -n test-${{NAMESPACE_BASENAME}}-${{CF_SHORT_REVISION}}"
environment:
- ACTION=auth
- KUBE_CONTEXT=test-${{CF_BUILD_ID}}
image: codefresh/cfstep-helm:3.6.2
stage: prepare
title: "View helm chart"
build_application_images:
type: parallel
stage: build
steps: {}
build_application_images_0:
build_application_images_1:
build_application_images_2:
build_application_images_3:
build_application_images_4:
build_application_images_5:
tests_unit:
stage: unittest
type: parallel
steps: {}
deployment:
stage: deploy
type: helm
working_directory: ./${{CF_REPO_NAME}}
title: Installing chart
arguments:
helm_version: 3.6.2
chart_name: deployment/helm
release_name: test-${{NAMESPACE_BASENAME}}
kube_context: ${{CLUSTER_NAME}}
namespace: test-${{NAMESPACE_BASENAME}}
chart_version: ${{CF_SHORT_REVISION}}
cmd_ps: "--timeout 600s --create-namespace"
custom_value_files:
- ./deployment/helm/values.yaml
build_test_images:
title: Build test images
type: parallel
stage: qa
steps: []
wait_deployment:
stage: qa
title: Wait deployment to be ready
image: codefresh/kubectl
commands:
- kubectl config use-context ${{CLUSTER_NAME}}
- kubectl config set-context --current --namespace=test-${{NAMESPACE_BASENAME}}
tests_nfs_failover:
stage: qa
title: NFS server failover & multi-node tests
image: codefresh/kubectl
working_directory: .
fail_fast: false
commands:
- kubectl config use-context ${{CLUSTER_NAME}}
- export NAMESPACE=test-${{NAMESPACE_BASENAME}}
- export STORAGE_CLASS=${NAMESPACE}-nfs-client
- bash applications/nfsserver/test/failover-test.sh
hooks:
on_finish:
exec:
image: codefresh/kubectl
commands:
- kubectl config use-context ${{CLUSTER_NAME}}
- export NAMESPACE=test-${{NAMESPACE_BASENAME}}
- kubectl -n $NAMESPACE delete pod -l app=nfs-failover-test --ignore-not-found --grace-period=0 --force --wait=false 2>/dev/null || true
- kubectl -n $NAMESPACE delete pvc -l app=nfs-failover-test --ignore-not-found --wait=false 2>/dev/null || true
on_fail:
exec:
image: alpine
commands:
- cf_export FAILED=failed
when:
condition:
all:
nfs_test_enabled: '"${{TEST_NFS_FAILOVER}}" == "true"'
tests_api:
stage: qa
title: Api tests
working_directory: /home/test
image: "${{test-api}}"
fail_fast: false
commands:
- echo $APP_NAME
scale: {}
hooks:
on_fail:
exec:
image: alpine
commands:
- cf_export FAILED=failed
tests_e2e:
stage: qa
title: End to end tests
working_directory: /home/test
image: "${{test-e2e}}"
fail_fast: false
commands:
- npx puppeteer browsers install chrome
- yarn test
scale: {}
hooks:
on_fail:
exec:
image: alpine
commands:
- cf_export FAILED=failed
publish: null
approval:
type: pending-approval
stage: qa
title: Approve anyway and delete deployment
description: The pipeline will fail after ${{WAIT_ON_FAIL}} minutes
timeout:
timeUnit: minutes
duration: ${{WAIT_ON_FAIL}}
finalState: denied
when:
condition:
all:
error: '"${{FAILED}}" == "failed"'