Skip to content

Commit da06da4

Browse files
Switch from tox build wrapper to charmcraft.yaml overrides (#319)
https://warthogs.atlassian.net/browse/DPE-5046
1 parent 9c74c1a commit da06da4

File tree

8 files changed

+46
-69
lines changed

8 files changed

+46
-69
lines changed

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464

6565
build:
6666
name: Build charm
67-
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v21.0.1
67+
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v22.0.0
6868
with:
6969
cache: true
7070

@@ -96,7 +96,7 @@ jobs:
9696
- lint
9797
- unit-test
9898
- build
99-
uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v21.0.1
99+
uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v22.0.0
100100
with:
101101
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
102102
architecture: ${{ matrix.architecture }}

.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: 8.0/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,izmalk
1616
permissions:

CONTRIBUTING.md

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

5858
```shell
59-
tox run -e build-dev
59+
charmcraftcache pack
6060
```
6161

6262
### Deploy

charmcraft.yaml

+30-11
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,42 @@ parts:
1313
files:
1414
plugin: dump
1515
source: .
16+
build-packages:
17+
- git
18+
override-build: |
19+
# Workaround to add unique identifier (git hash) to charm version while specification
20+
# DA053 - Charm versioning
21+
# (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1)
22+
# is pending review.
23+
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}")'
24+
25+
craftctl default
26+
stage:
27+
# Exclude requirements.txt file during staging
28+
# Workaround for https://github.com/canonical/charmcraft/issues/1389 on charmcraft 2
29+
- -requirements.txt
1630
prime:
1731
- charm_version
1832
- workload_version
1933
- scripts
2034
charm:
21-
override-pull: |
22-
craftctl default
23-
if [[ ! -f requirements.txt ]]
24-
then
25-
echo 'ERROR: Use "tox run -e build-dev" instead of calling "charmcraft pack" directly' >&2
26-
exit 1
27-
fi
28-
charm-strict-dependencies: true
29-
charm-entrypoint: src/kubernetes_charm.py
35+
build-snaps:
36+
- rustup
3037
build-packages:
3138
- libffi-dev
3239
- libssl-dev
3340
- pkg-config
34-
- rustc
35-
- cargo
41+
override-build: |
42+
rustup default stable
43+
44+
# Convert subset of poetry.lock to requirements.txt
45+
curl -sSL https://install.python-poetry.org | python3 -
46+
/root/.local/bin/poetry export --only main,charm-libs --output requirements.txt
47+
48+
craftctl default
49+
stage:
50+
# Exclude charm_version file during staging
51+
- -charm_version
52+
charm-strict-dependencies: true
53+
charm-requirements: [requirements.txt]
54+
charm-entrypoint: src/kubernetes_charm.py

poetry.lock

+7-18
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
@@ -51,14 +51,14 @@ ops = "^2.9.0"
5151
[tool.poetry.group.integration.dependencies]
5252
pytest = "^8.2.2"
5353
pytest-operator = "^0.35.0"
54-
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
55-
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
54+
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v22.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
55+
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v22.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
5656
juju = "^3.5.2.0"
5757
mysql-connector-python = "~8.0.33"
5858
pyyaml = "^6.0.1"
5959
tenacity = "^8.5.0"
6060
allure-pytest = "^2.13.5"
61-
allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"}
61+
allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v22.0.0", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"}
6262

6363

6464
[tool.coverage.run]

tox.ini

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

21-
[testenv:build-{production,dev,wrapper}]
22-
# Wrap `charmcraft pack`
23-
pass_env =
24-
CI
25-
GH_TOKEN
26-
allowlist_externals =
27-
{[testenv]allowlist_externals}
28-
charmcraft
29-
charmcraftcache
30-
mv
31-
commands_pre =
32-
# TODO charm versioning: Remove
33-
# Workaround to add unique identifier (git hash) to charm version while specification
34-
# DA053 - Charm versioning
35-
# (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1)
36-
# is pending review.
37-
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}")'
38-
39-
poetry export --only main,charm-libs --output requirements.txt
40-
commands =
41-
build-production: charmcraft pack {posargs}
42-
build-dev: charmcraftcache pack {posargs}
43-
commands_post =
44-
mv requirements.txt requirements-last-build.txt
45-
mv charm_version.backup charm_version
46-
4721
[testenv:format]
4822
description = Apply coding style standards to code
4923
commands_pre =
@@ -80,12 +54,7 @@ set_env =
8054
pass_env =
8155
CI
8256
GITHUB_OUTPUT
83-
allowlist_externals =
84-
{[testenv:build-wrapper]allowlist_externals}
8557
commands_pre =
8658
poetry install --only integration
87-
{[testenv:build-wrapper]commands_pre}
8859
commands =
8960
poetry run pytest -v --tb native --log-cli-level=INFO -s --ignore={[vars]tests_path}/unit/ {posargs}
90-
commands_post =
91-
{[testenv:build-wrapper]commands_post}

0 commit comments

Comments
 (0)