Work/charmcraft 710 prototype e2e - #2772
Draft
lengau wants to merge 6 commits into
Draft
Conversation
…REPO When CHARMCRAFT_EXPERIMENTAL_MONOREPO is set to a truthy value, charmcraft passes use_git_build_root=True to craft-application, which mounts the git repository root as the build root. This enables charms in a monorepo to access shared local dependencies (e.g. ../common) during pack. CHARMCRAFT-710 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a charm uses a source-subdir (as happens with root_dir/monorepo builds), the charm files live at part_build_subdir not part_build_dir. Fix get_charm_copy_commands in all three charm plugins (poetry, python, uv) to use part_build_subdir so that src/, lib/ etc. are found correctly. CHARMCRAFT-710 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move microk8s setup out of the charms/ suite-level prepare and into k8s-operator/task.yaml (the only test that uses a k8s Juju controller) so monorepo tests don't require microk8s. - Add tests/spread/charms/monorepo/ with four variants covering mysql-operators and mysql-router-operators × machines + kubernetes. - Add tests/spread/commands/git-build-root/ as a lightweight unit-level smoke test for the feature flag. CHARMCRAFT-710 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ype branches Temporarily pin both dependencies to the work/CHARMCRAFT-710-prototype branches while the upstream PRs are in review. CHARMCRAFT-710 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update craft-parts and craft-application pins to the e2e branch, which propagates root_dir end-to-end without mutating parts data. CHARMCRAFT-710 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prototypes “monorepo”/git-root build support by wiring a new experimental env var into the Charmcraft application, adjusting plugin copy behavior to use the part build subdirectory, and adding spread E2E coverage for packing charms from monorepos.
Changes:
- Add
CHARMCRAFT_EXPERIMENTAL_MONOREPOand passuse_git_build_rootintocraft_application.AppMetadata. - Update Python/Poetry/uv plugins to copy charm
src/andlib/frompart_build_subdirinstead ofpart_build_dir. - Add spread tasks to validate monorepo packing, and move microk8s bootstrap/setup into the k8s-operator task.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Switches several craft-* dependencies to git sources for this prototype lock state. |
pyproject.toml |
Adds tool.uv.sources overrides pointing craft-* deps at git branches. |
charmcraft/application/main.py |
Enables git-root build behavior via CHARMCRAFT_EXPERIMENTAL_MONOREPO. |
charmcraft/const.py |
Introduces EXPERIMENTAL_MONOREPO_ENV_VAR. |
charmcraft/parts/plugins/_uv.py |
Copies charm sources from build subdir to support monorepo layouts. |
charmcraft/parts/plugins/_python.py |
Same copy-path adjustment for the Python plugin. |
charmcraft/parts/plugins/_poetry.py |
Same copy-path adjustment for the Poetry plugin. |
tests/spread/commands/git-build-root/task.yaml |
New spread test intended to validate git-root/monorepo packing. |
tests/spread/charms/monorepo/task.yaml |
New spread test that packs multiple real monorepo charms with the feature enabled. |
tests/spread/charms/k8s-operator/task.yaml |
Adds per-task microk8s setup/juju bootstrap. |
spread.yaml |
Removes suite-level microk8s setup from the charms suite prepare step. |
Comment on lines
+51
to
+53
| arch=$(dpkg --print-architecture) | ||
| artifact=/tmp/monorepo/charm/monorepo-test-charm_${arch}.charm | ||
| test -f "${artifact}" |
Comment on lines
+20
to
+22
| git clone --depth=1 https://github.com/canonical/"${REPO}".git /tmp/"${REPO}" | ||
| python3 - << 'EOF' | ||
| import os, yaml, pathlib |
| d = yaml.safe_load(p.read_text()) | ||
| d["parts"].pop("files", None) | ||
| d["parts"].get("charm-poetry", {}).pop("override-build", None) | ||
| p.write_text(yaml.dump(d)) |
Comment on lines
+34
to
+36
| snap install microk8s --channel=1.28-strict/stable | ||
| microk8s enable hostpath-storage | ||
| microk8s enable dns |
Comment on lines
507
to
+514
| [tool.uv.sources] | ||
| craft-application = { git = "https://github.com/canonical/craft-application.git", branch = "work/CHARMCRAFT-710-prototype-e2e" } | ||
| craft-cli = { git = "https://github.com/canonical/craft-cli.git", branch = "main" } | ||
| craft-grammar = { git = "https://github.com/canonical/craft-grammar.git", branch = "main" } | ||
| craft-parts = { git = "https://github.com/canonical/craft-parts.git", branch = "work/CHARMCRAFT-710-prototype-e2e" } | ||
| craft-providers = { git = "https://github.com/canonical/craft-providers.git", branch = "main" } | ||
| craft-platforms = { git = "https://github.com/canonical/craft-platforms.git", branch = "main" } | ||
| craft-store = { git = "https://github.com/canonical/craft-store.git", branch = "main" } |
- Install python3-yaml explicitly rather than relying on it being present - Use yaml.safe_dump instead of yaml.dump - Add microk8s status --wait-ready before enabling addons Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Describe your changes.
make lint && make test.