-
Notifications
You must be signed in to change notification settings - Fork 27
326 lines (270 loc) · 8.52 KB
/
ci.yaml
File metadata and controls
326 lines (270 loc) · 8.52 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
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
name: Operator CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
kind-version: 'v0.31.0'
permissions:
contents: read
statuses: write
checks: write
pull-requests: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Go Tidy
run: go mod tidy && git diff --exit-code
- name: Check controller-gen generated
run: make generate && git diff --exit-code
- name: Check manifests generated
run: make manifests && git diff --exit-code
- name: Lint with golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11.4
- name: Lint with codespell
uses: codespell-project/actions-codespell@v2.2
with:
config: ci/.codespellrc
- name: actionlint
uses: raven-actions/actionlint@v2
with:
flags: '-config-file ci/actionlint.yaml'
check-crd-compat:
# Only run on pull requests, and skip when the PR is explicitly labeled as
# an intentional CRD-breaking change. The job is not part of ci-success-check,
# so a failure here does not block the aggregate gate.
if: |
github.event_name == 'pull_request' &&
!contains(github.event.pull_request.labels.*.name, 'crd-breaking-change')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Check CRD backward compatibility
run: make check-crd-compat CRD_BASE_REF=${{ github.event.pull_request.base.sha }}
bundle:
runs-on: ubuntu-latest
env:
VERSION: 0.0.1
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Generate bundle
run: make bundle
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
with:
cluster_name: 'test-bundle'
version: ${{ env.kind-version }}
- name: Export kubeconfig
run: kind export kubeconfig --name test-bundle
- name: Create bundle image
run: make bundle-build
- name: Load image into Kind cluster
run: kind load docker-image ghcr.io/clickhouse/clickhouse-operator-bundle:v0.0.1 --name test-bundle
- name: Run scorecard tests
run: make scorecard
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Go Mod
run: go mod download
- name: Go Mod Verify
run: go mod verify
- name: Build
run: go build -v cmd/main.go
- name: Run tests
run: |
go list ./... | grep -v /e2e
make test-ci
- name: Test Report
uses: dorny/test-reporter@v3
if: ${{ !cancelled() }}
with:
name: Unit tests
badge-title: Unit tests
path: "**/report/*.xml"
reporter: java-junit
fuzz_specs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Go Mod
run: go mod download
- name: Run fuzz tests
run: make fuzz
helm-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Install Helm
run: curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Verify Helm installation
run: helm version
- name: Check helmchart generated
run: make generate-helmchart-ci && git diff --exit-code dist/chart/
- name: Build Helm Chart Dependencies
run: make build-helmchart-dependencies
- name: Lint Helm Chart
run: helm lint ./dist/chart
compat-e2e-test:
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
matrix:
include:
- name: minimal-k8s-all-deploy-methods
k8s_image: v1.28.15
clickhouse_version: "26.3"
deploy_target: test-compat-e2e
- name: maximal-k8s-all-deploy-methods
k8s_image: v1.35.1
clickhouse_version: "26.3"
deploy_target: test-compat-e2e
- name: supported-clickhouse-compatibility
k8s_image: v1.30.13
clickhouse_version: "26.3,26.2,26.1,25.8"
deploy_target: test-compat-e2e-manifest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Free disk space
uses: jlumbroso/free-disk-space@v1.3.0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
with:
cluster_name: kind
version: ${{ env.kind-version }}
config: ci/kind-cluster.config
node_image: "kindest/node:${{ matrix.k8s_image }}"
- name: Go Mod
run: go mod download
- name: Install tools
run: make operator-sdk opm
- name: Pre-pull ClickHouse images into Kind
run: |
for version in $(echo "${{ matrix.clickhouse_version }}" | tr ',' ' '); do
for image in clickhouse/clickhouse-keeper clickhouse/clickhouse-server; do
docker pull "docker.io/${image}:${version}"
kind load docker-image "docker.io/${image}:${version}"
done
done
- name: Run compatibility e2e tests
run: make ${{ matrix.deploy_target }}
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse_version }}
- name: Upload test report
uses: actions/upload-artifact@v6
if: ${{ !cancelled() }}
with:
name: e2e-report-${{ matrix.name }}
path: "**/report/*"
if-no-files-found: error
overwrite: true
e2e-test:
needs: [ lint ]
strategy:
fail-fast: false
matrix:
scope: [ test-keeper-e2e, test-clickhouse-e2e ]
runs-on: [self-hosted, amd-medium]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Go Mod
run: go mod download
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
with:
cluster_name: kind
version: ${{ env.kind-version }}
config: ci/kind-cluster.config
node_image: "kindest/node:v1.34.3" # Can't use newer node image as self-hosted runners use cgroups v1
- name: Run e2e tests
run: make ${{ matrix.scope }}
- name: Upload test report
uses: actions/upload-artifact@v6
if: ${{ !cancelled() }}
with:
name: e2e-report-${{ matrix.scope }}
path: "**/report/*"
if-no-files-found: error
overwrite: true
e2e-report:
needs: [compat-e2e-test, e2e-test]
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
steps:
- name: Download all e2e test reports
uses: actions/download-artifact@v8
with:
pattern: e2e-report-*
- name: Test Report
uses: dorny/test-reporter@v3
with:
name: E2E tests
badge-title: E2E tests
reporter: java-junit
artifact: "/(.*)e2e-report(.*)/"
path: "**/*.xml"
ci-success-check:
name: All CI checks passed
runs-on: ubuntu-latest
needs: [ lint, bundle, build_and_test, fuzz_specs, helm-test, compat-e2e-test, e2e-test, check-crd-compat ]
if: always()
steps:
- name: Determine CI status
id: status
run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "One or more CI jobs failed or were cancelled"
exit 1
else
echo "All required jobs passed successfully"
fi