Skip to content

fix(ci): run the k8s row without the tests package #7525

Backlog

Description

@devops-cli-service

Split from #7369.

uv run devops ci --check --only k8s in a tree of dan-petty/homelab stops with ModuleNotFoundError: No module named 'tests'. Issue #7369 changes only the gate root. This failure is separate and deferred. Acceptance criteria: the k8s row SHALL run in a managed project that has no tests package. A test runs the row from a checkout with no tests directory and asserts that the row starts. The row SHALL report a missing tool or file with a message that names it.

Proposed design

Problem statement

The k8s CI row fails in a managed project because product code imports the top-level tests package. That package exists only in the devops-cli checkout. The row must start in a checkout that has no tests directory and must name a missing tool or file.

Acceptance criteria

Requirement: K8s row starts without tests package

The k8s CI row SHALL start from a managed-project checkout that has no top-level tests package.

Scenario: K8s row starts without tests

  • WHEN a test calls the k8s row with a fake command runner and a temporary project tree that has no tests directory
  • THEN the row starts and raises no ModuleNotFoundError that names tests.

Requirement: K8s row does not import tests

The k8s row and the modules that it imports SHALL NOT import the top-level tests package.

Scenario: Import with tests blocked

  • WHEN a test imports the k8s row module after it sets sys.modules['tests'] to None
  • THEN the import succeeds and raises no ModuleNotFoundError that names tests.

Requirement: Missing executable is named

The k8s row SHALL report a missing required executable with a message that names the executable.

Scenario: Missing executable in k8s row

  • WHEN a test runs the k8s row with a required executable absent from PATH
  • THEN the row exits nonzero and its message contains the name of the missing executable.

Requirement: Missing file is named

The k8s row SHALL report a missing required k8s manifest path with a message that names the path.

Scenario: Missing k8s manifest path

  • WHEN a test runs the k8s row with a required k8s manifest path absent from a temporary project tree
  • THEN the row exits nonzero and its message contains the missing path.

Requirement: Tests directory does not change the row

The k8s row SHALL NOT change its result based on the presence of a tests directory.

Scenario: Same row result with and without tests

  • WHEN a test runs the k8s row in two temporary project trees that are the same except that one has a tests directory
  • THEN both runs produce the same row result and the same messages.

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers this need. The k8s row is devops-cli's own CI code. The change fixes the product import and adds tests. The written cost is about 6,000 tokens and 30 minutes.

Key questions

  • What is the fix boundary for the tests import?: Remove the product import of tests. Keep the k8s row in the installed package. Do not make product code detect a tests directory. (best practice) [sources: AGENTS.md, CONTEXT.md]
    • Chosen: Move shared code into src/devops_cli/ci/. This removes the product import and keeps the code in the installed package.
    • Rejected: Add the top-level tests package to the install. This ships test code and hides the cause.
    • Rejected: Branch on the presence of a tests directory. This makes product code detect tests and is forbidden.
  • Where should shared k8s row code live?: Put shared k8s row code in src/devops_cli/ci/, next to the existing CI code. Import it from the row. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py:1470, src/devops_cli/commands/ci.py]
    • Chosen: src/devops_cli/ci/. It is the existing CI package and is installed with the product.
    • Rejected: src/devops_cli/commands/ci.py. It keeps row logic in the command module and may mix it with command parsing.
    • Rejected: A new top-level package. It adds a package for one helper and does not fix the import cause.
  • How should the k8s row report a missing tool or file?: Use the existing CI check error path. Include the missing item's name in the message. Do not add a second error path. (best practice) [sources: src/devops_cli/commands/ci.py, AGENTS.md]
    • Chosen: Existing CI check error path. It already reports check failures and keeps one message path.
    • Rejected: New exception type. It adds a second error path for the same failure.
    • Rejected: Raw traceback. It does not give a controlled message that names the missing item.
  • How should a test prove that the k8s row runs without tests?: Use a pytest test. Set sys.modules['tests'] to None and use a temporary project tree. Assert that the row starts. (best practice) [sources: docs/TESTING.md]
    • Chosen: Pytest import blocker and temporary tree. It proves the row starts without tests and runs offline.
    • Rejected: Integration test in dan-petty/homelab. It needs an outside checkout and is not offline.
    • Rejected: Source scan for tests imports. It does not prove that the row starts.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/ci
    source/agent
    status/new
    value/medium
    effort/low
    on Nov 28, 2026
  2. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    ContributorAuthor
  3. changed the title [-]fix(ci): run the k8s row in a managed project without the tests package[/-] [+]fix(ci): run the k8s row without the tests package[/+] on Nov 28, 2026
  4. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    ContributorAuthor

    The job shortened the title of this item. The summary had 62 characters, and the limit is 60. The type and the scope stay.

    • Before: fix(ci): run the k8s row in a managed project without the tests package
    • Source of the summary: the background model
  5. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  6. dan-petty commented on Nov 28, 2026

    @dan-petty
    Owner

    Cannot build #7525 as specified on origin/main:

    1. tests/commands/test_ci_gate_rows.py:11-31, tests/ci/test_fail_to_pass.py:2596-2613, and docs/TESTING.md:76 require the k8s gate row to run tests.gate.k8s.main from tests/gate/.
    2. tests/gate/runner.py:28-29 and tests/gate/k8s_checks/{argo_workflows,job_admission_policy,runner}.py import pytest, which is not a runtime dependency in pyproject.toml ([project].dependencies) and is rejected in src/ by deptry.
    3. The 14 modules in tests/gate/k8s_checks/ validate devops-cli-specific k8s/devops/ invariants (REPO_ROOT / "k8s" / "devops"), and tests/gate/k8s_checks/product_tree.py:49-55 fails on any tracked non-Markdown file under k8s/ outside k8s/devops/ (which fails in dan-petty/homelab).

    Re-scope this item if a managed project needs a project-agnostic k8s check in src/devops_cli/ instead of running tests/gate/k8s.py.

  7. dan-petty commented on Dec 1, 2026

    @dan-petty
    Owner

    Live case, 2026-12-01: the build of dan-petty/homelab#583 stopped on this failure (class=plan_defect, 995,075 input tokens). Its plan names uv run devops ci --check --only k8s. #8021 records the planning side.

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/lowpriority/p2-mediumscope/cisource/agentstatus/newtype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions