-
Notifications
You must be signed in to change notification settings - Fork 8
feat: allow devel in multi-base charm builds
#217
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
Open
Copilot
wants to merge
10
commits into
main
Choose a base branch
from
copilot/allow-devel-in-multi-base-builds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+160
−18
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
847de3a
Initial plan
Copilot 79e84f5
feat: allow devel in multi-base charm builds
Copilot 1101c6a
fix: also handle bare 'devel' in fuzz test filter
Copilot 3f7b268
fix: reject mixed devel+stable bases in build-on
Copilot 76796f1
fix: correct Hypothesis filter for multi-base fuzz test
Copilot 542fbb6
fix: resolve linting issues in _build.py and test_build.py
Copilot f5d2083
fix: reject devel+base-less mixing in build-on entries
Copilot 5899fbd
Merge branch 'main' into copilot/allow-devel-in-multi-base-builds
lengau 930bcc9
Merge branch 'main' into copilot/allow-devel-in-multi-base-builds
lengau 7b949cd
Merge branch 'main' into copilot/allow-devel-in-multi-base-builds
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -528,6 +528,63 @@ def test_build_plans_success( | |
| ], | ||
| id="multi-base-long-multi-build-on", | ||
| ), | ||
| pytest.param( | ||
| None, | ||
| None, | ||
| { | ||
| "noble": { | ||
| "build-on": ["devel:amd64"], | ||
| "build-for": ["ubuntu@24.04:amd64"], | ||
| }, | ||
| }, | ||
| [ | ||
| craft_platforms.BuildInfo( | ||
| "noble", | ||
| craft_platforms.DebianArchitecture("amd64"), | ||
| craft_platforms.DebianArchitecture("amd64"), | ||
| craft_platforms.DistroBase("ubuntu", "devel"), | ||
| ), | ||
| ], | ||
| id="multi-base-devel-build-on", | ||
| ), | ||
| pytest.param( | ||
| None, | ||
| None, | ||
| { | ||
| "noble": { | ||
| "build-on": ["ubuntu@devel:amd64"], | ||
| "build-for": ["ubuntu@24.04:amd64"], | ||
| }, | ||
| }, | ||
| [ | ||
| craft_platforms.BuildInfo( | ||
| "noble", | ||
| craft_platforms.DebianArchitecture("amd64"), | ||
| craft_platforms.DebianArchitecture("amd64"), | ||
| craft_platforms.DistroBase("ubuntu", "devel"), | ||
| ), | ||
| ], | ||
| id="multi-base-ubuntu-at-devel-build-on", | ||
| ), | ||
| pytest.param( | ||
| None, | ||
| None, | ||
| { | ||
| "noble": { | ||
| "build-on": ["devel:amd64"], | ||
| "build-for": ["ubuntu@24.04:all"], | ||
| }, | ||
| }, | ||
| [ | ||
| craft_platforms.BuildInfo( | ||
| "noble", | ||
| craft_platforms.DebianArchitecture("amd64"), | ||
| "all", | ||
| craft_platforms.DistroBase("ubuntu", "devel"), | ||
| ), | ||
| ], | ||
| id="multi-base-devel-build-on-all", | ||
| ), | ||
| ], | ||
| ) | ||
| def test_build_plans_in_depth(base, build_base, platforms, expected): | ||
|
|
@@ -687,6 +744,32 @@ def test_build_plans_in_depth(base, build_base, platforms, expected): | |
| "Use the same base for all 'build-on' and 'build-for' entries for the platform.", | ||
| id="platform-base-with-incompatible-build-on", | ||
| ), | ||
| pytest.param( | ||
| None, | ||
| None, | ||
| { | ||
| "noble": { | ||
| "build-on": ["devel:amd64", "ubuntu@24.04:arm64"], | ||
| "build-for": ["ubuntu@24.04:amd64"], | ||
| }, | ||
| }, | ||
| r"Platform 'noble' has mismatched bases in the 'build-on' and 'build-for' entries.", | ||
| "Use the same base for all 'build-on' and 'build-for' entries for the platform.", | ||
| id="devel-and-stable-mixed-build-on", | ||
| ), | ||
| pytest.param( | ||
| "ubuntu@24.04", | ||
| None, | ||
| { | ||
| "my-platform": { | ||
| "build-on": ["amd64", "devel:arm64"], | ||
| "build-for": ["amd64"], | ||
| }, | ||
| }, | ||
| r"Platform 'my-platform' has mismatched bases in the 'build-on' and 'build-for' entries.", | ||
| "Use the same base for all 'build-on' and 'build-for' entries for the platform.", | ||
| id="devel-and-base-less-mixed-build-on", | ||
| ), | ||
| ], | ||
| ) | ||
| def test_build_plans_bad_base(base, build_base, platforms, error_msg, error_res): | ||
|
|
@@ -740,6 +823,43 @@ def _is_valid_platform(platforms): | |
| return True | ||
|
|
||
|
|
||
| def _is_valid_multi_base_platform_dict(p): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels complex enough that it deserves its own test
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, this is a pretty complex helper function for a test. |
||
| """Return True if the platform dict is consistent for multi-base builds. | ||
|
|
||
| A valid multi-base platform dict must satisfy: | ||
| - All ``build-on`` entries either share the same base as ``build-for``, | ||
| or are devel-series entries (exactly ``"devel"`` or ``"*@devel"``). | ||
| - ``build-on`` must not mix devel-series entries with any non-devel entries | ||
| (including base-less entries that would inherit a stable top-level base), | ||
| for the same reason that two different stable bases in ``build-on`` are | ||
| rejected. | ||
| """ | ||
| build_ons = p["build-on"] if isinstance(p["build-on"], list) else [p["build-on"]] | ||
| build_fors = ( | ||
| p["build-for"] if isinstance(p["build-for"], list) else [p["build-for"]] | ||
| ) | ||
| build_for_base = build_fors[0].partition(":")[0] | ||
|
|
||
| devel_build_ons = [ | ||
| on | ||
| for on in build_ons | ||
| if on.partition(":")[0] == "devel" or on.partition(":")[0].endswith("@devel") | ||
| ] | ||
| # build-on entries that are not devel-series (includes base-less entries) | ||
| non_devel_build_ons = [on for on in build_ons if on not in devel_build_ons] | ||
|
|
||
| # Mixing devel with any non-devel entries in build-on is not allowed. | ||
| if devel_build_ons and non_devel_build_ons: | ||
| return False | ||
|
|
||
| # All non-devel entries that carry an explicit base must match build-for. | ||
| return all( | ||
| on.partition(":")[0] == build_for_base | ||
| for on in non_devel_build_ons | ||
| if "@" in on.partition(":")[0] | ||
| ) | ||
|
|
||
|
|
||
| @given( | ||
| base=strategies.real_distro_base(), | ||
| platforms=strategies.platform( | ||
|
|
@@ -773,12 +893,7 @@ def test_fuzz_get_platforms_build_plan_single_base( | |
| values=strategies.platform_dict( | ||
| build_ons=strategies.distro_series_arch_str(strategies.any_distro_base()), | ||
| build_fors=strategies.distro_series_arch_str(strategies.any_distro_base()), | ||
| ).filter( | ||
| lambda p: ( | ||
| {p["build-for"][0].partition(":")[0]} | ||
| == {on.partition(":")[0] for on in p["build-on"]} | ||
| ) | ||
| ), | ||
| ).filter(_is_valid_multi_base_platform_dict), | ||
| ), | ||
| ) | ||
| def test_fuzz_get_platforms_build_plan_multi_base( | ||
|
|
||
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.