diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5c46908..6dedba1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -66,7 +66,7 @@ jobs: build: name: Build charm - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v21.0.1 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v22.0.0 with: # Use of cache blocked by https://github.com/canonical/charmcraft/issues/1456 # Details: https://github.com/canonical/charmcraftcache/issues/3 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e8b67ff..c6f7863 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,14 +15,14 @@ jobs: build: name: Build charm - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v21.0.1 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v22.0.0 release: name: Release charm needs: - ci-tests - build - uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v21.0.1 + uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v22.0.0 with: channel: dpe/edge artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} diff --git a/.github/workflows/sync_docs.yaml b/.github/workflows/sync_docs.yaml index 960a92a..4e48da8 100644 --- a/.github/workflows/sync_docs.yaml +++ b/.github/workflows/sync_docs.yaml @@ -10,7 +10,7 @@ on: jobs: sync-docs: name: Sync docs from Discourse - uses: canonical/data-platform-workflows/.github/workflows/sync_docs.yaml@v21.0.1 + uses: canonical/data-platform-workflows/.github/workflows/sync_docs.yaml@v22.0.0 with: reviewers: a-velasco permissions: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5fb86b6..b5206ec 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,7 +86,7 @@ tox # runs 'lint' and 'unit' environments Build the charm in this git repository using: ```shell -tox run -e build-dev +charmcraftcache pack ``` ### Deploy diff --git a/charmcraft.yaml b/charmcraft.yaml index b14208c..ffba93e 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -19,23 +19,42 @@ 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: - override-pull: | - craftctl default - if [[ ! -f requirements.txt ]] - then - echo 'ERROR: Use "tox run -e build-dev" instead of calling "charmcraft pack" directly' >&2 - exit 1 - fi - # TODO: enable after https://github.com/canonical/charmcraft/issues/1456 fixed - charm-strict-dependencies: false - charm-entrypoint: src/machine_charm.py + build-snaps: + - rustup build-packages: - libffi-dev - libssl-dev - pkg-config - - rustc - - cargo + 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 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/machine_charm.py diff --git a/poetry.lock b/poetry.lock index 7365ae7..a5df510 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1770,8 +1770,8 @@ develop = false [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v21.0.1" -resolved_reference = "06f252ea079edfd055cee236ede28c237467f9b0" +reference = "v22.0.0" +resolved_reference = "da2da4b1e4469b5ed8f9187981fe2d747f8ee129" subdirectory = "python/pytest_plugins/github_secrets" [[package]] @@ -1825,8 +1825,8 @@ pyyaml = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v21.0.1" -resolved_reference = "06f252ea079edfd055cee236ede28c237467f9b0" +reference = "v22.0.0" +resolved_reference = "da2da4b1e4469b5ed8f9187981fe2d747f8ee129" subdirectory = "python/pytest_plugins/pytest_operator_cache" [[package]] @@ -1844,8 +1844,8 @@ pytest = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v21.0.1" -resolved_reference = "06f252ea079edfd055cee236ede28c237467f9b0" +reference = "v22.0.0" +resolved_reference = "da2da4b1e4469b5ed8f9187981fe2d747f8ee129" subdirectory = "python/pytest_plugins/pytest_operator_groups" [[package]] @@ -1918,6 +1918,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -2484,4 +2485,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.8.1" -content-hash = "dd09e45e5fff3e2a4f4846c26b96807eb9a1c3069bd4baf81455ade98d961bf1" +content-hash = "993c5644d6c32d8c10520837d8a29e7f90cf88d8b33e4117da09ca37d55a7edf" diff --git a/pyproject.toml b/pyproject.toml index 04f9cdc..3e6c7f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,9 +63,9 @@ pytest-mock = "^3.14.0" [tool.poetry.group.integration.dependencies] pytest = "^8.2.2" pytest-operator = "^0.35.0" -pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/pytest_operator_cache"} -pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"} -pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/github_secrets"} +pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v22.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"} +pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v22.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"} +pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v22.0.0", subdirectory = "python/pytest_plugins/github_secrets"} juju = "^3.5.2.0" mysql-connector-python = "~8.0.33" tenacity = "^8.5.0" diff --git a/tox.ini b/tox.ini index 465fc95..e22b3fc 100644 --- a/tox.ini +++ b/tox.ini @@ -17,32 +17,6 @@ set_env = allowlist_externals = poetry -[testenv:build-{production,dev,wrapper}] -# Wrap `charmcraft pack` -pass_env = - CI - GH_TOKEN -allowlist_externals = - {[testenv]allowlist_externals} - charmcraft - charmcraftcache - mv -commands_pre = - # TODO charm versioning: Remove - # 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. - 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 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 - mv charm_version.backup charm_version - [testenv:format] description = Apply coding style standards to code commands_pre = @@ -85,12 +59,7 @@ pass_env = CI GITHUB_OUTPUT SECRETS_FROM_GITHUB -allowlist_externals = - {[testenv:build-wrapper]allowlist_externals} commands_pre = poetry install --only integration - {[testenv:build-wrapper]commands_pre} 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}