forked from knative/func
-
Notifications
You must be signed in to change notification settings - Fork 0
485 lines (444 loc) · 13.8 KB
/
functions.yaml
File metadata and controls
485 lines (444 loc) · 13.8 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
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
name: Functions
# To run this workflow's tests locally, see ./hack/test-full.sh
permissions:
id-token: write # Required for signing
contents: read
packages: write
attestations: write
on:
push:
branches:
- main
pull_request:
branches:
- main
# Global version definitions
env:
PYTHON_VERSION: '3.10'
NODE_VERSION: '20'
JAVA_VERSION: '21'
JAVA_DISTRIBUTION: 'temurin'
jobs:
# --------
# PRECHECK
# --------
precheck:
name: Precheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
- name: Check and Lint
run: make check
- name: Check Generated Schema File
run: make check-schema
- name: Check Templates
run: make check-templates
- name: Check Embedded FS
run: make check-embedded-fs
# ----------
# UNIT TESTS
# ----------
test-unit:
name: Unit Tests
needs: precheck
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-latest" # x86_64
- "ubuntu-24.04-arm" # ARM64
- "macos-latest" # Intel
- "macos-14" # ARM
- "windows-latest"
runs-on: ${{ matrix.os }}
steps:
- name: Disable CRLF conversion (Windows)
if: runner.os == 'Windows'
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
- name: Run Unit Tests
run: make test
- uses: codecov/codecov-action@v5
with:
files: ./coverage.txt
flags: unit ${{ matrix.os }}
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
# --------------
# TEMPLATE TESTS
# --------------
test-templates:
name: Template Tests
needs: precheck
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-latest" # x86_64
- "ubuntu-24.04-arm" # ARM64
- "macos-latest" # Intel
- "macos-14" # ARM
- "windows-latest"
runs-on: ${{ matrix.os }}
steps:
# Setup
- name: Disable CRLF conversion (Windows)
if: runner.os == 'Windows'
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
# Toolchains
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
# Run
- name: Templates Tests
run: make test-templates
# -----------------
# INTEGRATION TESTS
# -----------------
test-integration:
name: Integration Tests
needs: precheck
runs-on: ubuntu-latest
env:
FUNC_CLUSTER_RETRIES: 5
FUNC_INT_TEKTON_ENABLED: true
FUNC_INT_GITLAB_ENABLED: true
FUNC_INT_GITLAB_HOSTNAME: gitlab.localtest.me
FUNC_TEST_GITLAB_PASS: test-password-123
FUNC_INT_PAC_HOST: pac-ctr.localtest.me
KUBECONFIG: ${{github.workspace}}/hack/bin/kubeconfig.yaml
steps:
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
- uses: endersonmenezes/free-disk-space@v3
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_swap: true
rm_cmd: "rmz" # Faster than rm
- name: Install Binaries
run: ./hack/binaries.sh
- name: Allocate Cluster
run: ./hack/cluster.sh
- name: Start Local Registry
run: ./hack/registry.sh
- name: Prepare Images
run: ./hack/images.sh
- name: Install Gitlab
run: ./hack/gitlab.sh
- name: Install Git Server
run: ./hack/git-server.sh
- name: Run Integration Tests
run: make test-integration
- uses: codecov/codecov-action@v5
with:
files: ./coverage.txt
flags: integration
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
# Preserve Cluser Logs
- name: Dump Cluster Logs
if: always()
run: ./hack/dump-logs.sh cluster_log.txt
- name: Archive Cluster Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: cluster-logs-integration
path: ./cluster_log.txt
retention-days: 7
# ---------
# E2E TESTS
# ---------
# Runs Core, Metadata, and Remote
test-e2e:
name: E2E - Core, Metadata, and Remote
needs: precheck
runs-on: ubuntu-latest
env:
FUNC_CLUSTER_RETRIES: 5
FUNC_E2E_CLEAN: false # cluster only used once
FUNC_E2E_VERBOSE: true
steps:
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
- uses: endersonmenezes/free-disk-space@v3
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_swap: true
rm_cmd: "rmz" # Faster than rm
- name: Install Binaries
run: ./hack/binaries.sh
- name: Allocate Cluster
run: ./hack/cluster.sh
- name: Start Local Registry
run: ./hack/registry.sh
- name: Prepare Images
run: ./hack/images.sh
- name: Run Basic E2E Tests (core, metadata, remote)
run: make test-e2e
- uses: codecov/codecov-action@v5
with:
files: ./coverage.txt
flags: e2e
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
# Preserve Cluser Logs
- name: Dump Cluster Logs
if: always()
run: ./hack/dump-logs.sh cluster_log.txt
- name: Archive Cluster Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: cluster-logs-e2e-core
path: ./cluster_log.txt
retention-days: 7
# ----------------
# E2E PODMAN TESTS
# ----------------
test-e2e-podman:
name: E2E - Podman
needs: precheck
runs-on: ubuntu-latest
strategy:
matrix:
os:
- "ubuntu-latest" # x86_64
- "ubuntu-24.04-arm" # ARM64
env:
FUNC_CLUSTER_RETRIES: 5
FUNC_E2E_PODMAN: true
FUNC_E2E_CLEAN: false # cluster only used once
FUNC_E2E_VERBOSE: true
steps:
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
- name: Start Podman
run: sudo apt update && sudo apt install -y podman && podman system service --time=0 &
- name: Install Binaries
run: ./hack/binaries.sh
- name: Allocate Cluster
run: ./hack/cluster.sh
- name: Start Local Registry
run: ./hack/registry.sh
- name: Run E2E Podman Tests
run: make test-e2e-podman
- uses: codecov/codecov-action@v5
with:
files: ./coverage.txt
flags: e2e
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
# Preserve Cluser Logs
- name: Dump Cluster Logs
if: always()
run: ./hack/dump-logs.sh cluster_log.txt
- name: Archive Cluster Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: cluster-logs-${{ matrix.os }}-podman
path: ./cluster_log.txt
retention-days: 7
# -----------------
# E2E RUNTIME TESTS
# -----------------
test-e2e-runtimes:
name: E2E - Runtimes
needs: precheck
strategy:
matrix:
runtime:
- "go"
- "python"
- "node"
- "typescript"
- "rust"
- "quarkus"
- "springboot"
runs-on: ubuntu-latest
env:
FUNC_CLUSTER_RETRIES: 5 # Cluster allocation retries
FUNC_E2E_CLEAN: false # Skip deletes (cluster not reused)
FUNC_E2E_MATRIX: true # Enables the language runtim matrix tests
FUNC_E2E_VERBOSE: true
FUNC_E2E_MATRIX_RUNTIMES: ${{ matrix.runtime }}
steps:
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
- uses: endersonmenezes/free-disk-space@v3
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_swap: true
rm_cmd: "rmz" # Faster than rm
# Install Toolchain Being Tested
- name: Setup Python
if: matrix.runtime == 'python'
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup Node.js
if: matrix.runtime == 'node' || matrix.runtime == 'typescript'
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Java
if: matrix.runtime == 'quarkus' || matrix.runtime == 'springboot'
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
- name: Setup Rust
if: matrix.runtime == 'rust'
uses: actions-rust-lang/setup-rust-toolchain@v1
# Allocate Cluster
- name: Install Binaries
run: ./hack/binaries.sh
- name: Allocate Cluster
run: ./hack/cluster.sh
- name: Start Local Registry
run: ./hack/registry.sh
- name: Prepare Images
run: ./hack/images.sh
- name: Run Test - ${{ matrix.runtime }}
run: make test-e2e-matrix
# Coverage and Logs
- uses: codecov/codecov-action@v5
with:
files: ./coverage.txt
flags: e2e ${{ matrix.runtime }}
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
# Preserve Cluser Logs
- name: Dump Cluster Logs
if: always()
run: ./hack/dump-logs.sh cluster_log.txt
- name: Archive Cluster Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: cluster-logs-${{ matrix.runtime }}
path: ./cluster_log.txt
retention-days: 7
# Build and Publish
build:
name: Build Release
needs:
- test-unit
- test-integration
- test-templates
- test-e2e
- test-e2e-podman
- test-e2e-runtimes
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
- name: Build Platform Binaries
run: make cross-platform
- uses: actions/upload-artifact@v4
with:
name: OSX Binary (AMD)
path: func_darwin_amd64
- uses: actions/upload-artifact@v4
with:
name: OSX Binary (ARM)
path: func_darwin_arm64
- uses: actions/upload-artifact@v4
with:
name: Linux Binary (AMD)
path: func_linux_amd64
- uses: actions/upload-artifact@v4
with:
name: Linux Binary (ARM)
path: func_linux_arm64
- uses: actions/upload-artifact@v4
with:
name: Linux Binary (PPC64LE)
path: func_linux_ppc64le
- uses: actions/upload-artifact@v4
with:
name: Linux Binary (S390X)
path: func_linux_s390x
- uses: actions/upload-artifact@v4
with:
name: Windows Binary
path: func_windows_amd64.exe
publish-utils-image:
name: Publish Utils Image
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
- uses: docker/setup-qemu-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build-images
run: |
for a in amd64 arm64 ppc64le s390x; do
CGO_ENABLED=0 GOARCH="${a}" go build -buildvcs=false -o "func-util-$a" -trimpath -ldflags '-w -s' ./cmd/func-util
done
export SOURCE_DATE_EPOCH=0
docker buildx create --name multiarch --driver docker-container --use
docker buildx build . -f Dockerfile.utils \
--output type=image,rewrite-timestamp=true \
--provenance=false --sbom=false \
--platform=linux/ppc64le,linux/s390x,linux/amd64,linux/arm64 \
--push \
-t "ghcr.io/knative/func-utils:v2" \
--annotation index:org.opencontainers.image.description="Knative Func Utils Image" \
--annotation index:org.opencontainers.image.source="https://github.com/knative/func" \
--annotation index:org.opencontainers.image.vendor="https://github.com/knative/func" \
--annotation index:org.opencontainers.image.url="https://github.com/knative/func/pkgs/container/func-utils" \
--metadata-file build-metadata.json
DIGEST="$(jq -r '."containerimage.digest"' build-metadata.json)"
echo "digest=${DIGEST}" >> "${GITHUB_OUTPUT}"
- name: Attest Build Provenance
uses: actions/attest-build-provenance@v3
with:
subject-name: "ghcr.io/knative/func-utils"
subject-digest: ${{ steps.build-images.outputs.digest }}
push-to-registry: true
publish-image:
name: Publish as Image
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: knative/actions/setup-go@main
- uses: imjasonh/setup-ko@v0.6
- run: ko build --platform=linux/ppc64le,linux/s390x,linux/amd64,linux/arm64 -B ./cmd/func