-
Notifications
You must be signed in to change notification settings - Fork 4
268 lines (235 loc) · 8.34 KB
/
checks.yml
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
# Copyright 2023 Nutanix. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: checks
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
merge_group:
types:
- checks_requested
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
unit-test:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.11.0
with:
enable-cache: true
- name: Go cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run unit tests
run: devbox run -- make test
- name: Annotate tests
if: always()
uses: guyarb/golang-test-annotations@v0.8.0
with:
test-results: test.json
e2e-quick-start:
needs:
- "lint-gha"
- "lint-go"
- "lint-test-helm"
- "pre-commit"
- "unit-test"
strategy:
matrix:
config:
- {"provider": "Nutanix", "kubernetesVersion": "v1.29.6", "osImage": "nkp-rocky-9.4-release-1.29.6-20240816215147"}
- {"provider": "Nutanix", "kubernetesVersion": "v1.30.5", "osImage": "nkp-rocky-9.4-release-1.30.5-20240930171619"}
- {"provider": "Docker", "kubernetesVersion": "v1.29.8"}
- {"provider": "Docker", "kubernetesVersion": "v1.30.5"}
- {"provider": "Docker", "kubernetesVersion": "v1.31.0"}
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
# - {"provider": "AWS", "kubernetesVersion": "v1.29.6"}
fail-fast: false
name: e2e-quick-start (${{ matrix.config.provider }}, ${{ matrix.config.kubernetesVersion }})
uses: ./.github/workflows/e2e.yml
with:
focus: Quick start
provider: ${{ matrix.config.provider }}
kubernetes-version: ${{ matrix.config.kubernetesVersion }}
runs-on: ${{ matrix.config.provider == 'Nutanix' && 'self-hosted-ncn-dind' || 'ubuntu-22.04' }}
os-image: ${{ matrix.config.provider == 'Nutanix' && matrix.config.osImage || '' }}
secrets: inherit
permissions:
contents: read
checks: write
e2e-self-hosted:
needs:
- "lint-gha"
- "lint-go"
- "lint-test-helm"
- "pre-commit"
- "unit-test"
strategy:
matrix:
config:
- {"provider": "Docker", "kubernetesVersion": "v1.29.8"}
- {"provider": "Docker", "kubernetesVersion": "v1.30.5"}
- {"provider": "Docker", "kubernetesVersion": "v1.31.0"}
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
# - {"provider": "Nutanix", "kubernetesVersion": "v1.29.6"}
# - {"provider": "AWS", "kubernetesVersion": "v1.29.6"}
fail-fast: false
uses: ./.github/workflows/e2e.yml
with:
focus: Self-hosted
provider: ${{ matrix.config.provider }}
kubernetes-version: ${{ matrix.config.kubernetesVersion }}
runs-on: ${{ matrix.config.provider == 'Nutanix' && 'self-hosted-ncn-dind' || 'ubuntu-22.04' }}
secrets: inherit
permissions:
contents: read
checks: write
lint-go:
runs-on: ubuntu-22.04
strategy:
matrix:
module: [api, common, .]
fail-fast: false
permissions:
pull-requests: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.11.0
with:
enable-cache: true
- name: Export golang and golangci-lint versions
id: versions
run: |
echo "golangci-lint=$(devbox run -- golangci-lint version --format short)" >>"${GITHUB_OUTPUT}"
echo "golang=$(devbox run -- go version | grep -o "[[:digit:]]\+.[[:digit:]]\+\(.[[:digit:]]\+\)\?")" >>"${GITHUB_OUTPUT}"
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
fail_on_error: true
reporter: github-pr-review
golangci_lint_version: v${{ steps.versions.outputs.golangci-lint }}
go_version: v${{ steps.versions.outputs.golang }}
workdir: ${{ matrix.module }}
golangci_lint_flags: "--config=${{ github.workspace }}/.golangci.yml"
lint-gha:
runs-on: ubuntu-22.04
permissions:
pull-requests: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: actionlint
uses: reviewdog/action-actionlint@v1
with:
fail_on_error: true
reporter: github-pr-review
pre-commit:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.11.0
with:
enable-cache: true
- name: Go cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up pre-commit cache
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: devbox run -- make pre-commit
env:
SKIP: no-commit-to-branch,golangci-lint,actionlint-system
lint-test-helm:
runs-on: ubuntu-22.04
env:
KIND_CLUSTER_NAME: chart-testing
KIND_KUBECONFIG: ct-kind-kubeconfig
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.11.0
with:
enable-cache: true
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed="$(devbox run -- \
ct list-changed --config charts/ct-config.yaml \
)"
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- if: steps.list-changed.outputs.changed == 'true'
name: Run chart-testing (lint)
run: |
devbox run -- \
ct lint --config charts/ct-config.yaml
- if: steps.list-changed.outputs.changed == 'true'
name: Create kind cluster
run: devbox run -- make kind.create
- if: steps.list-changed.outputs.changed == 'true'
name: Build Docker images
run: devbox run -- make release-snapshot
- if: steps.list-changed.outputs.changed == 'true'
name: Export image tag
id: export-image-tag
run: echo test-image-tag="$(devbox run -- gojq -r .version dist/metadata.json)-$(devbox run -- go env GOARCH)" >> "$GITHUB_OUTPUT"
- if: steps.list-changed.outputs.changed == 'true'
name: Sideload docker image
run: |
devbox run -- \
kind load docker-image \
--name "${KIND_CLUSTER_NAME}" \
"ko.local/cluster-api-runtime-extensions-nutanix:${{ steps.export-image-tag.outputs.test-image-tag }}" \
"ghcr.io/nutanix-cloud-native/caren-helm-reg:${{ steps.export-image-tag.outputs.test-image-tag }}"
- if: steps.list-changed.outputs.changed == 'true'
name: Setup Cluster API and cert-manager
run: devbox run -- make clusterctl.init
- if: steps.list-changed.outputs.changed == 'true'
name: Run chart-testing (install)
run: |
devbox run -- \
ct install \
--config charts/ct-config.yaml \
--helm-extra-set-args "--set-string image.repository=ko.local/cluster-api-runtime-extensions-nutanix --set-string image.tag=${{ steps.export-image-tag.outputs.test-image-tag }} --set-string helmRepository.images.bundleInitializer.tag=${{ steps.export-image-tag.outputs.test-image-tag }}"
env:
KUBECONFIG: ${{ env.KIND_KUBECONFIG }}
- if: steps.list-changed.outputs.changed == 'true' && always()
name: Delete chart-testing KinD cluster
run: |
devbox run -- make kind.delete