generated from canonical/template-operator
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcharmcraft.yaml
70 lines (65 loc) · 2.76 KB
/
charmcraft.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
type: charm
bases:
# Whenever "bases" is changed:
# - Update tests/conftest.py::pytest_configure()
# - Update .github/workflow/ci.yaml integration-test matrix
- name: ubuntu
channel: "20.04"
architectures: [amd64]
- name: ubuntu
channel: "22.04"
architectures: [amd64]
- name: ubuntu
channel: "22.04"
architectures: [arm64]
parts:
files:
plugin: dump
source: .
build-packages:
- git
override-build: |
# Workaround to add unique identifier (git hash) to charm version while specification
# DA053 - Charm versioning
# (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1)
# is pending review.
python3 -c 'import pathlib; import shutil; import subprocess; git_hash=subprocess.run(["git", "describe", "--always", "--dirty"], capture_output=True, check=True, encoding="utf-8").stdout; file = pathlib.Path("charm_version"); shutil.copy(file, pathlib.Path("charm_version.backup")); version = file.read_text().strip(); file.write_text(f"{version}+{git_hash}")'
craftctl default
stage:
# Exclude requirements.txt file during staging
# Workaround for https://github.com/canonical/charmcraft/issues/1389 on charmcraft 2
- -requirements.txt
prime:
- charm_version
- workload_version
charm:
build-snaps:
- rustup
build-packages:
- libffi-dev
- libssl-dev
- pkg-config
override-build: |
rustup default stable
# Use uv to install poetry so that a newer version of Python can be installed if needed by poetry
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.5.15/uv-installer.sh | sh # renovate: charmcraft-uv-latest
# poetry 2.0.0 requires Python >=3.9
if ! "$HOME/.local/bin/uv" python find '>=3.9'
then
# Use first Python version that is >=3.9 and available in an Ubuntu LTS
# (to reduce the number of Python versions we use)
"$HOME/.local/bin/uv" python install 3.10.12 # renovate: charmcraft-python-ubuntu-22.04
fi
"$HOME/.local/bin/uv" tool install --no-python-downloads --python '>=3.9' poetry==2.0.0 --with poetry-plugin-export==1.8.0 # renovate: charmcraft-poetry-latest
# Convert subset of poetry.lock to requirements.txt
"$HOME/.local/bin/poetry" export --only main,charm-libs --output requirements.txt
craftctl default
stage:
# Exclude charm_version file during staging
- -charm_version
# TODO: enable after https://github.com/canonical/charmcraft/issues/1456 fixed
charm-strict-dependencies: false
charm-requirements: [requirements.txt]
charm-entrypoint: src/charm.py