69 lines
2.6 KiB
YAML
69 lines
2.6 KiB
YAML
apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: smoke-runner
|
|
namespace: dev
|
|
labels:
|
|
app.kubernetes.io/name: smoke-runner
|
|
app.kubernetes.io/part-of: bid-mvp-factory
|
|
spec:
|
|
schedule: "*/15 * * * *"
|
|
timeZone: Asia/Tokyo
|
|
concurrencyPolicy: Forbid
|
|
successfulJobsHistoryLimit: 2
|
|
failedJobsHistoryLimit: 3
|
|
jobTemplate:
|
|
spec:
|
|
template:
|
|
spec:
|
|
restartPolicy: OnFailure
|
|
containers:
|
|
- name: smoke-runner
|
|
image: ghcr.io/astral-sh/uv:python3.11-alpine
|
|
imagePullPolicy: IfNotPresent
|
|
env:
|
|
- name: GIT_BRANCH
|
|
value: main
|
|
- name: SMOKE_TARGETS
|
|
value: scripts/smoke/targets.local-k3s.json
|
|
- name: ARGOCD_SERVER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: deploy-promoter-secret
|
|
key: argocd_server
|
|
- name: ARGOCD_TOKEN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: deploy-promoter-secret
|
|
key: argocd_token
|
|
- name: GITHUB_TOKEN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: deploy-promoter-secret
|
|
key: github_token
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
set -euo pipefail
|
|
apk add --no-cache git openssh-client curl py3-pip
|
|
pip3 install --no-cache-dir pyyaml jsonschema
|
|
rm -rf /work/repo
|
|
git clone --depth=1 "https://x-access-token:${GITHUB_TOKEN}@github.com/BrunoGaoSZ/ljwx-deploy.git" /work/repo
|
|
cd /work/repo
|
|
set +e
|
|
uvx --with pyyaml --with jsonschema python scripts/smoke/run_smoke.py --targets "${SMOKE_TARGETS}"
|
|
SMOKE_EXIT=$?
|
|
set -e
|
|
uvx --with pyyaml --with jsonschema python scripts/evidence/collect.py --out evidence/index.json --summary evidence/summary/latest.md
|
|
if git diff --quiet; then
|
|
echo "No smoke updates"
|
|
exit "${SMOKE_EXIT}"
|
|
fi
|
|
git config user.name "smoke-runner[bot]"
|
|
git config user.email "smoke-runner[bot]@users.noreply.github.com"
|
|
git add evidence/records evidence/index.json evidence/summary/latest.md
|
|
git commit -m "chore(smoke): update smoke evidence [skip ci]"
|
|
git push origin "HEAD:${GIT_BRANCH}"
|
|
exit "${SMOKE_EXIT}"
|