tests: add reproducer for pack retaining deleted files between builds (#710)#2669
tests: add reproducer for pack retaining deleted files between builds (#710)#2669
Conversation
Add a failing test that demonstrates that craft-parts' LifecycleManager does not remove stale files from the prime/stage directories on incremental rebuilds. When a source file is deleted and the charm is repacked, the deleted file is still included in the .charm artifact. Upstream bug: canonical/craft-parts#851 Closes #710 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Type checking with Command output |
Workaround for canonical/craft-parts#851. craft-parts' LocalSource.update() copies modified/new files from source into the part src directory but does not remove files that have been deleted from the source. This causes stale files to persist in prime and be included in repacked .charm archives. Add PartsLifecycle._clean_stale_parts() which, before each lifecycle run, compares each part's internal src directory against the current source directory. If any file in the internal src copy is no longer present in the source, the part is cleaned from the pull step so that the full pull runs again and stale files are removed from stage and prime. Update the reproducer test to use PartsLifecycle (with the workaround) rather than craft_parts.LifecycleManager directly. Fixes #710 Agent-Logs-Url: https://github.com/canonical/charmcraft/sessions/497fa1cd-0a44-411c-8a83-4f5d26a22fff Co-authored-by: lengau <4305943+lengau@users.noreply.github.com>
Done in commit 4b3411b. The fix adds The reproducer test is updated to use |
|
Type checking with Command output |
Summary
Adds a failing unit test that reproduces #710:
charmcraft packincludes 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 withreason='already ran'. The deleted file persists inprime/and is included in the repacked.charmarchive.Upstream bug: canonical/craft-parts#851
Workaround: run
charmcraft clean(orcharmcraft clean <part-name>) between packs.Reproducer
The test fails with:
Closes #710