diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6aa55a0f..c619c43f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,9 +40,10 @@ jobs: build: name: Build charms - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v24.0.5 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v26.0.0 with: cache: true + charmcraft-snap-channel: latest/beta/data-platform # TODO: remove after charmcraft 3.3 stable release path-to-charm-directory: ${{ matrix.path }} strategy: matrix: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c12ab982..ae1fd091 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,9 +30,9 @@ jobs: build: name: Build charm - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v24.0.5 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v26.0.0 with: - cache: false + charmcraft-snap-channel: latest/beta/data-platform # TODO: remove after charmcraft 3.3 stable release release: name: Release to Charmhub @@ -40,8 +40,9 @@ jobs: - lib-check - ci-tests - build - uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v24.0.5 + uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v26.0.0 with: + charmcraft-snap-channel: latest/beta/data-platform # TODO: remove after charmcraft 3.3 stable release channel: 3/edge artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} secrets: diff --git a/charmcraft.yaml b/charmcraft.yaml index de9d87c1..6a76a211 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -1,31 +1,86 @@ -# Copyright 2023 Canonical Ltd. +# Copyright 2022 Canonical Ltd. # See LICENSE file for licensing details. type: charm +platforms: + ubuntu@22.04:amd64: +# Files implicitly created by charmcraft without a part: +# - dispatch (https://github.com/canonical/charmcraft/pull/1898) +# - manifest.yaml +# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L259) +# Files implicitly copied/"primed" by charmcraft without a part: +# - actions.yaml, config.yaml, metadata.yaml +# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L290-L293 +# https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L156-L157) parts: - charm: - build-snaps: - - rustup + # "poetry-deps" part name is a magic constant + # https://github.com/canonical/craft-parts/pull/901 + poetry-deps: + plugin: nil build-packages: - - pkg-config - - libffi-dev - - libssl-dev + - curl override-build: | - # get latest rust stable toolchain - rustup default stable + # Use environment variable instead of `--break-system-packages` to avoid failing on older + # versions of pip that do not recognize `--break-system-packages` + # `--user` needed (in addition to `--break-system-packages`) for Ubuntu >=24.04 + PIP_BREAK_SYSTEM_PACKAGES=true python3 -m pip install --user --upgrade pip==24.3.1 # renovate: charmcraft-pip-latest - # 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 + # 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 + + ln -sf "$HOME/.local/bin/poetry" /usr/local/bin/poetry + # "charm-poetry" part name is arbitrary; use for consistency + # Avoid using "charm" part name since that has special meaning to charmcraft + charm-poetry: + # By default, the `poetry` plugin creates/primes these directories: + # - lib, src + # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L76-L78) + # - venv + # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L95 + # https://github.com/canonical/craft-parts/blob/afb0d652eb330b6aaad4f40fbd6e5357d358de47/craft_parts/plugins/base.py#L270) + plugin: poetry + source: . + after: + - poetry-deps + poetry-export-extra-args: ['--only', 'main,charm-libs'] + build-packages: + - libffi-dev # Needed to build Python dependencies with Rust from source + - libssl-dev # Needed to build Python dependencies with Rust from source + - pkg-config # Needed to build Python dependencies with Rust from source + override-build: | + # Workaround for https://github.com/canonical/charmcraft/issues/2068 + # rustup used to install rustc and cargo, which are needed to build Python dependencies with Rust from source + if [[ "$CRAFT_PLATFORM" == ubuntu@20.04:* || "$CRAFT_PLATFORM" == ubuntu@22.04:* ]] + then + snap install rustup --classic + else + apt-get install rustup -y + fi + + # If Ubuntu version < 24.04, rustup was installed from snap instead of from the Ubuntu + # archive—which means the rustup version could be updated at any time. Print rustup version + # to build log to make changes to the snap's rustup version easier to track + rustup --version + + # rpds-py (Python package) >=0.19.0 requires rustc >=1.76, which is not available in the + # Ubuntu 22.04 archive. Install rustc and cargo using rustup instead of the Ubuntu archive + rustup set profile minimal + rustup default 1.83.0 # renovate: charmcraft-rust-latest craftctl default - charm-strict-dependencies: true - charm-requirements: [requirements.txt] -bases: - - build-on: - - name: "ubuntu" - channel: "22.04" - run-on: - - name: "ubuntu" - channel: "22.04" + # Include requirements.txt in *.charm artifact for easier debugging + cp requirements.txt "$CRAFT_PART_INSTALL/requirements.txt" + # "files" part name is arbitrary; use for consistency + files: + plugin: dump + source: . + prime: + - LICENSE diff --git a/poetry.lock b/poetry.lock index 552741da..8885f881 100644 --- a/poetry.lock +++ b/poetry.lock @@ -998,6 +998,7 @@ files = [ {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:761817a3377ef15ac23cd7834715081791d4ec77f9297ee694ca1ee9c2c7e5eb"}, {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:3c672a53c0fb4725a29c303be906d3c1fa99c32f58abe008a82705f9ee96f40b"}, {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:4ac4c9f37eba52cb6fbeaf5b59c152ea976726b865bd4cf87883a7e7006cc543"}, + {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:60eb32934076fa07e4316b7b2742fa52cbb190b42c2df2863dbc4230a0a9b385"}, {file = "cryptography-44.0.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:ed3534eb1090483c96178fcb0f8893719d96d5274dfde98aa6add34614e97c8e"}, {file = "cryptography-44.0.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:f3f6fdfa89ee2d9d496e2c087cebef9d4fcbb0ad63c40e821b39f74bf48d9c5e"}, {file = "cryptography-44.0.0-cp37-abi3-win32.whl", hash = "sha256:eb33480f1bad5b78233b0ad3e1b0be21e8ef1da745d8d2aecbb20671658b9053"}, @@ -1008,6 +1009,7 @@ files = [ {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:c5eb858beed7835e5ad1faba59e865109f3e52b3783b9ac21e7e47dc5554e289"}, {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f53c2c87e0fb4b0c00fa9571082a057e37690a8f12233306161c8f4b819960b7"}, {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:9e6fc8a08e116fb7c7dd1f040074c9d7b51d74a8ea40d4df2fc7aa08b76b9e6c"}, + {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:9abcc2e083cbe8dde89124a47e5e53ec38751f0d7dfd36801008f316a127d7ba"}, {file = "cryptography-44.0.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:d2436114e46b36d00f8b72ff57e598978b37399d2786fd39793c36c6d5cb1c64"}, {file = "cryptography-44.0.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:a01956ddfa0a6790d594f5b34fc1bfa6098aca434696a03cfdbe469b8ed79285"}, {file = "cryptography-44.0.0-cp39-abi3-win32.whl", hash = "sha256:eca27345e1214d1b9f9490d200f9db5a874479be914199194e746c893788d417"}, @@ -2158,8 +2160,8 @@ pytest = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v24.0.5" -resolved_reference = "078fb649213bbffe223e826f04560c2e9c9c3396" +reference = "v26.0.0" +resolved_reference = "92d0a9f28a22c57b5965866c22f65b5021d3b115" subdirectory = "python/pytest_plugins/microceph" [[package]] @@ -2216,8 +2218,8 @@ pyyaml = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v24.0.5" -resolved_reference = "078fb649213bbffe223e826f04560c2e9c9c3396" +reference = "v26.0.0" +resolved_reference = "92d0a9f28a22c57b5965866c22f65b5021d3b115" subdirectory = "python/pytest_plugins/pytest_operator_cache" [[package]] @@ -2890,4 +2892,4 @@ files = [ [metadata] lock-version = "2.1" python-versions = "^3.10" -content-hash = "667da74749a16e870338d0e8be49cd283481c09cfcc9a7449f9a4168cc7acc8c" +content-hash = "09e3d7a292f863345b85f6ca2ee94e0610d3c99c37944b20777e9084827fdf44" diff --git a/pyproject.toml b/pyproject.toml index bfc534e6..f15cb01b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,11 +24,8 @@ extend-exclude = "tests/integration/app-charm/lib" profile = "black" [tool.poetry] -name = "zookeeper-k8s-operator" -version = "1.0" -description = "zookeeper-k8s-operator" -authors = [] package-mode = false +requires-poetry = ">=2.0.0" [tool.poetry.dependencies] python = "^3.10" @@ -97,10 +94,10 @@ pytest-operator = ">0.20" requests = ">2.25" kazoo = ">=2.8" jsonschema = ">=4.10" -pytest-operator-cache = { git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.5", subdirectory = "python/pytest_plugins/pytest_operator_cache" } +pytest-operator-cache = { git = "https://github.com/canonical/data-platform-workflows", tag = "v26.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache" } # To be enabled if we are using groups on integration tests # pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v6.1.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"} -pytest-microceph = { git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.5", subdirectory = "python/pytest_plugins/microceph" } +pytest-microceph = { git = "https://github.com/canonical/data-platform-workflows", tag = "v26.0.0", subdirectory = "python/pytest_plugins/microceph" } [tool.poetry.group.format.dependencies] pyright = "^1.1.301" diff --git a/tests/integration/app-charm/charmcraft.yaml b/tests/integration/app-charm/charmcraft.yaml index d37ba37e..e7ff5f19 100644 --- a/tests/integration/app-charm/charmcraft.yaml +++ b/tests/integration/app-charm/charmcraft.yaml @@ -2,10 +2,8 @@ # See LICENSE file for licensing details. type: charm -bases: - - build-on: - - name: "ubuntu" - channel: "22.04" - run-on: - - name: "ubuntu" - channel: "22.04" +platforms: + ubuntu@22.04:amd64: +parts: + charm: + plugin: charm diff --git a/tox.ini b/tox.ini index 4e53f9f4..abaf4ba9 100644 --- a/tox.ini +++ b/tox.ini @@ -74,10 +74,6 @@ commands = [testenv:integration-{charm,provider,password-rotation,tls,backup,ha,replication}] description = Run integration tests -set_env = - {[testenv]set_env} - # Workaround for https://github.com/python-poetry/poetry/issues/6958 - POETRY_INSTALLER_PARALLEL = false pass_env = {[testenv]pass_env} CI