Skip to content

Commit

Permalink
Remove build wrapper (#530)
Browse files Browse the repository at this point in the history
## Issue
tox build wrapper needs to be removed in order to prepare for charmcraft
3

## Solution
remove build wrapper

---------

Co-authored-by: Mehdi-Bendriss <[email protected]>
  • Loading branch information
MiaAltieri and Mehdi-Bendriss authored Jan 10, 2025
1 parent 1f7f8b9 commit 677a662
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 50 deletions.
54 changes: 32 additions & 22 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,30 @@

type: charm
bases:
- build-on:
- name: "ubuntu"
channel: "22.04"
run-on:
- name: "ubuntu"
channel: "22.04"
- name: ubuntu
channel: "22.04"
architectures: [amd64]
parts:
charm:
charm-strict-dependencies: true
files:
plugin: dump
source: .
build-packages:
- git
override-build: |
rustup default stable
# Convert subset of poetry.lock to requirements.txt
curl -sSL https://install.python-poetry.org | python3 -
/root/.local/bin/poetry self add poetry-plugin-export
/root/.local/bin/poetry export --only main,charm-libs --output requirements.txt
# 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:
Expand All @@ -28,13 +36,15 @@ parts:
- pkg-config
- rustc
- cargo
version_data:
plugin: dump
source: .
override-build: |
rustup default stable
# Convert subset of poetry.lock to requirements.txt
curl -sSL https://install.python-poetry.org | python3 -
/root/.local/bin/poetry self add poetry-plugin-export
/root/.local/bin/poetry export --only main,charm-libs --output requirements.txt
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
# Exclude charm_version file during staging
- -charm_version
charm-strict-dependencies: true
charm-requirements: [requirements.txt]
30 changes: 2 additions & 28 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,12 @@ allowlist_externals =
poetry
sh

[testenv:build-{production,dev,wrapper}]
# Wrap `charmcraft pack`
pass_env =
CI
allowlist_externals =
{[testenv]allowlist_externals}
charmcraft
charmcraftcache
mv
rm
commands_pre =
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}")'
poetry self add poetry-plugin-export
poetry export --only main,charm-libs --output requirements.txt
commands =
build-production: charmcraft pack {posargs}
build-dev: charmcraftcache pack {posargs}
commands_post =
mv requirements.txt requirements-last-build.txt
rm charm_version


[testenv:format]
description = Apply coding style standards to code
commands_pre =
poetry install --only format
commands =
poetry lock
poetry lock
poetry run isort {[vars]all_path}
poetry run black {[vars]all_path}

Expand Down Expand Up @@ -90,15 +68,11 @@ pass_env =
CI
GITHUB_OUTPUT
SECRETS_FROM_GITHUB
allowlist_externals =
{[testenv:build-wrapper]allowlist_externals}
commands_pre =
{[testenv:build-wrapper]commands_pre}
poetry install --only integration
commands =
poetry run pytest -v --tb native --log-cli-level=INFO -s --ignore={[vars]tests_path}/unit/ {posargs}
commands_post =
{[testenv:build-wrapper]commands_post}


[testenv:cleanup_juju_models]
description = Cleanup Juju models
Expand Down

0 comments on commit 677a662

Please sign in to comment.