canonical / data-platform-workflows

Reusable GitHub Actions workflows used by the Data Platform team
Apache License 2.0
3 stars 9 forks source link

Support unified charmcraft.yaml syntax #169

Open theoctober19th opened 2 months ago

theoctober19th commented 2 months ago

In the newer charm SDK versions, it is possible to merge yaml files like metadata.yaml, actions.yaml, etc. to a single charmcraft.yaml file. However, if a charm uses single charmcraft.yaml pattern, the release is blocked because the release workflow logic tries to look for metadata.yaml file which does not exist in the first place.

Here is the line which contains that logic: https://github.com/canonical/data-platform-workflows/blob/main/python/cli/data_platform_workflows_cli/craft_tools/release.py#L160C37-L160C46

Expected behavior: The release should work fine even on using a single charmcraft.yaml file for all metadata (maybe it can use charmcraft.yaml first and then metadata.yaml as a fallback or the other way around).

Logs from Actions:

Run release-charm --charm-directory='.' --channel='latest/edge'
INFO:root:Uploading charm_file=PosixPath('kyuubi-k8s_ubuntu-22.04-amd[6](https://github.com/canonical/kyuubi-k8s-operator/actions/runs/8781656696/job/24095095011#step:7:7)4.charm')
INFO:root:Uploaded charm revision=1
Traceback (most recent call last):
  File "/opt/pipx_bin/release-charm", line [8](https://github.com/canonical/kyuubi-k8s-operator/actions/runs/8781656696/job/24095095011#step:7:9), in <module>
    sys.exit(main())
  File "/opt/pipx/venvs/data-platform-workflows-cli/lib/python3.10/site-packages/data_platform_workflows_cli/release_charm.py", line 54, in main
    metadata_file = yaml.safe_load((charm_directory / "metadata.yaml").read_text())
  File "/usr/lib/python3.10/pathlib.py", line 1134, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.10/pathlib.py", line 111[9](https://github.com/canonical/kyuubi-k8s-operator/actions/runs/8781656696/job/24095095011#step:7:10), in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: 'metadata.yaml'
github-actions[bot] commented 2 months ago

https://warthogs.atlassian.net/browse/DPE-4174

carlcsaposs-canonical commented 2 months ago

Currently, unified charmcraft.yaml is not supported

This is partially by design—in order to make CI more reusable across data platform repositories, data-platform-workflows sometimes enforces/recommends a particular approach & does not support all possible approaches

However, some workflows (e.g. build_charm.yaml and release_charm.yaml) are aimed to be somewhat unopinionated & reusable across other charming teams at Canonical

For now, my recommendation would be to use a separate metadata.yaml, actions.yaml, and config.yaml for data platform charms

And we'll add this request to the backlog as non-urgent (feature request instead of bug report)

Do you have a particular need for unified charmcraft.yaml? If so, we can prioritize this higher

@theoctober19th does that sound good to you?

theoctober19th commented 2 months ago

I faced this while releasing the Apache Kyuubi charm. I believe the enchancement can be done in a backward-compatible way such that charmcraft.yaml is looked only when metadata.yaml file is not found. However, this is not something that is urgent to me and I am happy to refactor charmcraft.yaml into multiple files and move forward :)