test(coverage): enforce 75% unit gate and push integration to 60%#1414
Open
sergio-sisternes-epam wants to merge 6 commits into
Open
test(coverage): enforce 75% unit gate and push integration to 60%#1414sergio-sisternes-epam wants to merge 6 commits into
sergio-sisternes-epam wants to merge 6 commits into
Conversation
Add fail_under = 75 to [tool.coverage.report] in pyproject.toml so pytest-cov exits non-zero when unit coverage drops below 75%. Integration coverage remains report-only; a placeholder comment marks where the gate will be added once the baseline is established. Closes #1401 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Baseline measured locally at 44% (518 passed, 222 skipped). Phase 3 target set to 54% (baseline + 10 points). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 57 integration tests covering: - DependencyReference.parse() (27 tests): All shorthand, HTTPS, SSH, SCP, virtual packages, local paths, Azure DevOps, edge cases - DownloadDelegate.resilient_get() (5 tests): HTTP resilience with 429/503 rate-limit retry logic, connection error retry, exhaustion - compile command (3 tests): Minimal project, skills directory, agents directory - outdated command helpers (14 tests): Tag detection, remote tip finding, version stripping, marketplace checks - view command helpers (4 tests): Package path resolution, fallback scan, traversal attack rejection - GitHub downloader utilities (3 tests): Repository cleanup, progress reporting Coverage strategy: Execute all Python code (no mocking), mock only external I/O boundaries (HTTP requests, subprocess). All tests passing with ruff/format. Results: - 57/57 tests passing ✓ - apm_cli.models.dependency.reference: 43% coverage - Tested on real file I/O, CliRunner, request retry logic Fixes #1401 Phase 2 commitment
- 40 comprehensive integration tests covering 8 APM CLI command modules - Tests for: prune, run, config, experimental, update, runtime, policy, and _format_target_label - 44% code coverage across 989 statements in target files (baseline) - Test classes organized by command with helper functions for fixture setup - All tests passing with proper Click CliRunner isolation - Includes error handling and edge case validation tests
Add 34 integration test files covering: - CLI commands (compile, deps, install, view, init, pack, mcp, audit, uninstall) - Adapters (copilot, codex, vscode env helpers) - Dependencies (download strategies, resolver, dep references) - Marketplace (resolver, publisher, builder, yml_editor) - Policy (discovery, checks, registry operations) - Models (validation, detection evidence, lockfile) - Utils (diagnostics, formatters, console) - Integration patterns (mcp_integrator, hook_integrator, skill_integrator) Coverage: 44.12% -> 60.09% (line+branch combined metric) - 2,485 integration tests passing (up from 518) - All 8,733 unit tests still passing - Only pre-existing test_skill_bundle_live.py failures (require network) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ertion - 137 new tests for copilot_app_db, targets, prompt_integrator, experimental - Fix test_outdated_no_lockfile assertion to match updated message - Covers new code from #1405 (copilot-app target) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
danielmeppiel
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Enforce a 75% unit coverage gate in CI and push integration test coverage from 44% to 60% with 36 new test files (~2,760 tests). Unit coverage is report-only no longer — PRs that regress below 75% now fail the
Testsjob. Integration remains report-only with a Phase 3 placeholder.Note
Closes #1401. Phase 2 of the progressive coverage ratchet (#1398). Phase 1 shipped in #1404.
Problem (WHY)
$GITHUB_STEP_SUMMARYtable nobody was required to read.Approach (WHAT)
fail_under = 75to[tool.coverage.report]inpyproject.toml— pytest-cov enforces the gate automatically when--covis passed.ci-integration.ymlrecording the 44% baseline and 54% target — no active gate yet.Implementation (HOW)
pyproject.toml— One line:fail_under = 75under[tool.coverage.report]. pytest-cov reads this and exits non-zero when coverage drops below 75%. The current unit baseline is ~78%, giving 3 points of headroom..github/workflows/ci-integration.yml— Three comment lines recording the integration baseline (44%) and Phase 3 target (54%). The coverage step retainscontinue-on-error: true— no enforcement.tests/integration/test_*_coverage.py(36 files) — Hermetic integration tests that exercise real code paths with minimal mocking (only external I/O: HTTP, subprocess,os.environ,Path.home). Organised in progressive waves covering: CLI commands viaCliRunner, pure-logic functions, adapter helpers, marketplace/policy/registry operations, dep resolution, MCP registry, diagnostics/validation, and the newcopilot-apptarget modules from feat(experimental):copilot-apptarget deploys scheduled prompts to App DB #1405.Diagrams
Legend: How the coverage gate integrates into the existing CI pipeline — the unit job now has a hard gate while integration remains report-only.
flowchart LR subgraph Unit["Unit CI (ci.yml)"] UT[pytest --cov] --> CK{coverage >= 75%?} CK -->|yes| PASS[job passes] CK -->|no| FAIL[job fails]:::new end subgraph Integration["Integration CI (ci-integration.yml)"] S1[shard 1] --> FI[fan-in] S2[shard 2] --> FI S3[shard 3] --> FI S4[shard 4] --> FI FI --> SUM["summary (report-only)"] end classDef new stroke-dasharray: 5 5; class FAIL new;Trade-offs
actual - 3when actual exceeds the gate by 5+ points (78 - 3 = 75 exactly). Kept 75% to give the community margin during refactors — the gate can be ratcheted up in a future Phase.test_skill_bundle_livefailures prove we are not there yet. Phase 3 will activate the gate once those are addressed.test_wave3_*,test_wave7_*) from the iterative development process. Renaming would produce a large churn commit with no coverage benefit — a follow-up housekeeping PR is the right venue.pyproject.tomlhasbranch = true, so the 60% integration figure is combined line+branch coverage (64% statement-only, 50% branch-only). This is stricter but more meaningful.Benefits
ci-integration.ymlfor the next ratchet step.Validation
Lint (clean)
Unit tests (8,815 passed, coverage ~78%)
Integration tests (2,622 passed, coverage 60%)
16 failures in
test_skill_bundle_live.pyare pre-existing network-dependent tests that pass in CI.Scenario Evidence
pyproject.tomlfail_under = 75enforced by pytest-cov (verified locally by settingfail_under = 99and confirming non-zero exit).github/workflows/ci-integration.ymlline 274:continue-on-error: trueapm install,apm audit,apm outdated,apm viewCLI commands work end-to-end on valid project fixturestests/integration/test_commands_deep_coverage.pytests/integration/test_wave5_e2e_coverage.pytests/integration/test_policy_coverage.pytests/integration/test_wave7_policy_registry_coverage.pytests/integration/test_copilot_app_targets_coverage.pyHow to test
uv run --extra dev pytest tests/unit tests/test_console.py -n auto --dist worksteal --cov— verify exit code 0 and coverage >= 75%.fail_under = 99inpyproject.tomland re-run — verify exit code is non-zero (FAIL Required test coverage of 99.0% not reached).uv run --extra dev pytest tests/integration/ -q --cov=apm_cli --override-ini="addopts="— verify 2,600+ tests pass and coverage >= 60%.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com