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' } }