Skip to content

test(ci): run the Service image suite in a service-test stage #6408

Open

Description

@dan-petty

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

  1. Add a service-test stage FROM service to the Dockerfile:
    • COPY --from the uv image (by digest, as today).
    • COPY --from=lock /lock/dev.txt, then uv pip install --require-hashes --no-deps with a uv cache mount (the runner-deps pattern, Dockerfile:130-132).
    • COPY --link promtool from prom/prometheus:<tag>@sha256 and kubectl from registry.k8s.io/kubectl:<tag>@sha256.
  2. 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, --target install, sitecustomize, 2 install-tools calls) and the PYTHONPATH at line 193. Make the copy wrapper at line 179 shorter than its 840 s step (for example timeout 780), or delete it.
  3. Owner decision of 2026-11-19: the Service Image Tests also run when src/**, tests/support/** or a conftest.py changes (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; its tools_lock path goes too.
  4. Update tests/ci/test_fail_to_pass.py:1800 and the spec ci-service-image-tests. Never publish service-test. The smoke of service keeps 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 -I that must find pytest, passes in the stage.
  • git grep install-tools .github/workflows/service-image-test.yml gives 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,zizmor runs and git grep -n 'target: service-test' .github/workflows/service-image-test.yml runs
  • THEN actionlint and zizmor exit 0, and git grep prints the target: service-test line.

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 Tests workflow 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.yml runs
  • 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 Tests workflow 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.yml runs
  • 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.yml runs
  • 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 -q runs
  • 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 -q runs
  • 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.yml runs
  • 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 then docker run --rm --entrypoint /app/.venv/bin/python devops-cli-service:local -c 'import pytest' runs
  • THEN the import exits with ModuleNotFoundError for 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 --target install, a sitecustomize file, two devops install-tools calls and sets PYTHONPATH. 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-test stage use?: Use FROM 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.txt from the lock stage and run uv pip install --require-hashes --no-deps with a uv cache mount, as the runner-deps pattern at Dockerfile:130 does. (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 promtool and kubectl reach the test stage?: Copy them with COPY --link from pinned prom/prometheus and registry.k8s.io/kubectl images by digest. Check their paths with docker run --entrypoint in 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 service stage and Renovate updates the digests.
    • Rejected: Run install-tools after image load. It costs time in each shard and the issue removes it.
  • Should the workflow run on src/**, tests/support/** and conftest.py changes?: 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 drops src/devops_cli/tools_lock/**. (best practice) [sources: .github/workflows/service-image-test.yml:8, tests/ci/test_fail_to_pass.py:1800]
  • How should the copy wrapper be bounded?: Set timeout --kill-after=30 780 so 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-test stage be published?: No. The release builds only the published targets. The service smoke 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.

Dependencies

#6404

Activity

  1. added
    type/test
    scope/ci
    source/agent
    on Nov 19, 2026
  2. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor
  3. added
    status/new
    value/medium
    effort/medium
    priority/p2-medium
    on Nov 19, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    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.

  5. added
    status/ready
    and removed
    status/new
    on Nov 22, 2026
  6. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/cisource/agentstatus/readytype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions