-
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.
Add back support for snap & rocks (not ST124 support)
Adds support for core24 `platforms` in snapcraft.yaml
- Loading branch information
1 parent
97aab30
commit 3f3491f
Showing
6 changed files
with
102 additions
and
32 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 |
---|---|---|
|
@@ -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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,9 +34,8 @@ def collect(craft_: craft.Craft): | |
if craft_ is craft.Craft.SNAP: | ||
craft_file = craft_file.parent / "snap" / craft_file.name | ||
yaml_data = yaml.safe_load(craft_file.read_text()) | ||
platforms = [] | ||
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]) | ||
|
@@ -47,9 +46,37 @@ def collect(craft_: craft.Craft): | |
"name_in_artifact": platform.replace(":", "-"), | ||
} | ||
) | ||
github_actions.output["platforms"] = json.dumps(platforms) | ||
elif craft_ is craft.Craft.ROCK: | ||
for platform in yaml_data["platforms"]: | ||
# Example `platform`: "amd64" | ||
architecture = craft.Architecture(platform) | ||
platforms.append({"name": platform, "runner": RUNNERS[architecture]}) | ||
elif craft_ is craft.Craft.SNAP: | ||
if yaml_data["base"] == "core24": | ||
platforms_ = yaml_data["platforms"] | ||
if not isinstance(platforms_, dict): | ||
raise TypeError("Expected type 'dict' for snapcraft.yaml 'platforms'") | ||
for value in platforms_.values(): | ||
if value is not None: | ||
raise ValueError( | ||
"Only shorthand notation supported in snapcraft.yaml 'platforms'. " | ||
"'build-on' and 'build-for' not supported" | ||
) | ||
for platform in platforms_: | ||
# Example `platform`: "amd64" | ||
architecture = craft.Architecture(platform) | ||
platforms.append({"name": platform, "runner": RUNNERS[architecture]}) | ||
elif yaml_data["base"] == "core22": | ||
for entry in yaml_data["architectures"]: | ||
# Example: "amd64" | ||
platform = entry["build-on"] | ||
architecture = craft.Architecture(platform) | ||
platforms.append({"name": platform, "runner": RUNNERS[architecture]}) | ||
else: | ||
raise ValueError(f'Unsupported snapcraft.yaml base: {repr(yaml_data["base"])}') | ||
else: | ||
raise ValueError("ST124 syntax not yet supported for snaps or rocks") | ||
raise ValueError | ||
github_actions.output["platforms"] = json.dumps(platforms) | ||
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("/", "-")}' | ||
|
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