← Back to issue list

test: unit tests for lifecycle service

View original Github issue

Metadata

Project
debcraft
Number
#57
Type
pull request
State
open
Author
copilot-swe-agent
Labels
—
Created
Updated
Closed
—

Current evaluation

Adds unit tests for the Lifecycle service, but tests a helper (_get_prime_dirs_from_project) deleted by merged #68 and collides with the existing test_lifecycle.py from #139; needs a rewrite, not a rebase. CI: conventional-commits policy, lint and OSV-scanner failing.

Suggested action: close not mergeable

Reason: The diff cannot merge as written: `grep_repo` finds zero matches for `_get_prime_dirs_from_project` on main (deleted by merged #68, now inlined at debcraft/services/lifecycle.py:79-94), so the new test file would fail at import; and `tests/unit/services/test_lifecycle.py` already exists on main with unrelated content from merged #139/#170, so the path is taken. The green test jobs are misleading — the branch merged main on 2025-12-06, before #68 landed 2026-01-05, so its own lifecycle.py still has the helper. The 'policy / Conventional Commits' and 'lint / files' checks are still failing, and the agent's claimed lint fix is unverifiable since it reported snapd firewall blocks. The originating bot cannot act: it stated it cannot rebase and lengau's rebase request went unanswered; a maintainer noted 'The bot that opened this can't answer, so asking here instead.' get_prime_dir/prime_dirs still genuinely lack coverage, but that should be filed as a fresh PR against the property.

Evaluated by: mr-cal-bot

Impact: 12 Quick Win: 1 Complexity: 25 Confidence: 88 Actionability: 15

Issue body

- [x] Have you followed the guidelines for contributing? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] Have you successfully run `make lint && make test`? --- Addresses review feedback from #54 requesting unit test coverage for the `Lifecycle` service class. ### Changes - Add `tests/unit/services/test_lifecycle.py` with tests covering: - `_get_prime_dirs_from_project()` helper function (partition-to-package name mapping) - `Lifecycle.get_prime_dir()` method (including error handling for non-existent packages) - `Lifecycle.prime_dirs` property ### Test Coverage ```python # Tests verify partition prefix stripping works correctly project_info.prime_dirs = { "package/my-package": Path("/work/partitions/package/my-package/prime"), } result = _get_prime_dirs_from_project(project_info) # Returns: {None: default_prime, "my-package": package_prime} ``` Tests also verify: - Non-package partitions are ignored - Empty partition keys are handled - `DebcraftError` is raised for non-existent package lookups <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/canonical/debcraft/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 12
Quick Win: 1
Complexity: 25
Confidence: 88
Actionability: 15
close not mergeable Adds unit tests for the Lifecycle service, but tests a helper (_get_prime_dirs_from_project) deleted by merged #68 and collides with the existing test_lifecycle.py from #139; needs a rewrite, not a rebase. CI: conventional-commits policy, lint and OSV-scanner failing.
stealth/space-bunny-alpha
Impact: 18
Quick Win: 2
Complexity: 30
Confidence: 72
Actionability: 15
close stale Adds unit tests for the Lifecycle service (prime dirs helpers) plus a tools/schema.py formatting fix. Stalled since 2025-12: it imports a helper deleted in #68 and its test file path is taken by merged #139, so it cannot pass on current main.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 10
Complexity: 15
Confidence: 70
Actionability: 40
needs review Adds unit tests for the Lifecycle service class. Addresses review feedback from #54. CI has failing checks (OSV-scanner, conventional commits, lint/files). #54 dependency is merged.
qwen/qwen3.8-27b
Impact: 25
Quick Win: 21
Staleness: 55
Complexity: 15
Confidence: 70
needs review Adds unit tests for the Lifecycle service (prime_dirs, get_prime_dir, partition-to-package mapping) per review feedback on #54. Merged main in Dec 2025 to resolve conflicts; CI mostly green but Conventional Commits and lint checks still failing. No maintainer review yet.
qwen/qwen3.6-35b-a3b
Staleness: 68
Complexity: 15
Confidence: 80
needs review Adds unit tests for the Lifecycle service class, addressing feedback from PR #54. CI passes after fixes. Maintainers indicated it can be merged after #54, but it has been inactive for over seven months with no assigned reviewers.
qwen3.6-35b-a3b-mtp-q6
Staleness: 70
Complexity: 15
Confidence: 85
needs review Adds unit tests for the Lifecycle service class, addressing review feedback from #54. CI passes, conflicts resolved, and maintainers indicated it is ready to land on main.

Update history

Date Change
updated

Related work

  • Related To: canonical/debcraft#139 (confidence 95%)

    Merged PR that created tests/unit/services/test_lifecycle.py with unrelated tests (test_is_native_package, test_build_environment); the target filename is already taken, causing a conflict.

  • Blocked By: canonical/debcraft#68 (confidence 92%)

    Merged 2026-01-05; deleted the helper this PR imports and inlined it into the prime_dirs property, invalidating the test file. Branch predates this merge, hence misleadingly green test CI.

  • Related To: canonical/debcraft#54 (confidence 85%)

    The PR this one was waiting on, per cmatsuoka's 'We can land this directly on main after landing #54'. #54 is long merged and the dependency is satisfied.

Related issues

Issue Project State Summary Similarity
#50 add unit tests for lifecycle.py rockcraft closed Added tests/unit/test_lifecycle.py covering lifecycle.py's pack paths (mainly _run_in_provider) in PR #83, commit 2f5b9c48; maintainer closed the issue pointing to that commit.
76%
#3719 tests: fix lifecycle tests to run on new directory snapcraft merged Merged PR #3719 via commit 314dd7574 to run lifecycle tests in a new directory instead of the current directory.
72%
#2163 tests: add lifecycle ordering tests snapcraft merged Merged in #2163 via commit efebd07e9, adding lifecycle-ordering tests and refactoring lifecycle tests into a dedicated package; Codecov reported 100% diff coverage.
72%