Repository navigation
Description
Update 2026-11-26 (infra move): devops install-tools and tools_lock are gone (#6555). The shards now copy promtool and kubectl from the dan-petty/devtools image.
Skip the install-tools and tools_lock steps. In the service-test stage, take the two tools from the devtools stage of Dockerfile, not from new pinned images. Left: the stage, the removal of the other install steps and the src/** path filter.
Problem
Each of the 6 shards of service-image-test.yml installs the test tools after it loads the image: uv export, a --target install, a sitecustomize file, 2 devops install-tools calls and a PYTHONPATH (lines 138-160 and 193). Each shard spends 18-36 s on it. That PYTHONPATH layout caused the #4857 break: a child python -I did not find pytest. The path filter leaves out src/ (decision O1 of #4828), so #4857 passed its PR and broke main, and #5926 merged with no in-image run.
Change
- Add a
service-teststage FROMserviceto the Dockerfile:COPY --fromthe uv image (by digest, as today).COPY --from=lock /lock/dev.txt, thenuv pip install --require-hashes --no-depswith a uv cache mount (the runner-deps pattern, Dockerfile:130-132).COPY --linkpromtool fromprom/prometheus:<tag>@sha256and kubectl fromregistry.k8s.io/kubectl:<tag>@sha256.
- service-image-test.yml: the build job builds target
service-test, and the shards load it and run pytest. Delete lines 138-160 (uv export,--targetinstall, sitecustomize, 2 install-tools calls) and thePYTHONPATHat line 193. Make the copy wrapper at line 179 shorter than its 840 s step (for exampletimeout 780), or delete it. - Owner decision of 2026-11-19: the Service Image Tests also run when
src/**,tests/support/**or aconftest.pychanges (the fix(tests): refuse test writes under the real home #4857 break). This replaces decision O1 of perf(ci): run the in-image suite nightly and on image pull requests #4828. Change the path filter of service-image-test.yml; itstools_lockpath goes too. - Update tests/ci/test_fail_to_pass.py:1800 and the spec
ci-service-image-tests. Never publishservice-test. The smoke ofservicekeeps the check that pytest is not in the shipped image.
Renovate. The dockerfile manager updates the prom/prometheus and kubectl digests, and the pep621/uv manager updates the dev dependencies in uv.lock.
Risk. The paths inside vendor images can move (/bin/promtool, /bin/kubectl), so check them with docker run --entrypoint in the PR. The test stage must stay a child of service. The release builds only the published targets. The wider path filter runs the suite on more PRs, but each shard loses its install step.
Proof
- The 6 shards pass, and each shard loses its 18-36 s install step.
- The fix(tests): refuse test writes under the real home #4857 case, a child
python -Ithat must find pytest, passes in the stage. git grep install-tools .github/workflows/service-image-test.ymlgives nothing.- A PR that changes only a file under
src/starts the Service Image Tests.
Depends on: #6404
Alternatives check of 2026-11-19: not-applicable.
Class: test, no search.
Tool: none found.
Proposed design
Problem statement
The Service image test workflow installs test tools after it loads the image in each of its 6 shards. The install takes 18-36 s per shard, and its PYTHONPATH layout caused the #4857 break. The path filter leaves out src/, so a change can pass its pull request and break main. This change adds a service-test stage with the dev dependencies and pinned tools, runs the shards on that stage, and widens the path filter. It keeps service-test out of the release and keeps the smoke check that pytest is not in the shipped image. The issue depends on #6404.
Acceptance criteria
Requirement: Service test stage base
The Dockerfile SHALL define a service-test stage whose base is the service stage.
Scenario: Build the test stage
- WHEN
docker build --target service-test -t devops-cli-service-test:local .runs - THEN the build exits 0 and the image runs
/app/.venv/bin/python -c 'import devops_cli'.
Requirement: Hash-checked dev dependencies
The service-test stage MUST install the dev requirements from the lock stage with uv pip install --require-hashes --no-deps and a uv cache mount.
Scenario: Pytest is available in the test stage
- WHEN
docker run --rm --entrypoint /app/.venv/bin/python devops-cli-service-test:local -c 'import pytest'runs - THEN the command exits 0 and imports pytest from
/app/.venv.
Requirement: Isolated child interpreter finds pytest
The service-test stage MUST make pytest importable in an isolated child interpreter.
Scenario: Child python -I finds pytest
- WHEN
docker run --rm --entrypoint /app/.venv/bin/python devops-cli-service-test:local -I -c 'import pytest'runs - THEN the command exits 0.
Requirement: Pinned test tools
The service-test stage SHALL copy promtool and kubectl from pinned vendor images.
Scenario: Test tools run
- WHEN
docker run --rm --entrypoint sh devops-cli-service-test:local -c 'promtool --version && kubectl version --client'runs - THEN both commands exit 0.
Requirement: Workflow builds test stage
The Service Image Tests workflow MUST build the service-test target and run each shard's pytest suite in that stage.
Scenario: Workflow syntax and target
- WHEN
uv run devops ci --check --only actionlint,zizmorruns andgit grep -n 'target: service-test' .github/workflows/service-image-test.ymlruns - THEN actionlint and zizmor exit 0, and git grep prints the
target: service-testline.
Requirement: Six shards pass on the test stage
The Service Image Tests workflow MUST run the 6 shards on the service-test image.
Scenario: Six shards pass
- WHEN the live check runs the
Service Image Testsworkflow on a pull request - THEN all 6 shards pass.
Requirement: No post-load install
The Service Image Tests workflow MUST NOT install test dependencies after it loads the image, and MUST NOT set PYTHONPATH for the test run.
Scenario: Install step and PYTHONPATH are gone
- WHEN
git grep -nE 'install-tools|PYTHONPATH' .github/workflows/service-image-test.ymlruns - THEN the command exits 1 with no match.
Requirement: Source path filter
The Service Image Tests workflow MUST run when src/**, tests/support/** or a conftest.py changes.
Scenario: Source change starts suite
- WHEN the live check opens a pull request that changes only
src/devops_cli/__init__.py - THEN the
Service Image Testsworkflow shows a run.
Requirement: Tools lock path removed
The Service Image Tests workflow MUST NOT list src/devops_cli/tools_lock/** as a path.
Scenario: Tools lock path is gone
- WHEN
git grep -n 'src/devops_cli/tools_lock' .github/workflows/service-image-test.ymlruns - THEN the command exits 1 with no match.
Requirement: Copy wrapper timeout
The copy wrapper in service-image-test.yml MUST time out before its 840 s step timeout, or MUST be absent.
Scenario: Copy wrapper timeout value
- WHEN
git grep -n 'timeout --kill-after=30' .github/workflows/service-image-test.ymlruns - THEN the command prints a timeout value of 780 or less, or prints no wrapper line.
Requirement: Fail-to-pass test update
The tests/ci/test_fail_to_pass.py test SHALL treat a src/ change as a Service image test change.
Scenario: Fail-to-pass test passes
- WHEN
uv run pytest tests/ci/test_fail_to_pass.py -qruns - THEN the test passes.
Requirement: Spec update
The ci-service-image-tests spec SHALL state the service-test stage and the wider path filter.
Scenario: OpenSpec gate
- WHEN
uv run pytest tests/openspec/test_openspec_gate.py -qruns - THEN the test passes.
Requirement: Release does not publish test stage
The release workflow MUST NOT build or publish the service-test stage.
Scenario: Release target list
- WHEN
git grep -n 'service-test' .github/workflows/release.ymlruns - THEN the command exits 1 with no match.
Requirement: Shipped image has no pytest
The service stage MUST NOT contain pytest.
Scenario: Shipped image smoke check
- WHEN
docker build --target service -t devops-cli-service:local .runs and thendocker run --rm --entrypoint /app/.venv/bin/python devops-cli-service:local -c 'import pytest'runs - THEN the import exits with
ModuleNotFoundErrorfor pytest.
Existing Tool Considered
The alternatives check in the issue body records not-applicable; it names no tool. Docker BuildKit and uv already run in the repository and cover the multi-stage build, cache mount and hash-checked install. The change adds no maintained code, so it has no build cost.
Key questions
- What does the current workflow do after it loads the image?: Each shard runs
uv export, a--targetinstall, a sitecustomize file, twodevops install-toolscalls and setsPYTHONPATH. This takes 18-36 s and is the fix(tests): refuse test writes under the real home #4857 layout. [sources: .github/workflows/service-image-test.yml:138, .github/workflows/service-image-test.yml:193] - Which base should the
service-teststage use?: UseFROM service. The stage stays a child of the shipped stage, so the release does not publish it and the test uses the same base. (best practice) [sources: .github/workflows/service-image-test.yml:1]- Chosen: FROM service. It keeps the test stage a child of the shipped stage and tests the same base.
- Rejected: FROM python:3.14-slim-trixie. It would drift from the shipped image and could hide base defects.
- How should the stage install the dev test dependencies?: Copy
/lock/dev.txtfrom thelockstage and runuv pip install --require-hashes --no-depswith a uv cache mount, as the runner-deps pattern atDockerfile:130does. (best practice) [sources: uv.lock]- Chosen: Lock-stage dev.txt with uv. It uses the hash-checked lock and keeps the install in the image build.
- Rejected: uv export and --target install in the workflow. It is the 18-36 s step and the PYTHONPATH layout that broke fix(tests): refuse test writes under the real home #4857.
- How should
promtoolandkubectlreach the test stage?: Copy them withCOPY --linkfrom pinnedprom/prometheusandregistry.k8s.io/kubectlimages by digest. Check their paths withdocker run --entrypointin the pull request. (best practice) [sources: .github/workflows/service-image-test.yml:138, tests/support/promtool.py:14]- Chosen: Copy from vendor images by digest. The tools stay out of the shipped
servicestage and Renovate updates the digests. - Rejected: Run install-tools after image load. It costs time in each shard and the issue removes it.
- Chosen: Copy from vendor images by digest. The tools stay out of the shipped
- Should the workflow run on
src/**,tests/support/**andconftest.pychanges?: Yes. The owner decision of 2026-11-19 replaces decision O1 of perf(ci): run the in-image suite nightly and on image pull requests #4828. The filter includes those paths and dropssrc/devops_cli/tools_lock/**. (best practice) [sources: .github/workflows/service-image-test.yml:8, tests/ci/test_fail_to_pass.py:1800]- Chosen: Widen the filter. fix(tests): refuse test writes under the real home #4857 passed its pull request and broke main because
src/was left out. - Rejected: Keep the old filter. It repeats the fix(tests): refuse test writes under the real home #4857 break.
- Chosen: Widen the filter. fix(tests): refuse test writes under the real home #4857 passed its pull request and broke main because
- How should the copy wrapper be bounded?: Set
timeout --kill-after=30 780so it fires before the 840 s step timeout. Do not leave 900. (best practice) [sources: .github/workflows/service-image-test.yml:179]- Chosen: Shorten to 780. It fires before the 840 s step and leaves 60 s for cleanup.
- Rejected: Delete the wrapper. It loses the kill-after behavior that the wrapper gives.
- Rejected: Leave 900. The step timeout fires first, so the wrapper never fires.
- Should the
service-teststage be published?: No. The release builds only the published targets. Theservicesmoke keeps the check that pytest is not in the shipped image. (best practice) [sources: .github/workflows/release.yml]- Chosen: Do not publish service-test. It is a test-only stage and would add dev tools to the shipped image.
- Rejected: Publish service-test. It would ship pytest, promtool and kubectl.
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 19, 2026
Both optimize service-image-test.yml shards, but 4642 deduplicates the image build while the candidate adds a new Docker stage and deletes the per-shard install steps.devops-cli-service commentedon Nov 19, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.
devops-cli-service commentedon Nov 22, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.