Repository navigation
Description
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
testsdirectory - THEN the row starts and raises no
ModuleNotFoundErrorthat namestests.
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']toNone - THEN the import succeeds and raises no
ModuleNotFoundErrorthat namestests.
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
testsdirectory - 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
testsimport?: Remove the product import oftests. Keep the k8s row in the installed package. Do not make product code detect atestsdirectory. (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
testspackage to the install. This ships test code and hides the cause. - Rejected: Branch on the presence of a
testsdirectory. This makes product code detect tests and is forbidden.
- Chosen: Move shared code into
- 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.
- Chosen:
- 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. Setsys.modules['tests']toNoneand 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
testsand runs offline. - Rejected: Integration test in dan-petty/homelab. It needs an outside checkout and is not offline.
- Rejected: Source scan for
testsimports. It does not prove that the row starts.
- Chosen: Pytest import blocker and temporary tree. It proves the row starts without
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
devops-cli-service commentedon Nov 28, 2026
Both concern devops ci rows for k8s, but #2164 moves checks from pytest to ci rows while the candidate fixes a ModuleNotFoundError when the tests package is absent.[-]fix(ci): run the k8s row in a managed project without the tests package[/-][+]fix(ci): run the k8s row without the tests package[/+]devops-cli-service commentedon Nov 28, 2026
The job shortened the title of this item. The summary had 62 characters, and the limit is 60. The type and the scope stay.
fix(ci): run the k8s row in a managed project without the tests packagedevops-cli-service commentedon Nov 28, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
dan-petty commentedon Nov 28, 2026
Cannot build #7525 as specified on
origin/main:tests/commands/test_ci_gate_rows.py:11-31,tests/ci/test_fail_to_pass.py:2596-2613, anddocs/TESTING.md:76require thek8sgate row to runtests.gate.k8s.mainfromtests/gate/.tests/gate/runner.py:28-29andtests/gate/k8s_checks/{argo_workflows,job_admission_policy,runner}.pyimportpytest, which is not a runtime dependency inpyproject.toml([project].dependencies) and is rejected insrc/bydeptry.tests/gate/k8s_checks/validatedevops-cli-specifick8s/devops/invariants (REPO_ROOT / "k8s" / "devops"), andtests/gate/k8s_checks/product_tree.py:49-55fails on any tracked non-Markdown file underk8s/outsidek8s/devops/(which fails indan-petty/homelab).Re-scope this item if a managed project needs a project-agnostic
k8scheck insrc/devops_cli/instead of runningtests/gate/k8s.py.dan-petty commentedon Dec 1, 2026
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 namesuv run devops ci --check --only k8s. #8021 records the planning side.