-
Notifications
You must be signed in to change notification settings - Fork 122
329 lines (298 loc) · 11.5 KB
/
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
name: CI
on:
push:
branches:
- 'main'
- '[0-9]+.[1-9][0-9]*.x'
pull_request:
branches:
- 'main'
- '[0-9]+.[1-9][0-9]*.x'
- 'epic/*'
paths-ignore:
- "docs/**"
- "**.md"
- "netlify.toml"
- "mkdocs.yml"
- ".github/actions/spelling/*"
# Declare default permissions as read only.
permissions: read-all
env:
GO_VERSION: "~1.21"
# renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools
CONTROLLER_TOOLS_VERSION: "v0.13.0"
ENVTEST_K8S_VERSION: "1.24.2"
SCHEDULER_COMPATIBLE_K8S_VERSION: "v0.24.3"
defaults:
run:
shell: bash
jobs:
prepare_ci_run:
name: Prepare CI Run
runs-on: ubuntu-22.04
outputs:
GIT_SHA: ${{ steps.extract_branch.outputs.GIT_SHA }}
BRANCH: ${{ steps.extract_branch.outputs.BRANCH }}
BRANCH_SLUG: ${{ steps.extract_branch.outputs.BRANCH_SLUG }}
DATETIME: ${{ steps.get_datetime.outputs.DATETIME }}
BUILD_TIME: ${{ steps.get_datetime.outputs.BUILD_TIME }}
NON_FORKED_AND_NON_ROBOT_RUN: ${{ steps.get_run_type.outputs.NON_FORKED_AND_NON_ROBOT_RUN }}
steps:
- name: Check out code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Extract branch name
id: extract_branch
uses: keptn/gh-action-extract-branch-name@6ca4fe061da10c66b2d7341fd1fb12962ad911b2
- name: Get current date and time
id: get_datetime
run: |
DATETIME=$(date +'%Y%m%d%H%M')
BUILD_TIME=$(date -u "+%F_%T")
echo "DATETIME=$DATETIME" >> "$GITHUB_OUTPUT"
echo "BUILD_TIME=$BUILD_TIME" >> "$GITHUB_OUTPUT"
- name: Get workflow run type
id: get_run_type
env:
NON_FORKED_AND_NON_ROBOT_RUN: >
${{
( github.actor != 'renovate[bot]' && github.actor != 'dependabot[bot]' ) &&
( github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository )
}}
run: |
echo "github.actor != 'renovate[bot]' = ${{ github.actor != 'renovate[bot]' }}"
echo "github.actor != 'dependabot[bot]' = ${{ github.actor != 'dependabot[bot]' }}"
echo "github.event_name == 'push' = ${{ github.event_name == 'push' }}"
echo "github.event.pull_request.head.repo.full_name == github.repository = \
${{ github.event.pull_request.head.repo.full_name == github.repository }}"
echo "NON_FORKED_AND_NON_ROBOT_RUN = $NON_FORKED_AND_NON_ROBOT_RUN"
echo "NON_FORKED_AND_NON_ROBOT_RUN=$NON_FORKED_AND_NON_ROBOT_RUN" >> "$GITHUB_OUTPUT"
test:
name: Unit Tests
needs: prepare_ci_run
runs-on: ubuntu-22.04
strategy:
matrix:
config:
- name: "lifecycle-operator"
folder: "lifecycle-operator/"
- name: "metrics-operator"
folder: "metrics-operator/"
- name: "scheduler"
folder: "scheduler/"
- name: "certificate-operator"
folder: "keptn-cert-manager/"
steps:
- name: Check out code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Set up Go 1.x
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: '${{ matrix.config.folder }}go.sum'
check-latest: true
- name: Unit Test ${{ matrix.config.name }}
working-directory: ./${{ matrix.config.folder }}
run: make unit-test
- name: Report code coverage
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # v4.3.1
with:
flags: ${{ matrix.config.name }}
token: ${{ secrets.CODECOV_TOKEN }}
build_image:
name: Build Docker Image
needs: prepare_ci_run
runs-on: ubuntu-22.04
env:
BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }}
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
BUILD_TIME: ${{ needs.prepare_ci_run.outputs.BUILD_TIME }}
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }}
RELEASE_REGISTRY: "localhost:5000/keptn"
strategy:
matrix:
config:
- name: "lifecycle-operator"
folder: "lifecycle-operator/"
- name: "metrics-operator"
folder: "metrics-operator/"
- name: "scheduler"
folder: "scheduler/"
- name: "deno-runtime"
folder: "runtimes/deno-runtime/"
- name: "python-runtime"
folder: "runtimes/python-runtime/"
- name: "certificate-operator"
folder: "keptn-cert-manager/"
steps:
- name: Check out code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Cache build tools
id: cache-build-tools
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: ./${{ matrix.config.folder }}bin
key: build-tools-${{ github.ref_name }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3
- name: Build Docker Image
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
context: ${{ matrix.config.folder }}
platforms: linux/amd64,linux/arm64
target: production
tags: |
${{ env.RELEASE_REGISTRY }}/${{ matrix.config.name }}:dev-${{ env.DATETIME }}
build-args: |
GIT_HASH=${{ env.GIT_SHA }}
RELEASE_VERSION=dev-${{ env.DATETIME }}
BUILD_TIME=${{ env.BUILD_TIME }}
CONTROLLER_TOOLS_VERSION=${{ env.CONTROLLER_TOOLS_VERSION }}
SCHEDULER_COMPATIBLE_K8S_VERSION=${{ env.SCHEDULER_COMPATIBLE_K8S_VERSION }}
builder: ${{ steps.buildx.outputs.name }}
push: false
cache-from: type=gha,scope=${{ github.ref_name }}-${{ matrix.config.name }}
cache-to: type=gha,scope=${{ github.ref_name }}-${{ matrix.config.name }}
outputs: type=oci,dest=/tmp/${{ matrix.config.name }}-image.tar
- name: Upload image as artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
with:
name: ${{ matrix.config.name }}-image.tar
path: /tmp/${{ matrix.config.name }}-image.tar
image_tag:
name: Store tag of the built images
needs: prepare_ci_run
runs-on: ubuntu-22.04
env:
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
steps:
- name: Create empty file to store image tag
run: echo "" > tag
- name: Upload tag for tests
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
with:
name: dev-${{ env.DATETIME }}
path: tag
component_tests:
name: Component Tests
needs: prepare_ci_run
uses: ./.github/workflows/component-test.yml
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
integration_tests:
name: Integration Tests
needs:
- prepare_ci_run
- build_image
strategy:
matrix:
scheduling-gates: [gates_on, gates_off]
cert-manager-io-enabled: [cert_manager_io_on, cert_manager_io_off]
exclude:
- scheduling-gates: gates_on
cert-manager-io-enabled: cert_manager_io_on
with:
runtime_tag: dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
scheduling-gates: ${{ matrix.scheduling-gates }}
cert-manager-io-enabled: ${{ matrix.cert-manager-io-enabled }}
uses: ./.github/workflows/integration-test.yml
integration_tests_allowed_namespaces:
name: Integration Tests Allowed Namespaces
needs:
- prepare_ci_run
- build_image
with:
runtime_tag: dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
type: allowed-namespaces
uses: ./.github/workflows/integration-test-component.yml
integration_tests_lifecycle:
name: Integration Tests Lifecycle
needs:
- prepare_ci_run
- build_image
with:
runtime_tag: dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
type: lifecycle
uses: ./.github/workflows/integration-test-component.yml
integration_tests_metrics:
name: Integration Tests Metrics
needs:
- prepare_ci_run
- build_image
with:
runtime_tag: dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
type: metrics
uses: ./.github/workflows/integration-test-component.yml
integration_tests_cert_manager:
name: Integration Tests Cert Manager
needs:
- prepare_ci_run
- build_image
with:
runtime_tag: dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
type: cert-manager
uses: ./.github/workflows/integration-test-component.yml
load-tests:
name: Load Tests
needs: [prepare_ci_run, build_image]
with:
runtime_tag: dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
uses: ./.github/workflows/load-test.yml
e2e_tests:
name: End to End Tests
needs: [prepare_ci_run, build_image]
with:
runtime_tag: dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
uses: ./.github/workflows/e2e-test.yml
helm_charts_publish:
name: Publish helm chart changes to charts repo
if: github.event_name == 'push' && needs.prepare_ci_run.outputs.NON_FORKED_AND_NON_ROBOT_RUN == 'true'
needs: [prepare_ci_run, build_image]
strategy:
matrix:
config:
- name: keptn
path: chart
- name: keptn-lifecycle-operator
path: lifecycle-operator/chart
- name: keptn-metrics-operator
path: metrics-operator/chart
- name: keptn-cert-manager
path: keptn-cert-manager/chart
runs-on: ubuntu-22.04
steps:
- name: Check out keptn repo
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Check out helm-charts repo
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: 'keptn/lifecycle-toolkit-charts'
path: ./helm-charts-repository
token: ${{ secrets.KEPTN_BOT_TOKEN }}
- name: Substitue local paths with official chart URL
if: matrix.config.name == 'keptn'
working-directory: ./${{ matrix.config.path }}
run: |
# substitute local charts path with official ones
yq -i '.dependencies.[].repository = "https://charts.lifecycle.keptn.sh"' ./Chart.yaml
# update Chart.lock files
helm repo add keptn https://charts.lifecycle.keptn.sh
helm repo update
helm dependency update
helm dependency build
- name: Copy chart from keptn to helm repo
run: rsync -av --delete --exclude='charts/*.tgz' ./${{ matrix.config.path }}/ ./helm-charts-repository/charts/${{ matrix.config.name }}/
- name: Create Pull Request
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
with:
token: ${{ secrets.KEPTN_BOT_TOKEN }}
path: ./helm-charts-repository
commit-message: "feat: update ${{ matrix.config.name }} helm chart"
signoff: true
branch: chart-update-${{ matrix.config.name }}
delete-branch: true
base: main
title: "Update ${{ matrix.config.name }} Helm chart"
body: |
:robot: **This is an automated PR for updating and releasing Helm charts from keptn/lifecycle-toolkit!** :robot: