-
Notifications
You must be signed in to change notification settings - Fork 273
132 lines (114 loc) · 3.88 KB
/
Copy pathbenchmark.yml
File metadata and controls
132 lines (114 loc) · 3.88 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
name: Benchmarks
on:
workflow_dispatch:
inputs:
timeout:
description: Eventually Default Timeout (e.g., 2m)
required: false
default: 2m
namespace:
description: Fleet namespace
required: false
default: fleet-local
schedule:
# Runs everyday at 05:15 UTC
- cron: "15 5 * * *"
permissions:
contents: read
concurrency:
group: benchmarks-${{ github.ref }}
cancel-in-progress: true
env:
GOARCH: amd64
CGO_ENABLED: 0
SETUP_K3S_VERSION: "v1.36.0-k3s1"
# Defaults for both manual and scheduled runs
BENCH_TIMEOUT: ${{ github.event.inputs.timeout || '2m' }}
BENCH_NAMESPACE: ${{ github.event.inputs.namespace || 'fleet-local' }}
jobs:
benchmark:
name: Run Fleet Benchmarks
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: "go.mod"
# No extra host dependencies required
# Rely on kubectl and helm preinstalled in GitHub runner image
- name: Build Fleet
run: |
./.github/scripts/build-fleet-binaries.sh
./.github/scripts/build-fleet-images.sh
- name: Check Docker installation
run: |
docker --version
docker info
- name: Cache k3d CLI
id: cache-k3d
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.local/bin/k3d
key: ${{ runner.os }}-k3d-${{ hashFiles('.github/scripts/install-k3d.sh') }}
restore-keys: |
${{ runner.os }}-k3d-
- name: Install k3d
env:
CACHE_HIT: ${{ steps.cache-k3d.outputs.cache-hit }}
run: |
if [ "$CACHE_HIT" != "true" ]; then
./.github/scripts/install-k3d.sh
else
echo "Using cached k3d"
chmod +x ~/.local/bin/k3d
fi
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Verify k3d installation
run: |
k3d version
which k3d
- name: Provision k3d Cluster
run: |
k3d cluster create upstream --wait \
--agents 1 \
--image docker.io/rancher/k3s:${{ env.SETUP_K3S_VERSION }} \
--k3s-arg "--cluster-init@server:0"
- name: Import Images Into k3d
run: |
./.github/scripts/k3d-import-retry.sh rancher/fleet:dev rancher/fleet-agent:dev -c upstream
- name: Deploy Fleet
run: |
./.github/scripts/deploy-fleet.sh
- name: Label local cluster for benchmarks
run: |
kubectl -n "$BENCH_NAMESPACE" label clusters.fleet.cattle.io local fleet.cattle.io/benchmark=true --overwrite
- name: Run Benchmarks
env:
FLEET_BENCH_TIMEOUT: ${{ env.BENCH_TIMEOUT }}
FLEET_BENCH_NAMESPACE: ${{ env.BENCH_NAMESPACE }}
run: |
go run ./benchmarks/cmd run -d benchmarks/db -t "$FLEET_BENCH_TIMEOUT" -n "$FLEET_BENCH_NAMESPACE"
- name: Collect benchmark report filename
id: report
shell: bash
run: |
set -euo pipefail
file=$(ls -1t b-*.json | head -n1)
# Replace characters that cause issues in artifact uploads (e.g., ':')
safe_file="${file//:/-}"
if [ "$file" != "$safe_file" ]; then
mv "$file" "$safe_file"
fi
echo "report=$safe_file" >> "$GITHUB_OUTPUT"
echo "Found report: $safe_file"
- name: Upload benchmark JSON
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-report
path: ${{ steps.report.outputs.report }}