generated from canonical/starbase
-
Notifications
You must be signed in to change notification settings - Fork 21
feat(Lifecycle): select plugin groups #978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8ac68c2
build(deps): allow dev on Ubuntu Resolute
lengau 66b4784
feat(Lifecycle): select plugin groups
lengau 9a1b84b
docs: add LifecycleService docss
lengau 41c93a1
fix: refine plugin groups docs
lengau 942e772
chore: Merge remote-tracking branch 'origin/main' into work/CRAFT-4993
lengau 04da4b2
fix: reset plugins
lengau 63291e0
fix: description
lengau 5ccb221
fix: better warning
lengau a741c25
build(deps): update distro-support (#979)
lengau 1285239
chore: Merge branch 'main' into work/CRAFT-4993
lengau 3a7bd11
fix: don't error out if the current machine doesn't have a build
lengau d1edc35
fix: docs suggestions
lengau 49c906f
fix: craft-parts release
lengau 3cab5c4
fix: br suggestion
lengau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,5 @@ Services | |
| :maxdepth: 1 | ||
|
|
||
| app | ||
| lifecycle | ||
| project | ||
medubelko marked this conversation as resolved.
Show resolved
Hide resolved
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| .. meta:: | ||
| :description: API reference for the LifecycleService. In a craft application, the LifecycleService handles interactions with Craft Parts. | ||
lengau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .. py:currentmodule:: craft_application.services.lifecycle | ||
|
|
||
| .. _reference-LifecycleService: | ||
|
|
||
| ``LifecycleService`` | ||
| ==================== | ||
|
|
||
| The ``LifecycleService`` handles interactions with :external+craft-parts:doc:`index`. | ||
|
|
||
|
|
||
| API documentation | ||
| ----------------- | ||
|
|
||
| .. autoclass:: LifecycleService | ||
| :member-order: bysource | ||
| :members: | ||
| :private-members: _get_build,_validate_build_plan,_get_build_for,_init_lifecycle_manager | ||
| :undoc-members: | ||
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
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
18 changes: 18 additions & 0 deletions
18
tests/spread/witchcraft/plugin-groups/[email protected]/witchcraft.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| name: merlin-build | ||
| description: | | ||
| A witchcraft cauldron that fails to pack on Ubuntu 22.04 due to the lack of a rust plugin. | ||
| base: [email protected] | ||
| platforms: | ||
| platform-independent: | ||
| build-on: [amd64, arm64, ppc64el, s390x, riscv64] | ||
| build-for: [all] | ||
|
|
||
| version: "0.1" | ||
|
|
||
| parts: | ||
| part1: | ||
| # The rust plugin is only available for 24.04+ in witchcraft | ||
| plugin: rust | ||
| source: . | ||
| override-build: | | ||
| true |
18 changes: 18 additions & 0 deletions
18
tests/spread/witchcraft/plugin-groups/[email protected]/witchcraft.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| name: morgana-build | ||
| description: | | ||
| A witchcraft cauldron that fails to pack on Ubuntu 24.04 because of the lack of a Python plugin. | ||
| base: [email protected] | ||
| platforms: | ||
| platform-independent: | ||
| build-on: [amd64, arm64, ppc64el, s390x, riscv64] | ||
| build-for: [all] | ||
|
|
||
| version: "0.1" | ||
|
|
||
| parts: | ||
| part1: | ||
| # The Python plugin is only available for 22.04 and below in witchcraft. | ||
| plugin: python | ||
| source: . | ||
| override-build: | | ||
| true |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| summary: test setting of plugin groups based on BuildInfo. | ||
|
|
||
| systems: | ||
| - ubuntu-22.04-64 | ||
| - ubuntu-24.04-64 | ||
|
|
||
| execute: | | ||
| . /etc/os-release | ||
|
|
||
| export DISTRO="${ID}@${VERSION_ID}" | ||
|
|
||
| # Check that the valid package for this system packs. | ||
| cd "${DISTRO}" | ||
| witchcraft pack --destructive-mode | ||
| cd - | ||
|
|
||
| # Check that the package referencing a plugin not used on this system does not pack. | ||
| cd "invalid-${DISTRO}" | ||
| witchcraft pack --destructive-mode |& MATCH "Plugin '[a-z]+' in part 'part1' is not registered." | ||
|
|
||
|
|
||
| restore: | | ||
| for path in $(find ./* -maxdepth 0 -type d); do | ||
| cd "${path}" | ||
| witchcraft clean --destructive-mode || true | ||
| rm -f *.witchcraft | ||
| cd .. | ||
| done |
17 changes: 17 additions & 0 deletions
17
tests/spread/witchcraft/plugin-groups/[email protected]/witchcraft.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: merlin-build | ||
| summary: A witchcraft cauldron that packs on Ubuntu 22.04 with the python plugin. | ||
| base: [email protected] | ||
| platforms: | ||
| platform-independent: | ||
| build-on: [amd64, arm64, ppc64el, s390x, riscv64] | ||
| build-for: [all] | ||
|
|
||
| version: "0.1" | ||
|
|
||
| parts: | ||
| part1: | ||
| # The Python plugin is only available for 22.04 and below in witchcraft. | ||
| plugin: python | ||
| source: . | ||
| override-build: | | ||
| true |
17 changes: 17 additions & 0 deletions
17
tests/spread/witchcraft/plugin-groups/[email protected]/witchcraft.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: morgana-build | ||
| summary: A witchcraft cauldron that packs on Ubuntu 22.04 with the rust plugin. | ||
lengau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| base: [email protected] | ||
| platforms: | ||
| platform-independent: | ||
| build-on: [amd64, arm64, ppc64el, s390x, riscv64] | ||
| build-for: [all] | ||
|
|
||
| version: "0.1" | ||
|
|
||
| parts: | ||
| part1: | ||
| # The rust plugin is only available for 24.04+ | ||
| plugin: rust | ||
| source: . | ||
| override-build: | | ||
| true | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # This file is part of craft_application. | ||
| # | ||
| # Copyright 2025 Canonical Ltd. | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify it | ||
| # under the terms of the GNU Lesser General Public License version 3, as | ||
| # published by the Free Software Foundation. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, but WITHOUT | ||
| # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
| # SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
| # See the GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License along | ||
| # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| """Witchcraft lifecycle service.""" | ||
|
|
||
| import craft_platforms | ||
| from craft_application.services import lifecycle | ||
| from craft_parts.plugins import Plugin | ||
| from craft_parts.plugins.plugins import PluginGroup | ||
| from craft_parts.plugins.python_plugin import PythonPlugin | ||
| from craft_parts.plugins.rust_plugin import RustPlugin | ||
| from typing_extensions import override | ||
|
|
||
| MERLIN = PluginGroup.MINIMAL.value | { | ||
| "python": PythonPlugin, | ||
| } | ||
| MORGANA = PluginGroup.MINIMAL.value | {"rust": RustPlugin} | ||
|
|
||
|
|
||
| class Lifecycle(lifecycle.LifecycleService): | ||
| """Lifecycle service for witchcraft.""" | ||
|
|
||
| @override | ||
| @staticmethod | ||
| def get_plugin_group( | ||
| build_info: craft_platforms.BuildInfo, | ||
| ) -> dict[str, type[Plugin]] | None: | ||
| if build_info.build_base.distribution != "ubuntu": | ||
| return MORGANA | ||
| if build_info.build_base <= craft_platforms.DistroBase("ubuntu", "22.04"): | ||
| return MERLIN | ||
| return MORGANA |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.