-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathci.yml
More file actions
226 lines (207 loc) · 8.78 KB
/
ci.yml
File metadata and controls
226 lines (207 loc) · 8.78 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
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
version: '3'
tasks:
configure:
desc: "Configure a CI agent"
cmds:
# operator go test is using at least 2 k3d clusters which might exhaust limits of opened files
- task: set-aio-max
- task: set-inotify-watches
- task: set-inotify-instances
- task: configure-git-private-repo
lint:
cmds:
- task: :generate
- task: :lint
# Fail on any generated diffs.
- git diff --exit-code
test:unit:
cmds:
- defer: 'buildkite-agent artifact upload "{{.SRC_DIR}}/unit-tests-*.xml"'
- task: :test:unit
vars:
GO_TEST_RUNNER: gotestsum --raw-command --junitfile=unit-tests-%.xml -- go test
CLI_ARGS: '-json {{.CLI_ARGS}}'
test:integration:
cmds:
- defer: 'kind delete clusters --all'
- task: :charts:kind-cluster
- defer: 'buildkite-agent artifact upload "{{.SRC_DIR}}/integration-tests-*.xml"'
- task: :test:integration
vars:
GO_TEST_RUNNER: gotestsum --raw-command --junitfile=integration-tests-%.xml -- go test
CLI_ARGS: '-json {{.CLI_ARGS}}'
test:acceptance:
cmds:
- defer: 'kind delete clusters --all'
- task: :charts:kind-cluster
- defer: 'buildkite-agent artifact upload "{{.SRC_DIR}}/acceptance-tests-*.xml"'
- task: :test:acceptance
vars:
GO_TEST_RUNNER: gotestsum --raw-command --junitfile=acceptance-tests-%.xml -- go test
CLI_ARGS: '-json {{.CLI_ARGS}}'
test:kuttl-v1:
cmds:
- 'echo "~~~ Running kuttl V1 tests :k8s:"'
- task: run-kuttl-tests
test:kuttl-v1-nodepools:
cmds:
- 'echo "~~~ Running kuttl V1 Nodepools tests :k8s:"'
- task: run-kuttl-tests
vars:
KUTTL_CONFIG_FILE: kuttl-test-with-flags.yaml
test:kuttl-v2:
cmds:
- 'echo "~~~ Running kuttl V2 tests :k8s:"'
- task: run-kuttl-tests
vars:
KUTTL_CONFIG_FILE: kuttl-v2-test.yaml
configure-git-private-repo:
internal: true
env:
GITHUB_TOKEN:
sh: echo "${GITHUB_TOKEN:-$GITHUB_API_TOKEN}"
cmds:
- git config --global url."https://$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
preconditions:
- test -n "$GITHUB_API_TOKEN" || test -n "$GITHUB_TOKEN"
run-kuttl-tests:
cmds:
- defer:
task: ci:kuttl-artifact-upload
vars:
KUTTL_CONFIG_FILE: '{{.KUTTL_CONFIG_FILE}}'
- task: :k8s:run-kuttl-tests
vars:
KUTTL_CONFIG_FILE: '{{.KUTTL_CONFIG_FILE}}'
kuttl-artifact-upload:
internal: true
desc: uploads artifact when kuttl fails
dir: operator
summary: |
kuttl-artifact-upload should be called in `defer`.
https://taskfile.dev/usage/#doing-task-cleanup-with-defer
As buildkite pipeline step are wrapped with shell script, that executes
docker run of a NIX container, where the permission are set to user of
ID 0 (root). The buildkite agent executor can not resolve glob due to
not sufficient permission. All invocation, within taskfile, of
`buildkite-agent artifact upload` will have sufficient permission.
vars:
KUTTL_CONFIG_FILE: '{{default "kuttl-test.yaml" .KUTTL_CONFIG_FILE}}'
KUTTL_ARTIFACTS_DIR:
sh: |
cat {{.KUTTL_CONFIG_FILE}} | grep artifactsDir | awk '{print $2}'
cmds:
- tar -czf {{.KUTTL_ARTIFACTS_DIR | base}}.tar.gz {{.KUTTL_ARTIFACTS_DIR}}
- buildkite-agent artifact upload "{{.SRC_DIR}}/operator/{{.KUTTL_ARTIFACTS_DIR | base}}.tar.gz"
- buildkite-agent artifact upload "{{.SRC_DIR}}/operator/{{.KUTTL_ARTIFACTS_DIR}}/kuttl-report.xml"
publish-operator-image:
deps:
- :dev:create-buildx-builder
cmds:
- 'echo "~~~ Logging into Dockerhub :docker:"'
- cmd: docker login --username {{.DOCKERHUB_USER}} --password {{.DOCKERHUB_TOKEN}}
silent: true
- defer: docker logout
- 'echo "~~~ Tagging and uploading images to Dockerhub :docker:"'
- task: :build:operator-image
vars:
TAGS:
- docker.io/vectorized/redpanda-operator:{{.OPERATOR_VERSION}}
- docker.io/redpandadata/redpanda-operator:{{.OPERATOR_VERSION}}
PLATFORMS:
- linux/amd64
- linux/arm64
CLI_ARGS: "--push"
publish-nightly-artifacts:
deps:
- :dev:create-buildx-builder
cmds:
- 'echo "~~~ Logging into Dockerhub :docker:"'
- cmd: docker login --username {{.DOCKERHUB_USER}} --password {{.DOCKERHUB_TOKEN}}
silent: true
- defer: docker logout
- 'echo "~~~ Tagging and uploading images to nightly Dockerhub :docker:"'
- task: :build:operator-image
vars:
TAGS:
- docker.io/redpandadata/redpanda-operator-nightly:{{.OPERATOR_VERSION}}
PLATFORMS:
- linux/amd64
- linux/arm64
CLI_ARGS: "--push"
# Package and push Operator helm chart to Dockerhub
- task: publish:nightly:helm:chart
vars: {REPO: redpanda-operator-nightly, CHART: operator, VERSION: "{{ .OPERATOR_CHART_VERSION }}"}
- task: publish:nightly:helm:chart
vars: {REPO: console-unstable, CHART: console, VERSION: "{{ .CONSOLE_CHART_VERSION }}"}
publish:nightly:helm:chart:
desc: "Packages and pushes a helm chart to redpandadata's dockerhub account as an OCI artifact"
label: "publish:helm:chart:{{ .CHART }}"
requires:
vars: [CHART, VERSION, REPO]
vars:
TMP_PATH:
sh: mktemp --directory --tmpdir "helm-package-XXXXXXXXXX"
cmds:
- defer: 'rm -r {{.TMP_PATH}}'
# NB: cp -r/-R is dependent on the implementation (macOS vs Linux).
# cp -R src/. dest/ <- Same behavior, copy contents of src to dest.
# cp -r src/ dest <- Different. macOS == copy contents, linux == copy src folder into dest.
- cp -R charts/{{ .CHART }}/. {{.TMP_PATH}}
# `helm push`, to an OCI repo, uses `name` and `version` from Chart.yaml
# to determine where to push the chart to.
# i.e. `helm push chart.tgz oci://registry-1.docker.io/<org>` -> <org>/<chart.name>:<chart.version>
# name is set with `yq`
# version is set with `helm package`
- yq -i '.name = "{{ .REPO }}"' {{.TMP_PATH}}/Chart.yaml
# dockerhub has a limitation where oci artifacts may not share tags with images [1].
# We suffix versions with `-helm-chart` to work around this.
# [1]: https://forums.docker.com/t/tag-overlap-in-oci-artifacts/131453
- helm package {{.TMP_PATH}} --version "{{ .VERSION }}-helm-chart" --destination {{.BUILD_ROOT}} --dependency-update
- helm registry login registry-1.docker.io -u {{.DOCKERHUB_USER}} --password {{.DOCKERHUB_TOKEN}}
- defer: 'helm registry logout registry-1.docker.io'
# For usage of operator artifact please go to specific reference like the one below
# https://hub.docker.com/layers/redpandadata/redpanda-operator-nightly/v0.0.0-20250104git4a5a076-helm-chart/images/sha256-ffaea8752b6bd00a26589a168830a87d498106e470f11af0f08267bc13fbd078
- helm push '{{.BUILD_ROOT}}/{{ .REPO }}-{{.VERSION}}-helm-chart.tgz' oci://registry-1.docker.io/redpandadata
set-aio-max:
internal: true
desc: set minimum required value for fs.aio-max-nr sysctl option
vars:
MIN_REQUIRED_AIO_MAX: 20971520
USE_SUDO: '{{default "false" .USE_SUDO}}'
cmds:
- 'echo "Setting fs.aio-max-nr sysctl option to {{.MIN_REQUIRED_AIO_MAX}}"'
- '{{if eq .USE_SUDO "true"}}echo "Please enter your sudo password: "{{end}}'
- '{{if eq .USE_SUDO "true"}}sudo {{end}}sysctl -w fs.aio-max-nr={{.MIN_REQUIRED_AIO_MAX}}'
status:
- test {{.MIN_REQUIRED_AIO_MAX}} -le $(sysctl -nb fs.aio-max-nr)
platforms:
- linux
set-inotify-watches:
internal: true
desc: |
set minimum required value for fs.inotify.max_user_watches sysctl option
REF: https://kind.sigs.k8s.io/docs/user/known-issues/#pod-errors-due-to-too-many-open-files
vars:
MIN_REQUIRED_USER_WATCHES: 1310720
USE_SUDO: '{{default "false" .USE_SUDO}}'
cmds:
- '{{if eq .USE_SUDO "true"}}sudo {{end}}sysctl -w fs.inotify.max_user_watches={{.MIN_REQUIRED_USER_WATCHES}}'
status:
- test {{.MIN_REQUIRED_USER_WATCHES}} -le $(sysctl -nb fs.inotify.max_user_watches)
platforms:
- linux
set-inotify-instances:
internal: true
desc: |
set minimum required value for fs.inotify.max_user_instances sysctl option
REF: https://kind.sigs.k8s.io/docs/user/known-issues/#pod-errors-due-to-too-many-open-files
vars:
MIN_REQUIRED_USER_INSTANCES: 2560
USE_SUDO: '{{default "false" .USE_SUDO}}'
cmds:
- '{{if eq .USE_SUDO "true"}}sudo {{end}}sysctl -w fs.inotify.max_user_instances={{.MIN_REQUIRED_USER_INSTANCES}}'
status:
- test {{.MIN_REQUIRED_USER_INSTANCES}} -le $(sysctl -nb fs.inotify.max_user_instances)
platforms:
- linux