← Back to issue list

tests: add reproducer for pack retaining deleted files between builds (#710)

View original Github issue

Metadata

Project
charmcraft
Number
#2669
Type
pull request
State
open
Author
lengau
Labels
Created
Updated
Closed

Current evaluation

Adds failing reproducer test for #710 plus a fix (PartsLifecycle._clean_stale_parts) that cleans stale pulled files before each lifecycle run; test now passes. Awaiting review; several CI checks failing.

Suggested action: needs review

Reason: PR is pending with 0 reviewers and has concrete failing CI: snap-tests on ubuntu-18.04 through ubuntu-26.04, snap-store-tests, and the Conventional Commits title check, which need to be addressed before landing. The fix is a local workaround for still-open upstream craft-parts#851, so a maintainer should weigh whether to merge now or wait for the upstream fix.

Impact: 50 Quick Win: 30.0 Staleness: 50 Complexity: 40 Confidence: 75

Issue body

## Summary Adds a failing unit test that reproduces #710: `charmcraft pack` includes files that were deleted from the working directory since the last pack, because craft-parts does not clean stale files from the stage/prime directories on incremental rebuilds. ## Bug When `LifecycleManager.run()` is called a second time after a source file has been deleted, craft-parts skips all lifecycle steps with `reason='already ran'`. The deleted file persists in `prime/` and is included in the repacked `.charm` archive. Upstream bug: https://github.com/canonical/craft-parts/issues/851 Workaround: run `charmcraft clean` (or `charmcraft clean <part-name>`) between packs. ## Reproducer ``` uv run python -m pytest tests/unit/parts/test_lifecycle.py::test_stale_files_removed_from_prime_after_repack -v ``` The test fails with: ``` AssertionError: Stale file from deleted source is still present in prime directory after repack ``` Closes #710

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 50
Quick Win: 30.0
Staleness: 50
Complexity: 40
Confidence: 75
needs review Adds failing reproducer test for #710 plus a fix (PartsLifecycle._clean_stale_parts) that cleans stale pulled files before each lifecycle run; test now passes. Awaiting review; several CI checks failing.
qwen3.6-35b-a3b-mtp-q6
Staleness: 55
Complexity: 20
Confidence: 85
needs review Adds a failing test reproducing a bug where charmcraft pack retains deleted files between builds. Author requested an automated fix via Copilot, which was applied. PR awaits maintainer review and CI fixes.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 40
Confidence: 85
needs review Adds a reproducer test and automated fix for a bug where charmcraft pack retains deleted files between builds. Currently awaiting maintainer review.
qwen3.6-35b-a3b-mtp-q6
Staleness: 65
Complexity: 40
Confidence: 45
needs review Adds a failing test reproducing a bug where charmcraft pack retains deleted files. A maintainer requested a fix via Copilot, which added a workaround commit, but type checking fails and the PR has been inactive for 73 days.
qwen3.6-35b-a3b-mtp-q6
Staleness: 40
Complexity: 50
Confidence: 85
needs review Fixes charmcraft pack retaining deleted files between builds. Adds a reproducer test and implements PartsLifecycle._clean_stale_parts() to remove missing source files before lifecycle runs. Test passes. Type checks report non-blocking errors. Awaiting review.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/charmcraft#710 (confidence 90%)

    PR body says 'Closes #710'; issue is still open and no fix found in main branch.

  • Blocked By: canonical/craft-parts#851 (confidence 80%)

    Upstream bug cited in the PR ('Removed files from local sources remain in the part'); still open, so the in-tree _clean_stale_parts workaround may be superseded by an upstream fix.

Related issues

No related issues found above the similarity threshold.