|
| 1 | +name: Benchmarks |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + timeout: |
| 7 | + description: Eventually Default Timeout (e.g., 2m) |
| 8 | + required: false |
| 9 | + default: 2m |
| 10 | + namespace: |
| 11 | + description: Fleet namespace |
| 12 | + required: false |
| 13 | + default: fleet-local |
| 14 | + schedule: |
| 15 | + - cron: "0 15 * * *" |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: benchmarks-${{ github.ref }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +env: |
| 25 | + GOARCH: amd64 |
| 26 | + CGO_ENABLED: 0 |
| 27 | + SETUP_K3D_VERSION: "v5.8.3" |
| 28 | + SETUP_K3S_VERSION: "v1.33.1-k3s1" |
| 29 | + # Defaults for both manual and scheduled runs |
| 30 | + BENCH_TIMEOUT: ${{ github.event.inputs.timeout || '2m' }} |
| 31 | + BENCH_NAMESPACE: ${{ github.event.inputs.namespace || 'fleet-local' }} |
| 32 | + |
| 33 | +jobs: |
| 34 | + benchmark: |
| 35 | + name: Run Fleet Benchmarks |
| 36 | + runs-on: ubuntu-latest |
| 37 | + timeout-minutes: 90 |
| 38 | + steps: |
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 41 | + with: |
| 42 | + fetch-depth: 0 |
| 43 | + |
| 44 | + - name: Setup Go |
| 45 | + uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6 |
| 46 | + with: |
| 47 | + go-version-file: "go.mod" |
| 48 | + check-latest: true |
| 49 | + |
| 50 | + # No extra host dependencies required |
| 51 | + |
| 52 | + # Rely on kubectl and helm preinstalled in GitHub runner image |
| 53 | + - name: Build Fleet |
| 54 | + run: | |
| 55 | + ./.github/scripts/build-fleet-binaries.sh |
| 56 | + ./.github/scripts/build-fleet-images.sh |
| 57 | +
|
| 58 | + - name: Check Docker installation |
| 59 | + run: | |
| 60 | + docker --version |
| 61 | + docker info |
| 62 | +
|
| 63 | + - name: Install k3d |
| 64 | + run: curl --silent --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${{ env.SETUP_K3D_VERSION }} bash |
| 65 | + |
| 66 | + - name: Verify k3d installation |
| 67 | + run: | |
| 68 | + k3d version |
| 69 | + which k3d |
| 70 | +
|
| 71 | + - name: Provision k3d Cluster |
| 72 | + run: | |
| 73 | + k3d cluster create upstream --wait \ |
| 74 | + --agents 1 \ |
| 75 | + --image docker.io/rancher/k3s:${{ env.SETUP_K3S_VERSION }} |
| 76 | +
|
| 77 | + - name: Import Images Into k3d |
| 78 | + run: | |
| 79 | + ./.github/scripts/k3d-import-retry.sh rancher/fleet:dev rancher/fleet-agent:dev -c upstream |
| 80 | +
|
| 81 | + - name: Deploy Fleet |
| 82 | + run: | |
| 83 | + ./.github/scripts/deploy-fleet.sh |
| 84 | +
|
| 85 | + - name: Label local cluster for benchmarks |
| 86 | + run: | |
| 87 | + kubectl -n "$BENCH_NAMESPACE" label clusters.fleet.cattle.io local fleet.cattle.io/benchmark=true --overwrite |
| 88 | +
|
| 89 | + - name: Run Benchmarks |
| 90 | + env: |
| 91 | + FLEET_BENCH_TIMEOUT: ${{ env.BENCH_TIMEOUT }} |
| 92 | + FLEET_BENCH_NAMESPACE: ${{ env.BENCH_NAMESPACE }} |
| 93 | + run: | |
| 94 | + go run ./benchmarks/cmd run -d benchmarks/db -t "$FLEET_BENCH_TIMEOUT" -n "$FLEET_BENCH_NAMESPACE" |
| 95 | +
|
| 96 | + - name: Collect benchmark report filename |
| 97 | + id: report |
| 98 | + shell: bash |
| 99 | + run: | |
| 100 | + set -euo pipefail |
| 101 | + file=$(ls -1t b-*.json | head -n1) |
| 102 | + # Replace characters that cause issues in artifact uploads (e.g., ':') |
| 103 | + safe_file="${file//:/-}" |
| 104 | + if [ "$file" != "$safe_file" ]; then |
| 105 | + mv "$file" "$safe_file" |
| 106 | + fi |
| 107 | + echo "report=$safe_file" >> "$GITHUB_OUTPUT" |
| 108 | + echo "Found report: $safe_file" |
| 109 | +
|
| 110 | + - name: Upload benchmark JSON |
| 111 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 112 | + with: |
| 113 | + name: benchmark-report |
| 114 | + path: ${{ steps.report.outputs.report }} |
0 commit comments