-
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.
Support ST124 shorthand notation syntax in charmcraft.yaml
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
- Loading branch information
1 parent
909fa34
commit 97aab30
Showing
6 changed files
with
106 additions
and
161 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
112 changes: 0 additions & 112 deletions
112
python/cli/data_platform_workflows_cli/craft_tools/collect_bases.py
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
python/cli/data_platform_workflows_cli/craft_tools/collect_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,68 @@ | ||
# Copyright 2022 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
"""Collect ST124 shorthand notation platforms to build from charmcraft.yaml | ||
TODO add ST124 support for snaps & rocks | ||
""" | ||
|
||
import argparse | ||
import json | ||
import logging | ||
import pathlib | ||
import sys | ||
|
||
import yaml | ||
|
||
from .. import github_actions | ||
from . import craft | ||
|
||
logging.basicConfig(level=logging.INFO, stream=sys.stdout) | ||
RUNNERS = { | ||
craft.Architecture.X64: "ubuntu-latest", | ||
craft.Architecture.ARM64: "Ubuntu_ARM64_4C_16G_02", | ||
} | ||
|
||
|
||
def collect(craft_: craft.Craft): | ||
"""Collect platforms to build from *craft.yaml""" | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--directory", required=True) | ||
if craft_ is craft.Craft.CHARM: | ||
parser.add_argument("--cache", required=True) | ||
args = parser.parse_args() | ||
craft_file = pathlib.Path(args.directory, f"{craft_.value}craft.yaml") | ||
if craft_ is craft.Craft.SNAP: | ||
craft_file = craft_file.parent / "snap" / craft_file.name | ||
yaml_data = yaml.safe_load(craft_file.read_text()) | ||
if craft_ is craft.Craft.CHARM: | ||
# todo: run ccst124 validate | ||
platforms = [] | ||
for platform in yaml_data["platforms"]: | ||
# Example `platform`: "[email protected]:amd64" | ||
architecture = craft.Architecture(platform.split(":")[-1]) | ||
platforms.append( | ||
{ | ||
"name": platform, | ||
"runner": RUNNERS[architecture], | ||
"name_in_artifact": platform.replace(":", "-"), | ||
} | ||
) | ||
github_actions.output["platforms"] = json.dumps(platforms) | ||
else: | ||
raise ValueError("ST124 syntax not yet supported for snaps or rocks") | ||
default_prefix = f'packed-{craft_.value}-{args.directory.replace("/", "-")}' | ||
if craft_ is craft.Craft.CHARM: | ||
default_prefix = f'packed-{craft_.value}-cache-{args.cache}-{args.directory.replace("/", "-")}' | ||
github_actions.output["default_prefix"] = default_prefix | ||
|
||
|
||
def snap(): | ||
collect(craft.Craft.SNAP) | ||
|
||
|
||
def rock(): | ||
collect(craft.Craft.ROCK) | ||
|
||
|
||
def charm(): | ||
collect(craft.Craft.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
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