This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
351 lines (314 loc) · 10.5 KB
/
quarks-operator-ci.yaml
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
name: quarks-operator-ci
on:
# run for every push (master, feature branch, ...)
push:
# nightly
schedule:
- cron: '0 0 * * *'
env:
GOPROXY: "https://proxy.golang.org"
DOCKER_IMAGE_ORG: ghcr.io/cfcontainerizationbot
DOCKER_IMAGE_REPOSITORY: quarks-operator-dev
DOCKER_IMAGE_TAG: "${{ github.sha }}"
DOCKER_RELEASE_ORG: ghcr.io/cloudfoundry-incubator
DOCKER_RELEASE_REPOSITORY: quarks-operator
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.3
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: |
sudo gem install bosh-template
go install github.com/onsi/ginkgo/[email protected]
- name: Install shared tools
run: |
bin/tools
- name: Run lint
run: |
go list ./... | xargs go vet
- name: Run unit tests
run: |
bin/test-unit
dockerbuild:
needs: [unit-tests]
runs-on: ubuntu-16.04
# Cannot run for pushes in forked repos, without adapting this workflow
# dependabots pushes directly now, but needs PR review since secrets are missing
if: >
github.repository == 'cloudfoundry-incubator/quarks-operator' &&
!contains(["dependabot"], "${{ github.actor }}")
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.3
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install shared tools
run: |
bin/tools
git config user.email "[email protected]"
git config user.name "$GITHUB_ACTOR"
- name: Prepare docker build
run: |
go mod vendor
- uses: whoan/docker-build-with-cache-action@v5
with:
username: cfcontainerizationbot
# container registry personal access token
password: "${{ secrets.CR_PAT }}"
registry: "${{ env.DOCKER_IMAGE_ORG }}"
image_name: "${{ env.DOCKER_IMAGE_REPOSITORY }}"
image_tag: "${{ env.DOCKER_IMAGE_TAG }}"
e2e-tests:
needs: [dockerbuild]
runs-on: ubuntu-16.04
strategy:
matrix:
kubernetes_version: [v1.16.15,v1.18.15,v1.20.2]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.3
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Go dependencies
run: |
sudo gem install bosh-template
go install github.com/onsi/ginkgo/[email protected]
- name: Install shared tools
run: |
bin/tools
git config user.email "[email protected]"
git config user.name "$GITHUB_ACTOR"
- name: Create k8s Kind Cluster
uses: engineerd/[email protected]
with:
config: .github/kind-config.yaml
version: v0.10.0
image: kindest/node:${{matrix.kubernetes_version}}
- name: Run cluster tests
run: |
bin/build-helm
bin/test-cli-e2e
bin/test-helm-e2e
bin/test-helm-e2e-storage
bin/test-helm-e2e-upgrade
env:
NODES: "3"
OPERATOR_TEST_STORAGE_CLASS: "standard"
PROJECT: "quarks-operator"
CF_OPERATOR_WEBHOOK_SERVICE_HOST: 172.17.0.1
- uses: actions/upload-artifact@v2
if: failure()
with:
name: e2e env dump
path: "/tmp/env_dumps"
retention-days: 1
- uses: actions/upload-artifact@v2
if: success()
with:
name: helm chart
path: "helm/quarks-*.tgz"
integration-tests:
needs: [dockerbuild]
runs-on: ubuntu-16.04
strategy:
matrix:
kubernetes_version: [v1.16.15,v1.18.15,v1.20.2]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.3
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Go dependencies
run: |
sudo gem install bosh-template
go install github.com/onsi/ginkgo/[email protected]
- name: Install shared tools
run: |
bin/tools
git config user.email "[email protected]"
git config user.name "$GITHUB_ACTOR"
- name: Create k8s Kind Cluster
uses: engineerd/[email protected]
with:
config: .github/kind-config.yaml
version: v0.10.0
image: kindest/node:${{matrix.kubernetes_version}}
- name: Run cluster tests
run: |
bin/test-integration
INTEGRATION_SUITE=storage bin/test-integration
INTEGRATION_SUITE=util bin/test-integration
env:
NODES: "3"
DEBUG: "yes"
OPERATOR_TEST_STORAGE_CLASS: "standard"
PROJECT: "quarks-operator"
CF_OPERATOR_WEBHOOK_SERVICE_HOST: 172.17.0.1
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ginkgo debug logs
path: "**/ginkgo-node-*.log"
retention-days: 2
publish:
needs: [integration-tests,e2e-tests]
runs-on: ubuntu-latest
# only run if this is a push with a release tag
if: startsWith( github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v2
- name: Install shared tools
run: |
bin/tools
- name: Setup git
run: |
git config --global user.name "CFContainerizationBot"
git config --global user.email "[email protected]"
- name: Get version number
shell: bash
run: |
. ./bin/include/versioning
echo "##[set-output name=artifact_version;]$(echo $ARTIFACT_VERSION)"
id: get_version
- name: Get current tag
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}
- name: Drafts release notes
uses: release-drafter/release-drafter@v5
with:
name: "${{ steps.get_tag.outputs.TAG }} 🌈"
tag: ${{ steps.get_version.outputs.artifact_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: create_release
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: cfcontainerizationbot
password: ${{ secrets.CR_PAT }}
- name: Promote docker image
shell: bash
run: |
pre="$DOCKER_IMAGE_ORG/$DOCKER_IMAGE_REPOSITORY:$DOCKER_IMAGE_TAG"
image="$DOCKER_RELEASE_ORG/$DOCKER_RELEASE_REPOSITORY:$ARTIFACT_VERSION"
docker pull "$pre"
docker tag "$pre" "$image"
docker push "$image"
env:
ARTIFACT_VERSION: "${{ steps.get_version.outputs.artifact_version }}"
- name: Build binary to attach later
shell: bash
run: |
bin/build
zip --junk-paths quarks-operator-linux-amd64.zip binaries/quarks-operator
env:
ARTIFACT_VERSION: "${{ steps.get_version.outputs.artifact_version }}"
- name: Checkout helm chart repo
uses: actions/checkout@master
with:
repository: cloudfoundry-incubator/quarks-helm
ref: refs/heads/master
path: helm-charts
# github personal access token, for pushing commits
token: ${{ secrets.GH_PAT }}
- name: Build and commit helm chart
run: |
bin/build-helm
echo "##[set-output name=sha;]$( sha256sum helm/*.tgz | head -1 | cut -f1 -d ' ' )"
helm repo index --merge helm-charts/index.yaml helm/
cp -p helm/quarks*.tgz helm-charts/
cp helm/index.yaml helm-charts/
cd helm-charts
git add .
git commit -m "add helm chart for $ARTIFACT_VERSION"
git push
env:
DOCKER_IMAGE_ORG: "${{ env.DOCKER_RELEASE_ORG }}"
DOCKER_IMAGE_REPOSITORY: "${{ env.DOCKER_RELEASE_REPOSITORY }}"
ARTIFACT_VERSION: "${{ steps.get_version.outputs.artifact_version }}"
DOCKER_IMAGE_TAG: "${{ steps.get_version.outputs.artifact_version }}"
id: build_helm
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install git-pull-request tool
run: pip3 install git-pull-request
- name: Checkout kubecf repo
uses: actions/checkout@master
with:
repository: cloudfoundry-incubator/kubecf
ref: refs/heads/master
path: kubecf
# github personal access token, for pushing commits
token: ${{ secrets.GH_PAT }}
- name: Create KubeCF PR
shell: bash
run: |
version=$(echo "$version" | sed 's/^v//;s/-/+/')
url_version=$(echo "$version" | sed 's/+/%2B/')
cd kubecf
sed -i "/cf_operator:/{n;s/sha256: \(.*\)/sha256: ${sha}/}" ./dependencies.yaml
sed -i "/cf_operator:/{n;n;n;s/version: \(.*\)/version: ${url_version}/}" ./dependencies.yaml
git checkout -b bot/cf-operator
git add .
git commit -m "feat: bump quarks $version"
git push -f origin bot/cf-operator
# Create PR
export GIT_ASKPASS=./git-password.sh
cat > git-password.sh <<EOF
#!/bin/sh
echo "$token"
EOF
chmod +x git-password.sh
git config --global core.editor "cat"
git config --global credential.helper cache
git config credential.https://github.com.username CFContainerizationBot
git pull-request --no-fork --title "feat: update cf-operator dependency." --message "Increment quarks-operator version in def.bzl file."
env:
sha: "${{ steps.build_helm.outputs.sha }}"
version: "${{ steps.get_version.outputs.artifact_version }}"
token: ${{ secrets.GH_PAT }}
# You have to manually delete wrong assets from the release and wait for them to vanish
- name: Upload release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "quarks-operator-linux-amd64.zip"
asset_name: "quarks-operator-linux-amd64"
asset_content_type: application/zip