Skip to content

Commit 2f14032

Browse files
Switch from tox build wrapper to charmcraft.yaml overrides (#178)
https://warthogs.atlassian.net/browse/DPE-5046 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Carl Csaposs <[email protected]>
1 parent 309117b commit 2f14032

File tree

8 files changed

+47
-58
lines changed

8 files changed

+47
-58
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666

6767
build:
6868
name: Build charm
69-
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v21.0.1
69+
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v22.0.0
7070
with:
7171
# Use of cache blocked by https://github.com/canonical/charmcraft/issues/1456
7272
# Details: https://github.com/canonical/charmcraftcache/issues/3

.github/workflows/release.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ jobs:
1515

1616
build:
1717
name: Build charm
18-
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v21.0.1
18+
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v22.0.0
1919

2020
release:
2121
name: Release charm
2222
needs:
2323
- ci-tests
2424
- build
25-
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v21.0.1
25+
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v22.0.0
2626
with:
2727
channel: dpe/edge
2828
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}

.github/workflows/sync_docs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
sync-docs:
1212
name: Sync docs from Discourse
13-
uses: canonical/data-platform-workflows/.github/workflows/sync_docs.yaml@v21.0.1
13+
uses: canonical/data-platform-workflows/.github/workflows/sync_docs.yaml@v22.0.0
1414
with:
1515
reviewers: a-velasco
1616
permissions:

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ tox # runs 'lint' and 'unit' environments
8686
Build the charm in this git repository using:
8787

8888
```shell
89-
tox run -e build-dev
89+
charmcraftcache pack
9090
```
9191

9292
### Deploy

charmcraft.yaml

+31-12
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,42 @@ parts:
1919
files:
2020
plugin: dump
2121
source: .
22+
build-packages:
23+
- git
24+
override-build: |
25+
# Workaround to add unique identifier (git hash) to charm version while specification
26+
# DA053 - Charm versioning
27+
# (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1)
28+
# is pending review.
29+
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}")'
30+
31+
craftctl default
32+
stage:
33+
# Exclude requirements.txt file during staging
34+
# Workaround for https://github.com/canonical/charmcraft/issues/1389 on charmcraft 2
35+
- -requirements.txt
2236
prime:
2337
- charm_version
2438
- workload_version
2539
charm:
26-
override-pull: |
27-
craftctl default
28-
if [[ ! -f requirements.txt ]]
29-
then
30-
echo 'ERROR: Use "tox run -e build-dev" instead of calling "charmcraft pack" directly' >&2
31-
exit 1
32-
fi
33-
# TODO: enable after https://github.com/canonical/charmcraft/issues/1456 fixed
34-
charm-strict-dependencies: false
35-
charm-entrypoint: src/machine_charm.py
40+
build-snaps:
41+
- rustup
3642
build-packages:
3743
- libffi-dev
3844
- libssl-dev
3945
- pkg-config
40-
- rustc
41-
- cargo
46+
override-build: |
47+
rustup default stable
48+
49+
# Convert subset of poetry.lock to requirements.txt
50+
curl -sSL https://install.python-poetry.org | python3 -
51+
/root/.local/bin/poetry export --only main,charm-libs --output requirements.txt
52+
53+
craftctl default
54+
stage:
55+
# Exclude charm_version file during staging
56+
- -charm_version
57+
# TODO: enable after https://github.com/canonical/charmcraft/issues/1456 fixed
58+
charm-strict-dependencies: false
59+
charm-requirements: [requirements.txt]
60+
charm-entrypoint: src/machine_charm.py

poetry.lock

+8-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ pytest-mock = "^3.14.0"
6363
[tool.poetry.group.integration.dependencies]
6464
pytest = "^8.2.2"
6565
pytest-operator = "^0.35.0"
66-
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
67-
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
68-
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/github_secrets"}
66+
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v22.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
67+
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v22.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
68+
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v22.0.0", subdirectory = "python/pytest_plugins/github_secrets"}
6969
juju = "^3.5.2.0"
7070
mysql-connector-python = "~8.0.33"
7171
tenacity = "^8.5.0"

tox.ini

-31
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,6 @@ set_env =
1717
allowlist_externals =
1818
poetry
1919

20-
[testenv:build-{production,dev,wrapper}]
21-
# Wrap `charmcraft pack`
22-
pass_env =
23-
CI
24-
GH_TOKEN
25-
allowlist_externals =
26-
{[testenv]allowlist_externals}
27-
charmcraft
28-
charmcraftcache
29-
mv
30-
commands_pre =
31-
# TODO charm versioning: Remove
32-
# Workaround to add unique identifier (git hash) to charm version while specification
33-
# DA053 - Charm versioning
34-
# (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1)
35-
# is pending review.
36-
python -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}")'
37-
38-
poetry export --only main,charm-libs --output requirements.txt
39-
commands =
40-
build-production: charmcraft pack {posargs}
41-
build-dev: charmcraftcache pack {posargs}
42-
commands_post =
43-
mv requirements.txt requirements-last-build.txt
44-
mv charm_version.backup charm_version
45-
4620
[testenv:format]
4721
description = Apply coding style standards to code
4822
commands_pre =
@@ -85,12 +59,7 @@ pass_env =
8559
CI
8660
GITHUB_OUTPUT
8761
SECRETS_FROM_GITHUB
88-
allowlist_externals =
89-
{[testenv:build-wrapper]allowlist_externals}
9062
commands_pre =
9163
poetry install --only integration
92-
{[testenv:build-wrapper]commands_pre}
9364
commands =
9465
poetry run pytest -v --tb native --log-cli-level=INFO -s --ignore={[vars]tests_path}/unit/ {posargs}
95-
commands_post =
96-
{[testenv:build-wrapper]commands_post}

0 commit comments

Comments
 (0)