From 934d35884ad905355072f00f67a2c4c240283962 Mon Sep 17 00:00:00 2001 From: Ray Chan Date: Wed, 26 Feb 2025 06:58:20 +0800 Subject: [PATCH] Support charmcraft 3 and multi platform builds (#394) * Support charmcraft 3 and multi platform builds * Update .github/workflows/check.yaml Co-authored-by: Samuel Allan * Fix charm path in tests --------- Co-authored-by: Samuel Allan --- .github/workflows/check.yaml | 4 +-- .github/workflows/promote.yaml | 2 +- .github/workflows/release.yaml | 2 +- charmcraft.yaml | 46 +++++++--------------------------- tests/functional/conftest.py | 2 +- 5 files changed, 14 insertions(+), 42 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index cc22f45a..c940e109 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -91,7 +91,7 @@ jobs: - 'tox -e func -- -v --base ubuntu@24.04 --keep-models' juju-channel: ["3.4/stable"] exclude: - # NOTE(rgildein): The grafana-agent does not support ubuntu@24.04 on arm64. See #347 + # NOTE: grafana-agent does not support ubuntu@24.04 on arm64. See https://github.com/canonical/grafana-agent-operator/issues/207 - test-command: 'tox -e func -- -v --base ubuntu@24.04 --keep-models' runs-on: [Ubuntu_ARM64_4C_16G_01] steps: @@ -116,7 +116,7 @@ jobs: with: provider: "lxd" juju-channel: ${{ matrix.juju-channel }} - charmcraft-channel: "2.x/stable" + charmcraft-channel: "3.x/stable" # This is used by zaza in the functional tests for non-amd64 architectures (if applicable) - name: Set zaza juju model constraints for architecture diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml index fed31a1e..a99b1023 100644 --- a/.github/workflows/promote.yaml +++ b/.github/workflows/promote.yaml @@ -36,4 +36,4 @@ jobs: credentials: ${{ secrets.CHARMHUB_TOKEN }} destination-channel: ${{ steps.set-channels.outputs.destination-channel }} origin-channel: ${{ steps.set-channels.outputs.origin-channel }} - charmcraft-channel: "2.x/stable" + charmcraft-channel: "3.x/stable" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 31c428ae..ba719597 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -36,7 +36,7 @@ jobs: - name: Pack and upload to charmhub uses: canonical/charming-actions/upload-charm@2.6.2 with: - charmcraft-channel: "2.x/stable" + charmcraft-channel: "3.x/stable" credentials: "${{ secrets.CHARMHUB_TOKEN }}" github-token: "${{ secrets.GITHUB_TOKEN }}" # Ensure the charm is built in an isolated environment and on the correct base in an lxd container. diff --git a/charmcraft.yaml b/charmcraft.yaml index 0ee7b4ac..e1532dff 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -1,50 +1,22 @@ # Learn more about charmcraft.yaml configuration at: # https://juju.is/docs/sdk/charmcraft-config # This is a template `charmcraft.yaml` file for ops charms -# This file is managed by bootstack-charms-spec and should not be modified -# within individual charm repos. https://launchpad.net/bootstack-charms-spec type: charm parts: charm: + plugin: charm + source: . build-packages: [git] -bases: - - build-on: - - name: ubuntu - channel: "22.04" - architectures: ["amd64"] - run-on: - - name: ubuntu - channel: "24.04" - architectures: - - amd64 - - name: ubuntu - channel: "22.04" - architectures: - - amd64 - - name: ubuntu - channel: "20.04" - architectures: - - amd64 - - build-on: - - name: ubuntu - channel: "22.04" - architectures: ["arm64"] - run-on: - - name: ubuntu - channel: "24.04" - architectures: - - arm64 - - name: ubuntu - channel: "22.04" - architectures: - - arm64 - - name: ubuntu - channel: "20.04" - architectures: - - arm64 +platforms: + ubuntu@20.04:amd64: + ubuntu@22.04:amd64: + ubuntu@24.04:amd64: + ubuntu@20.04:arm64: + ubuntu@22.04:arm64: + ubuntu@24.04:arm64: actions: redetect-hardware: diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index 08bddafc..d4147089 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -191,7 +191,7 @@ def required_resources(resources: list[Resource], provided_collectors: set) -> l @pytest.fixture(scope="module") def charm_path(base: str, architecture: str) -> Path: """Fixture to determine the charm path based on the base and architecture.""" - glob_path = f"hardware-observer_*{base.replace('@', '-')}-{architecture}*.charm" + glob_path = f"hardware-observer_*{base}-{architecture}*.charm" paths = list(Path(".").glob(glob_path)) if not paths: