← Back to issue list

Fix missing build metadata in reactive charm artifacts

View original Github issue

Metadata

Project
charmcraft
Number
#2502
Type
pull request
State
open
Author
Copilot
Labels
Created
Updated
Closed

Current evaluation

Adds .build.manifest preservation and charmtool_version to manifest.yaml for reactive charm builds. Fixes #872. Inactive 263 days, 0 reviewer approvals, several CI checks failing (snap-tests, Conventional Commits policy).

Suggested action: needs review

Reason: Issue #872 remains open and the fix is not present in main (no matches for charmtool_version or .build.manifest in the codebase), so the PR is still relevant. However, it has sat for ~8.5 months with zero maintainer reviews and has failing CI checks (snap-tests on ubuntu-20/22/24.04, Conventional Commits policy, macos-13 tests) that need a human to triage before it can land.

Impact: 35 Quick Win: 19.25 Staleness: 65 Complexity: 45 Confidence: 72

Issue body

This PR addresses missing valuable build metadata in charm artifacts built with charmcraft's reactive plugin. ## Description When a reactive charm is built with `charm build .` directly, the resulting artifact includes a `.build.manifest` file with commit hashes for each charm layer and installed pip packages from the wheelhouse. Additionally, the manifest should include the charm-tools version used for the build. This PR ensures both features are preserved when building reactive charms through charmcraft. ## Changes Made 1. **`.build.manifest` file preservation**: - Added logic in the reactive plugin to copy `.build.manifest` from the current working directory to the install directory after charm build completes - The file now appears in the final charm artifact, preserving valuable build metadata 2. **`charmtool-version` in `manifest.yaml`**: - Added `charmtool_version` field to the Manifest model - Implemented `_get_charmtool_version()` method in PackageService that detects reactive plugin usage and extracts version info by running `charm version --format json` - The manifest.yaml now includes charm-tools version information when building reactive charms 3. **Code quality improvements**: - Separated exception handling for better debugging and error messages - Fixed trailing whitespace - Fixed ruff formatting issues - Added comprehensive test coverage 4. **Spread test enhancement**: - Modified the reactive spread test to verify that `.build.manifest` file is present in the resulting charm artifact - Added unzip package installation to the test preparation phase ## Testing - ✅ All existing tests pass (37 tests) - ✅ Added new unit test `test_build_copies_build_manifest` to verify `.build.manifest` preservation - ✅ Modified reactive spread test to verify `.build.manifest` in charm artifact using `unzip -l` and `MATCH` assertion - ✅ Linting passes with ruff and prettier - ✅ Security scanning completed with no vulnerabilities found - ✅ Code review feedback addressed --- - [x] I've followed the [contribution guidelines](https://github.com/canonical/charmcraft/blob/main/CONTRIBUTING.md). - [ ] I've signed the [CLA](http://www.ubuntu.com/legal/contributors/). - [x] I've successfully run `make lint && make test`. - [ ] I've added or updated any relevant documentation. - [ ] I've updated the relevant release notes. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>charm artifacts from reactive plugin are missing valuable build metadata</issue_title> > <issue_description>when a reactive charm is built with `charm build .` the resulting artifact has a file in the top level with the title `.build.manifest` > > This file is generated by the `charm` snap and lists the commit hash for each charm layer, installed pip from the wheelhouse > > 1) It seems when i build a reactive charm using the charmcraft reactive plugin, this file is missing from the `.charm` artifact. > > 2) it would also be REALLY nice if the `manifest.yaml` generated would also list the `charmtool-version` used to build the charm. > the plugin can determine this version by running `/snap/bin/charm version --format json` and extracting the output</issue_description> > > <agent_instructions>1. Write a test for this that fails when run from the 4.0.1 tag. > 2. Check whether it succeeds on the `hotfix/3.5` branch. > 3. Check whether it succeeds on the `hotfix/2.7` branch. > 4. Check whether it succeeds on the main branch. > > If the test fails on `hotfix/3.5`, target your fix PR at that branch. If it succeeds on both `hotfix/3.5` and `main` but fails on `hotfix/2.7`, write a fix for that branch. > > If it fails on the 4.0.1 tag but succeeds everywhere else, write a comment that this will be resolved in version 4.1.0 and close the issue. Otherwise, write a fix.</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes canonical/charmcraft#872 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/canonical/charmcraft/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
qwen/qwen3.8-27b
Impact: 35
Quick Win: 19.25
Staleness: 65
Complexity: 45
Confidence: 72
needs review Adds .build.manifest preservation and charmtool_version to manifest.yaml for reactive charm builds. Fixes #872. Inactive 263 days, 0 reviewer approvals, several CI checks failing (snap-tests, Conventional Commits policy).
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 25
Confidence: 60
needs review Preserves .build.manifest and adds charmtool-version to manifest.yaml for reactive charms. Inactive for 225 days with multiple failing CI checks and stalled maintainer review.
qwen3.6-35b-a3b-mtp-q6
Staleness: 75
Complexity: 25
Confidence: 70
needs review Preserves .build.manifest and adds charmtool-version to manifest.yaml for reactive charms. Includes test updates and linting fixes. Currently awaiting maintainer review after 210 days of inactivity.
qwen3.6-35b-a3b-mtp-q6
Staleness: 60
Complexity: 35
Confidence: 85
needs review Fixes missing .build.manifest and charmtool-version in reactive charm artifacts. Incorporates maintainer feedback, passes tests and linting, and is ready for review.
qwen3.6-35b-a3b-mtp-q6
Staleness: 75
Complexity: 40
Confidence: 85
needs review Preserves .build.manifest and charmtool version in reactive charm artifacts. Addresses reviewer feedback, fixes linting, and adds spread tests. Currently awaiting final review and merge after passing CI checks.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: charmcraft#872 (confidence 90%)

    PR body explicitly states 'Fixes canonical/charmcraft#872' and the issue is still open.

  • Related To: charmcraft#1151 (confidence 60%)

    Merged PR that modified reactive plugin file handling (do not create metafiles); context for how the reactive plugin manages output files.

  • Related To: charmcraft#1666 (confidence 55%)

    Merged PR restricting metadata.yaml retention to reactive charms; related reactive plugin file-management work.

Related issues

No related issues found above the similarity threshold.