ci: reuse the agent and shallow-clone so the gate is not all overhead

The tests run in 0.62 seconds; the build took 191. Agent scheduling and image
pull were ~54s, a full clone of a five-commit repo ~25s, and pip install
pytest ~55s. None of that is the thing being demonstrated.

A fixed label plus idleMinutes keeps the pod alive between builds. The default
inline template mints a random POD_LABEL per build, so a fresh pod was
guaranteed every time and the pip cache in the workspace volume was always
cold. With reuse, a second run skips scheduling, skips the image pull, and
finds pytest already cached.

The first run after an idle period still pays full price, so a throwaway run
before a demo is worth doing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Brad Stein 2026-08-07 04:29:04 -03:00
parent 6c4428c893
commit 92fae0a1c4

43
Jenkinsfile vendored
View File

@ -1,5 +1,26 @@
// Test gate for the Hermes code-repair demo.
podTemplate(cloud: 'kubernetes', yaml: """
//
// Tuned for a demo, where the wait between pushing a defect and seeing the
// build go red is watched by people. The tests themselves run in under a
// second; everything else was overhead:
//
// agent pod scheduling + image pull ~54s
// full clone of a five-commit repo ~25s
// pip install pytest ~55s
// the actual tests ~0.6s
//
// A named template with idleMinutes keeps the pod alive between builds, so a
// second run reuses it: no scheduling, no image pull, and the pip cache in the
// workspace volume is already warm. The first run after an idle period still
// pays the full cost, which is why a throwaway run before a demo is worth it.
podTemplate(
cloud: 'kubernetes',
// A fixed label is what makes reuse possible at all. The default inline
// template mints a random POD_LABEL per build, so every build necessarily
// got a fresh pod.
label: 'hermes-code-demo-agent',
idleMinutes: 60,
yaml: """
apiVersion: v1
kind: Pod
spec:
@ -27,16 +48,28 @@ spec:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
cpu: 1000m
memory: 512Mi
""") {
node(POD_LABEL) {
node('hermes-code-demo-agent') {
container('python') {
stage('Checkout') {
checkout scm
// Depth 1 and no tags: the build only ever needs the commit under
// test, and fetching five commits of history to run one test file is
// time spent on nothing anyone will look at.
checkout([
$class: 'GitSCM',
branches: scm.branches,
userRemoteConfigs: scm.userRemoteConfigs,
extensions: [
[$class: 'CloneOption', shallow: true, depth: 1, noTags: true, timeout: 5],
],
])
}
stage('tests') {
sh 'pip install --quiet pytest'
// Idempotent and near-instant once the pod's pip cache is warm; the
// cost is only paid on a cold agent.
sh 'pip install --quiet --disable-pip-version-check pytest'
sh 'python -m pytest -v --junitxml=build/junit.xml'
}
}