forked from operator-framework/operator-lifecycle-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.jsonnet
204 lines (184 loc) · 6.21 KB
/
.gitlab-ci.jsonnet
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
local utils = import '.gitlab-ci/utils.libsonnet';
local vars = import '.gitlab-ci/vars.libsonnet';
local baseJob = import '.gitlab-ci/base_jobs.libsonnet';
local mergeJob = utils.ci.mergeJob;
local images = vars.images;
local docker = utils.docker;
local stages_list = [
// gitlab-ci stages
'docker_base',
'docker_build',
'deploy_preview',
'test_setup',
'tests',
'test_teardown',
'integration',
'docker_release',
'deploy_staging',
'teardown',
];
local stages = utils.set(stages_list);
// List CI jobs
local jobs = {
// Helpers
local onlyMaster = {
only: ['master', 'tags'],
},
local onlyBranch = {
only: ['branches'],
except: ['master', 'tags'],
},
'container-base-build': baseJob.dockerBuild {
stage: stages.docker_base,
script: docker.build_and_push(images.base.name,
cache=false,
args={ sshkey: vars.deploy_keys.operator_client },
extra_opts=["-f base.Dockerfile"]),
only: ["schedules", "tags"],
},
'container-build': baseJob.dockerBuild {
// Build and push the alm container.
// Docker Tag is the branch/tag name
stage: stages.docker_build,
before_script+: [
"mkdir -p $PWD/bin",
],
// builds a single multistage dockerfile and tags images based on labels
// on the intermediate builds
script: docker.multibuild_and_push("Dockerfile", labelImageMap={
'builder': images.ci.alm.name,
'olm': images.prerelease.alm.name,
'catalog': images.prerelease.catalog.name,
'broker': images.prerelease.servicebroker.name,
'e2e': images.e2e.name,
}) +
docker.run(images.ci.alm.name, "make verify-codegen verify-catalog")
},
'container-release': baseJob.dockerBuild {
// ! Only master/tags
// push the container to the 'prod' repository
stage: stages.docker_release,
before_script+: ["mkdir -p $PWD/bin"],
script:
docker.rename(images.prerelease.alm.name, images.release.alm.name) +
docker.rename(images.prerelease.catalog.name, images.release.catalog.name) +
docker.rename(images.prerelease.servicebroker.name, images.release.servicebroker.name) +
docker.rename(images.e2e.name, images.e2elatest.name),
} + onlyMaster,
// Unit-tests
local unittest_stage = baseJob.AlmTest {
stage: stages.tests,
},
'unit-tests': unittest_stage {
coverage: @"/\d\d\.\d.$/",
script: [
"make vendor",
"make verify-catalog",
"make verify-codegen",
"make coverage",
],
},
'e2e-setup': baseJob.Deploy {
local _vars = self.localvars,
localvars+:: {
namespace: "e2e-%s" % "${CI_COMMIT_REF_SLUG}-${SHA8}",
catalog_namespace: "e2e-%s" % "${CI_COMMIT_REF_SLUG}-${SHA8}",
},
stage: stages.test_setup,
},
'e2e-teardown': baseJob.DeployStop {
local _vars = self.localvars,
localvars+:: {
namespace: "e2e-%s" % "${CI_COMMIT_REF_SLUG}-${SHA8}",
catalog_namespace: "e2e-%s" % "${CI_COMMIT_REF_SLUG}-${SHA8}",
},
stage: stages.test_teardown,
},
// End2End tests
local integration_test = baseJob.EndToEndTest {
stage: stages.tests,
},
e2e_tests: integration_test {
},
"deploy-preview": baseJob.Deploy {
local _vars = self.localvars,
localvars+:: {
helm_opts: ["--force"],
},
stage: stages.deploy_preview,
when: "manual",
environment+: {
on_stop: "stop-preview",
},
} + onlyBranch,
"stop-preview": baseJob.DeployStop {
when: "manual",
stage: stages.deploy_preview,
} + onlyBranch,
"deploy-staging": baseJob.Deploy {
local _vars = self.localvars,
localvars+:: {
image: images.release,
domain: "alm-staging.k8s.devtable.com",
namespace: "ci-alm-staging",
channel: "staging",
helm_opts: ["--force"],
kubeconfig: "$CD_KUBECONFIG",
},
stage: stages.deploy_staging,
script+: [],
environment+: {
name: "staging",
},
only: ['master'],
},
"deploy-teamui": baseJob.Deploy {
local _vars = self.localvars,
localvars+:: {
image: images.release,
domain: "teamui.console.team.coreos.systems",
namespace: "tectonic-system",
channel: "staging",
helm_opts: ["--force"],
kubeconfig: "$TEAMUI_KUBECONFIG",
params+:: {
watchedNamespaces: "",
},
},
stage: stages.deploy_staging,
script+: [
"curl -X POST --data-urlencode \"payload={\\\"text\\\": \\\"New OLM Operator quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA} deployed to ${TEAMUI_HOST}/k8s/ns/tectonic-system/deployments/alm-operator\\\"}\" ${TEAMUI_SLACK_URL}",
],
environment+: {
name: "teamui",
},
only: ['master'],
},
"deploy-openshift": baseJob.Deploy {
local _vars = self.localvars,
localvars+:: {
image: images.release,
domain: "console.apps.ui-preserve.origin-gce.dev.openshift.com",
namespace: "openshift",
catalog_namespace: "openshift",
channel: "staging",
helm_opts: ["--force"],
kubeconfig: "$OPENSHIFT_KUBECONFIG",
params+:: {
watchedNamespaces: "",
},
},
stage: stages.deploy_staging,
script+: [
"curl -X POST --data-urlencode \"payload={\\\"text\\\": \\\"New OLM Operator quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA} deployed to ${OPENSHIFT_HOST}/k8s/ns/tectonic-system/deployments/alm-operator\\\"}\" ${TEAMUI_SLACK_URL}",
],
environment+: {
name: "openshift",
},
only: ['master'],
},
};
{
stages: stages_list,
variables: vars.global,
} + jobs