-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support multi-base platform recipes (#2054)
Adds support for multi-base recipes with the `platforms` keyword. Internally, this moves to a new practice where the application stops modifying project data before passing the it to craft-platforms. This will ensure consistent processing by charmcraft and by launchpad. Documentation is coming soon via canonical/craft-platforms#75 and #2009. To summarize the usage, `base` and `build-base` are removed from the project and the base is encoded into the platform. Platforms can be defined in a shorthand notation: ```yaml platforms: ubuntu@22.04:amd64: ubuntu@24.04:amd64: ``` Or they can be defined in standard form: ```yaml platforms: jammy: build-on: [ubuntu@22.04:amd64] build-for: [ubuntu@22.04:amd64] noble: build-on: [ubuntu@24.04:amd64] build-for: [ubuntu@24.04:amd64] ``` Fixes #1789 Fixes #2008 Creates canonical/craft-platforms#85 Found during implementation canonical/craft-platforms#80 (CRAFT-3718)
- Loading branch information
Showing
21 changed files
with
538 additions
and
250 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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,20 @@ | ||
name: test-charm | ||
type: charm | ||
title: test | ||
summary: test | ||
description: | | ||
A charm recipe that uses a multi-base platform syntax to define | ||
architecture independent charms for 22.04 and 24.04. | ||
platforms: | ||
jammy: | ||
build-on: [ubuntu@22.04:amd64] | ||
build-for: [ubuntu@22.04:all] | ||
noble: | ||
build-on: [ubuntu@24.04:amd64] | ||
build-for: [ubuntu@24.04:all] | ||
|
||
parts: | ||
my-charm: | ||
plugin: dump | ||
source: . |
This file contains 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,2 @@ | ||
test-charm_jammy.charm | ||
test-charm_noble.charm |
This file contains 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 @@ | ||
name: test-charm | ||
type: charm | ||
title: test | ||
summary: test | ||
description: | | ||
A charm recipe that uses a multi-base platform syntax to define | ||
6 charms across different bases and architectures. | ||
platforms: | ||
# shorthand syntax | ||
ubuntu@20.04:amd64: | ||
ubuntu@20.04:riscv64: | ||
|
||
ubuntu@22.04:amd64: | ||
ubuntu@22.04:riscv64: | ||
|
||
# standard syntax | ||
noble-amd64: | ||
build-on: [ubuntu@24.04:amd64] | ||
build-for: [ubuntu@24.04:amd64] | ||
noble-riscv64: | ||
build-on: [ubuntu@24.04:riscv64] | ||
build-for: [ubuntu@24.04:riscv64] | ||
|
||
parts: | ||
my-charm: | ||
plugin: charm | ||
source: . |
This file contains 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,3 @@ | ||
test-charm_ubuntu@20.04:amd64.charm | ||
test-charm_ubuntu@22.04:amd64.charm | ||
test-charm_noble-amd64.charm |
This file contains 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 @@ | ||
--platform ubuntu@22.04:amd64 |
29 changes: 29 additions & 0 deletions
29
tests/spread/smoketests/multi-base/one-platform/charmcraft.yaml
This file contains 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,29 @@ | ||
name: test-charm | ||
type: charm | ||
title: test | ||
summary: test | ||
description: | | ||
A charm recipe that uses a multi-base platform syntax to define | ||
6 charms across different bases and architectures. | ||
This test builds one of the charms using the `--platform` argument. | ||
platforms: | ||
# shorthand syntax | ||
ubuntu@20.04:amd64: | ||
ubuntu@20.04:riscv64: | ||
|
||
ubuntu@22.04:amd64: | ||
ubuntu@22.04:riscv64: | ||
|
||
# standard syntax | ||
noble-amd64: | ||
build-on: [ubuntu@24.04:amd64] | ||
build-for: [ubuntu@24.04:amd64] | ||
noble-riscv64: | ||
build-on: [ubuntu@24.04:riscv64] | ||
build-for: [ubuntu@24.04:riscv64] | ||
|
||
parts: | ||
my-charm: | ||
plugin: charm | ||
source: . |
1 change: 1 addition & 0 deletions
1
tests/spread/smoketests/multi-base/one-platform/expected-charms.txt
This file contains 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 @@ | ||
test-charm_ubuntu@22.04:amd64.charm |
This file contains 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,52 @@ | ||
summary: pack charm using multi-base notation | ||
kill-timeout: 30m # These sometimes take a while to download bases. | ||
priority: 50 # Because these can take a while, run them early. | ||
|
||
environment: | ||
CHARM/all: all | ||
CHARM/basic: basic | ||
CHARM/one_platform: one-platform | ||
|
||
# test only on amd64 | ||
systems: | ||
- ubuntu-22.04-64 | ||
- ubuntu-22.04-amd64 | ||
|
||
include: | ||
- tests/ | ||
|
||
prepare: | | ||
# '--force' because charmcraft.yaml already exists | ||
charmcraft init --force --project-dir="$CHARM" | ||
restore: | | ||
cd $CHARM | ||
charmcraft clean | ||
execute: | | ||
cd $CHARM | ||
if [[ -e "arguments.txt" ]]; then | ||
call_args=$(cat "arguments.txt") | ||
else | ||
call_args="" | ||
fi | ||
# shellcheck disable=SC2046 (quote to prevent word splitting) | ||
charmcraft pack $call_args | ||
# assert charms were built | ||
while read -r charm_file; do | ||
if [[ ! -e ${charm_file} ]]; then | ||
echo "Could not find charm '${charm_file}'" | ||
exit 1 | ||
fi | ||
done < "expected-charms.txt" | ||
# assert no other charms were built | ||
expected_num=$(wc -l < "expected-charms.txt") | ||
actual_num=$(find . -wholename "./*.charm" | wc -l) | ||
if [[ $expected_num -ne $actual_num ]]; then | ||
echo "Expected $expected_num charms, but found $actual_num." | ||
exit 1 | ||
fi |
Oops, something went wrong.