-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
breaking: Switch to ST124 "shorthand notation" syntax in charmcraft.y…
…aml (#258) Enables building & releasing multi-base charms with 24.04 in a single charmcraft.yaml and git branch Integration testing is not supported on multiple bases—it is currently only supported on 22.04 ## Breaking changes - ST124 "shorthand notation" syntax required in charmcraft.yaml - `pytest-operator-cache` (which overrides `ops_test.build_charm` from pytest-operator) now assumes 22.04 base ## Deprecation notice - `pytest-operator-cache` is deprecated & will be removed in a future release
- Loading branch information
1 parent
eb08b36
commit 92d0a9f
Showing
15 changed files
with
292 additions
and
193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,19 @@ with: | |
cache: true | ||
``` | ||
remember to add your charm's branch(es) to charmcraftcache by running `ccc add` or by [opening an issue](https://github.com/canonical/charmcraftcache-hub/issues/new?assignees=&labels=add-charm&projects=&template=add_charm_branch.yaml&title=Add+charm+branch). | ||
|
||
### Required charmcraft.yaml syntax | ||
Only [ST124 - Multi-base platforms in craft tools](https://docs.google.com/document/d/1QVHxZumruKVZ3yJ2C74qWhvs-ye5I9S6avMBDHs2YcQ/edit) "shorthand notation" syntax is supported | ||
|
||
#### Example | ||
```yaml | ||
platforms: | ||
[email protected]:amd64: | ||
[email protected]:arm64: | ||
[email protected]:amd64: | ||
[email protected]:arm64: | ||
``` | ||
|
||
Under the charmcraft.yaml `platforms` key, `build-on` and `build-for` syntax are not supported | ||
|
||
The `base` and `bases` charmcraft.yaml keys are not supported |
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 |
---|---|---|
|
@@ -8,4 +8,16 @@ jobs: | |
build: | ||
name: Build rock | ||
uses: canonical/data-platform-workflows/.github/workflows/[email protected] | ||
``` | ||
``` | ||
### Supported `platforms` syntax in rockcraft.yaml | ||
Only "shorthand notation" is supported | ||
|
||
Example rockcraft.yaml | ||
```yaml | ||
platforms: | ||
amd64: | ||
arm64: | ||
``` | ||
|
||
`build-on` and `build-for` are not supported |
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 |
---|---|---|
|
@@ -8,4 +8,35 @@ jobs: | |
build: | ||
name: Build snap | ||
uses: canonical/data-platform-workflows/.github/workflows/[email protected] | ||
``` | ||
``` | ||
### Supported `platforms` and `architectures` syntax in snapcraft.yaml | ||
See https://snapcraft.io/docs/architectures#how-to-create-a-snap-for-a-specific-architecture | ||
|
||
#### core24 | ||
Only `platforms` is supported. `architectures` is not supported | ||
|
||
Only "shorthand notation" is supported | ||
|
||
Example snapcraft.yaml | ||
```yaml | ||
platforms: | ||
amd64: | ||
arm64: | ||
``` | ||
|
||
`build-on` and `build-for` are not supported | ||
|
||
#### core22 | ||
Only `architectures` is supported. `platforms` is not supported | ||
|
||
`architectures` must be a list of dictionaries. Each dictionary in the list must contain a `build-on` key | ||
|
||
Example snapcraft.yaml | ||
```yaml | ||
architectures: | ||
- build-on: [amd64] | ||
build-for: [amd64] | ||
- build-on: [arm64] | ||
build-for: [arm64] | ||
``` |
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
54 changes: 54 additions & 0 deletions
54
python/cli/data_platform_workflows_cli/craft_tools/charmcraft_platforms.py
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,54 @@ | ||
# Copied from https://github.com/canonical/charmcraftcache/blob/main/charmcraftcache/_platforms.py | ||
import pathlib | ||
|
||
import yaml | ||
|
||
_SYNTAX_DOCS = "https://github.com/canonical/data-platform-workflows/blob/main/.github/workflows/build_charm.md#required-charmcraftyaml-syntax" | ||
|
||
|
||
class Platform(str): | ||
"""Platform in charmcraft.yaml 'platforms' (e.g. '[email protected]:amd64')""" | ||
|
||
def __new__(cls, value: str, /): | ||
try: | ||
_, architecture = value.split(":") | ||
except ValueError: | ||
raise ValueError( | ||
"Invalid ST124 shorthand notation in charmcraft.yaml 'platforms': " | ||
f"{repr(value)}\n\nMore info: {_SYNTAX_DOCS}" | ||
) | ||
instance: Platform = super().__new__(cls, value) | ||
instance.architecture = architecture | ||
return instance | ||
|
||
|
||
def get(charmcraft_yaml: pathlib.Path, /): | ||
"""Get platforms from charmcraft.yaml""" | ||
charmcraft_yaml_data = yaml.safe_load(charmcraft_yaml.read_text()) | ||
for key in ("base", "bases"): | ||
if key in charmcraft_yaml_data: | ||
raise ValueError( | ||
f"'{key}' key in charmcraft.yaml not supported. Use 'platforms' key instead.\n\n" | ||
f"More info: {_SYNTAX_DOCS}" | ||
) | ||
yaml_platforms = charmcraft_yaml_data.get("platforms") | ||
if not yaml_platforms: | ||
raise ValueError( | ||
f"'platforms' key in charmcraft.yaml required\n\nMore info: {_SYNTAX_DOCS}" | ||
) | ||
if not isinstance(yaml_platforms, dict): | ||
raise TypeError( | ||
"Expected charmcraft.yaml 'platforms' with type 'dict', got " | ||
f"{repr(type(yaml_platforms).__name__)}: {repr(yaml_platforms)}\n\n" | ||
f"More info: {_SYNTAX_DOCS}" | ||
) | ||
for value in yaml_platforms.values(): | ||
if value is not None: | ||
raise ValueError( | ||
"Shorthand notation required ('build-on' and 'build-for' not supported) in " | ||
f"charmcraft.yaml 'platforms'.\n\nMore info: {_SYNTAX_DOCS}" | ||
) | ||
# Validate format of keys in `yaml_platforms` | ||
platforms = [Platform(platform) for platform in yaml_platforms] | ||
|
||
return platforms |
Oops, something went wrong.