-
Notifications
You must be signed in to change notification settings - Fork 759
352 lines (294 loc) Β· 10.9 KB
/
workflow.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
352
name: build_test
on:
push:
paths-ignore:
- ".github/workflows/website.yaml"
- "docs/**"
- "library/**"
- "demo/**"
- "deprecated/**"
- "example/**"
- "website/**"
- "**.md"
- "!cmd/build/helmify/static/README.md"
pull_request:
paths-ignore:
- ".github/workflows/website.yaml"
- "docs/**"
- "library/**"
- "demo/**"
- "deprecated/**"
- "example/**"
- "website/**"
- "**.md"
- "!cmd/build/helmify/static/README.md"
permissions: read-all
jobs:
lint:
name: "Lint"
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
egress-policy: audit
- name: Set up Go 1.20
uses: actions/setup-go@v4 # v4.0.1
with:
go-version: "1.20"
- name: Check out code into the Go module directory
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
# source: https://github.com/golangci/golangci-lint-action
- name: golangci-lint
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
# version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.51.2
test:
name: "Unit test"
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
egress-policy: audit
- name: Set up Go 1.20
uses: actions/setup-go@v4 # v4.0.1
with:
go-version: "1.20"
- name: Check out code into the Go module directory
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Unit test
run: make native-test
- name: Codecov Upload
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
with:
flags: unittests
file: ./cover.out
fail_ci_if_error: false
check_manifest:
name: "Check codegen and manifest"
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
egress-policy: audit
- name: Check out code into the Go module directory
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.2
- name: Set up Go 1.20
uses: actions/setup-go@v4 # v4.0.1
with:
go-version: "1.20"
- name: Check go.mod and manifests
run: |
# there should be no additional manifest or go.mod changes
go mod tidy
git diff --exit-code
make generate manifests
git diff --exit-code
gator_test:
name: "Test Gator"
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
egress-policy: audit
- name: Set up Go 1.20
uses: actions/setup-go@v4 # v4.0.1
with:
go-version: "1.20"
- name: Check out code into the Go module directory
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Download e2e dependencies
run: |
mkdir -p $GITHUB_WORKSPACE/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
make e2e-dependencies KUBERNETES_VERSION=${{ matrix.KUBERNETES_VERSION }}
- name: gator test
run: make test-gator-containerized
build_test:
name: "Build and Test"
runs-on: ubuntu-22.04
timeout-minutes: 15
strategy:
matrix:
KUBERNETES_VERSION: ["1.24.12", "1.25.8", "1.26.3", "1.27.1"]
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
egress-policy: audit
- name: Check out code into the Go module directory
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Set up Go 1.20
uses: actions/setup-go@v4 # v4.0.1
with:
go-version: "1.20"
- name: Bootstrap e2e
run: |
mkdir -p $GITHUB_WORKSPACE/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
make e2e-bootstrap KUBERNETES_VERSION=${{ matrix.KUBERNETES_VERSION }}
- name: Run e2e
run: |
make docker-buildx \
IMG=gatekeeper-e2e:latest
make e2e-build-load-externaldata-image
kind load docker-image --name kind \
gatekeeper-e2e:latest
make deploy \
IMG=gatekeeper-e2e:latest \
USE_LOCAL_IMG=true
make test-e2e
- name: Save logs
if: ${{ always() }}
run: |
kubectl logs -n gatekeeper-system -l control-plane=controller-manager --tail=-1 > logs-controller.json
kubectl logs -n gatekeeper-system -l control-plane=audit-controller --tail=-1 > logs-audit.json
- name: Upload artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ always() }}
with:
name: logs
path: |
logs-*.json
helm_build_test:
name: "[Helm] Build and Test"
runs-on: ubuntu-22.04
timeout-minutes: 15
strategy:
matrix:
HELM_VERSION: ["3.7.2"]
GATEKEEPER_NAMESPACE: ["gatekeeper-system", "custom-namespace"]
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
egress-policy: audit
- name: Check out code into the Go module directory
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Bootstrap e2e
run: |
mkdir -p $GITHUB_WORKSPACE/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
make e2e-bootstrap
- name: Run e2e
run: |
make docker-buildx \
IMG=gatekeeper-e2e:latest \
GATEKEEPER_NAMESPACE=${{ matrix.GATEKEEPER_NAMESPACE }}
make docker-buildx-crds \
CRD_IMG=gatekeeper-crds:latest \
GATEKEEPER_NAMESPACE=${{ matrix.GATEKEEPER_NAMESPACE }}
make e2e-build-load-externaldata-image \
GATEKEEPER_NAMESPACE=${{ matrix.GATEKEEPER_NAMESPACE }}
kind load docker-image --name kind \
gatekeeper-e2e:latest \
gatekeeper-crds:latest
make e2e-helm-deploy \
HELM_REPO=gatekeeper-e2e \
HELM_CRD_REPO=gatekeeper-crds \
HELM_RELEASE=latest \
HELM_VERSION=${{ matrix.HELM_VERSION }} \
GATEKEEPER_NAMESPACE=${{ matrix.GATEKEEPER_NAMESPACE }}
make test-e2e \
GATEKEEPER_NAMESPACE=${{ matrix.GATEKEEPER_NAMESPACE }}
- name: Save logs
if: ${{ always() }}
run: |
kubectl logs -n ${{ matrix.GATEKEEPER_NAMESPACE }} -l control-plane=controller-manager --tail=-1 > logs-helm-${{ matrix.HELM_VERSION }}-${{ matrix.GATEKEEPER_NAMESPACE }}-controller.json
kubectl logs -n ${{ matrix.GATEKEEPER_NAMESPACE }} -l control-plane=audit-controller --tail=-1 > logs-helm-${{ matrix.HELM_VERSION }}-${{ matrix.GATEKEEPER_NAMESPACE }}-audit.json
kubectl logs -n ${{ matrix.GATEKEEPER_NAMESPACE }} -l run=dummy-provider --tail=-1 > logs-helm-${{ matrix.HELM_VERSION }}-${{ matrix.GATEKEEPER_NAMESPACE }}-dummy-provider.json
- name: Upload artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ always() }}
with:
name: helm-logs
path: |
logs-*.json
build_test_generator_expansion:
name: "[Generator Resource Expansion] Build and Test"
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
egress-policy: audit
- name: Check out code into the Go module directory
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Set up Go 1.20
uses: actions/setup-go@v4 # v4.0.1
with:
go-version: "1.20"
- name: Bootstrap e2e
run: |
mkdir -p $GITHUB_WORKSPACE/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
make e2e-bootstrap
- name: Run e2e
run: |
make docker-buildx \
IMG=gatekeeper-e2e:latest
make e2e-build-load-externaldata-image
kind load docker-image --name kind \
gatekeeper-e2e:latest
make deploy \
IMG=gatekeeper-e2e:latest \
USE_LOCAL_IMG=true \
ENABLE_GENERATOR_EXPANSION=true
go mod tidy
# there should be no additional manifest or go.mod changes
git diff --exit-code
make test-e2e ENABLE_GENERATOR_EXPANSION_TESTS=1
- name: Save logs
if: ${{ always() }}
run: |
kubectl logs -n gatekeeper-system -l control-plane=controller-manager --tail=-1 > logs-generatorexpansion-controller.json
kubectl logs -n gatekeeper-system -l control-plane=audit-controller --tail=-1 > logs-generatorexpansion-audit.json
- name: Upload artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ always() }}
with:
name: generatorexpansion-logs
path: |
logs-*.json
scan_vulnerabilities:
name: "[Trivy] Scan for vulnerabilities"
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
egress-policy: audit
- name: Check out code into the Go module directory
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Download trivy
run: |
pushd $(mktemp -d)
wget https://github.com/aquasecurity/trivy/releases/download/v${{ env.TRIVY_VERSION }}/trivy_${{ env.TRIVY_VERSION }}_Linux-64bit.tar.gz
tar zxvf trivy_${{ env.TRIVY_VERSION }}_Linux-64bit.tar.gz
echo "$(pwd)" >> $GITHUB_PATH
env:
TRIVY_VERSION: "0.41.0"
- name: Run trivy on git repository
run: |
trivy fs --format table --ignore-unfixed --skip-dirs website --scanners vuln .
- name: Build docker images
run: |
make docker-buildx \
IMG=gatekeeper-e2e:latest
make docker-buildx-crds \
CRD_IMG=gatekeeper-crds:latest
- name: Run trivy on images
run: |
for img in "gatekeeper-e2e:latest" "gatekeeper-crds:latest"; do
trivy image --ignore-unfixed --vuln-type="os,library" "${img}"
done