Skip to content

Commit 4f6cd47

Browse files
Update data-platform-workflows & migrate to charmcraft 3 (#41)
1 parent 82e1a34 commit 4f6cd47

File tree

6 files changed

+288
-34
lines changed

6 files changed

+288
-34
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@ on:
1212
- cron: '53 0 * * *' # Daily at 00:53 UTC
1313
# Triggered on push to branch "main" by .github/workflows/release.yaml
1414
workflow_call:
15+
outputs:
16+
artifact-prefix:
17+
description: build_charm.yaml `artifact-prefix` output
18+
value: ${{ jobs.build.outputs.artifact-prefix }}
1519

1620
jobs:
1721
lint:
1822
name: Lint
19-
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v20.0.2
23+
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v30.0.1
2024

2125
lib-check:
2226
name: Check libraries
2327
runs-on: ubuntu-latest
2428
timeout-minutes: 5
2529
steps:
2630
- name: Checkout
27-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
2832
with:
2933
fetch-depth: 0
3034
- name: Check libs
@@ -37,6 +41,4 @@ jobs:
3741

3842
build:
3943
name: Build charm
40-
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
41-
with:
42-
cache: true
44+
uses: canonical/data-platform-workflows/.github/workflows/[email protected]

.github/workflows/release.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,24 @@ jobs:
2121
timeout-minutes: 60
2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525
with:
2626
fetch-depth: 0
2727
- name: Release charm libraries
2828
uses: canonical/charming-actions/[email protected]
2929
with:
3030
credentials: ${{ secrets.CHARMHUB_TOKEN }}
3131
github-token: ${{ secrets.GITHUB_TOKEN }}
32-
build:
33-
name: Build charm
34-
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
3532

3633
release:
3734
name: Release charm
3835
needs:
3936
- ci-tests
40-
- build
41-
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
37+
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
4238
with:
4339
channel: latest/edge
44-
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
40+
artifact-prefix: ${{ needs.ci-tests.outputs.artifact-prefix }}
4541
secrets:
4642
charmhub-token: ${{ secrets.CHARMHUB_TOKEN }}
4743
permissions:
48-
contents: write # Needed to create GitHub release
44+
contents: write # Needed to create git tags

charmcraft.yaml

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,67 @@
1-
# Copyright 2023 Canonical Ltd.
1+
# Copyright 2022 Canonical Ltd.
22
# See LICENSE file for licensing details.
33

44
type: charm
5-
bases:
6-
- name: ubuntu
7-
channel: "20.04"
8-
architectures: [amd64]
9-
- name: ubuntu
10-
channel: "20.04"
11-
architectures: [arm64]
12-
- name: ubuntu
13-
channel: "22.04"
14-
architectures: [amd64]
15-
- name: ubuntu
16-
channel: "22.04"
17-
architectures: [arm64]
5+
platforms:
6+
ubuntu@20.04:amd64:
7+
ubuntu@20.04:arm64:
8+
9+
ubuntu@22.04:arm64:
10+
# Files implicitly created by charmcraft without a part:
11+
# - dispatch (https://github.com/canonical/charmcraft/pull/1898)
12+
# - manifest.yaml
13+
# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L259)
14+
# Files implicitly copied/"staged" by charmcraft without a part:
15+
# - actions.yaml, config.yaml, metadata.yaml
16+
# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L290-L293
17+
# https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L156-L157)
1818
parts:
19-
charm:
20-
charm-strict-dependencies: true
21-
charm-binary-python-packages:
22-
- mysql-connector-python
19+
# "poetry-deps" part name is a magic constant
20+
# https://github.com/canonical/craft-parts/pull/901
21+
poetry-deps:
22+
plugin: nil
23+
build-packages:
24+
- curl
25+
override-build: |
26+
# Use environment variable instead of `--break-system-packages` to avoid failing on older
27+
# versions of pip that do not recognize `--break-system-packages`
28+
# `--user` needed (in addition to `--break-system-packages`) for Ubuntu >=24.04
29+
PIP_BREAK_SYSTEM_PACKAGES=true python3 -m pip install --user --upgrade pip==24.3.1 # renovate: charmcraft-pip-latest
30+
31+
# Use uv to install poetry so that a newer version of Python can be installed if needed by poetry
32+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.5.20/uv-installer.sh | sh # renovate: charmcraft-uv-latest
33+
# poetry 2.0.0 requires Python >=3.9
34+
if ! "$HOME/.local/bin/uv" python find '>=3.9'
35+
then
36+
# Use first Python version that is >=3.9 and available in an Ubuntu LTS
37+
# (to reduce the number of Python versions we use)
38+
"$HOME/.local/bin/uv" python install 3.10.12 # renovate: charmcraft-python-ubuntu-22.04
39+
fi
40+
"$HOME/.local/bin/uv" tool install --no-python-downloads --python '>=3.9' poetry==2.0.1 --with poetry-plugin-export==1.9.0 # renovate: charmcraft-poetry-latest
41+
42+
ln -sf "$HOME/.local/bin/poetry" /usr/local/bin/poetry
43+
# "charm-poetry" part name is arbitrary; use for consistency
44+
# Avoid using "charm" part name since that has special meaning to charmcraft
45+
charm-poetry:
46+
# By default, the `poetry` plugin creates/stages these directories:
47+
# - lib, src
48+
# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L76-L78)
49+
# - venv
50+
# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L95
51+
# https://github.com/canonical/craft-parts/blob/afb0d652eb330b6aaad4f40fbd6e5357d358de47/craft_parts/plugins/base.py#L270)
52+
plugin: poetry
53+
source: .
54+
after:
55+
- poetry-deps
56+
poetry-export-extra-args: ['--only', 'main,charm-libs']
57+
poetry-pip-extra-args: ['--only-binary', 'mysql-connector-python']
58+
override-build: |
59+
craftctl default
60+
# Include requirements.txt in *.charm artifact for easier debugging
61+
cp requirements.txt "$CRAFT_PART_INSTALL/requirements.txt"
62+
# "files" part name is arbitrary; use for consistency
63+
files:
64+
plugin: dump
65+
source: .
66+
stage:
67+
- LICENSE

0 commit comments

Comments
 (0)