From 92fae0a1c4666e39351abbe349550ccf2c782ff8 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Fri, 7 Aug 2026 04:29:04 -0300 Subject: [PATCH] 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 --- Jenkinsfile | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ec2cf2b..501784e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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' } }