diff --git a/hack/github-actions-runner/cache-warming-cronjob.yaml b/hack/github-actions-runner/cache-warming-cronjob.yaml new file mode 100644 index 00000000000..e6cbd03af7c --- /dev/null +++ b/hack/github-actions-runner/cache-warming-cronjob.yaml @@ -0,0 +1,78 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: go-cache-warmer + namespace: arc-runners + labels: + app.kubernetes.io/component: cache-warmer + app.kubernetes.io/part-of: arc-runner-set +spec: + schedule: "0 2 * * *" + concurrencyPolicy: Forbid + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 + jobTemplate: + spec: + activeDeadlineSeconds: 3600 + backoffLimit: 1 + template: + spec: + restartPolicy: Never + securityContext: + runAsNonRoot: true + seccompProfile: + type: RuntimeDefault + containers: + - name: cache-warmer + image: quay.io/redhat-user-workloads/crt-redhat-acm-tenant/hypershift-gh-actions-runner:latest + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + command: + - /bin/bash + - -c + - | + set -euo pipefail + + echo "=== Cloning openshift/hypershift main branch ===" + git clone --depth 1 --branch main https://github.com/openshift/hypershift.git /tmp/hypershift + cd /tmp/hypershift + + echo "=== Compiling all packages ===" + go build ./... + + echo "=== Compiling all test binaries ===" + go test -c -o /dev/null ./... 2>/dev/null || true + + echo "=== Cleaning stale cache entries (older than 7 days) ===" + find /cache/go-build -type f -mtime +7 -delete + find /cache/go-build -mindepth 1 -type d -empty -delete + + echo "=== Syncing build cache to PV ===" + cp -a "${GOCACHE}"/* /cache/go-build/ + + echo "=== Cache warming complete ===" + du -sh /cache/go-build/ + env: + - name: GOCACHE + value: /tmp/go-build-cache + - name: GOMODCACHE + value: /tmp/go-mod-cache + - name: HOME + value: /tmp + resources: + requests: + cpu: "4" + memory: "16Gi" + limits: + cpu: "4" + memory: "16Gi" + volumeMounts: + - name: go-cache + mountPath: /cache/go-build + volumes: + - name: go-cache + persistentVolumeClaim: + claimName: go-cache-pvc