From d34a13e00ad16bad8bdca37a9e569fc9438c1fca Mon Sep 17 00:00:00 2001 From: Carl Csaposs Date: Fri, 8 Nov 2024 16:01:55 +0100 Subject: [PATCH] Update data-platform-workflows to v23.0.4 and remove tox build wrapper Tox build wrapper support removed in dpw 22: https://github.com/canonical/data-platform-workflows/releases/tag/v22.0.0 Unblocks https://warthogs.atlassian.net/browse/DPE-5809 --- .github/workflows/ci.yaml | 6 ++-- .github/workflows/release.yaml | 4 +-- charmcraft.yaml | 56 ++++++++++++++++++++++------------ poetry.lock | 20 ++++++------ pyproject.toml | 17 +++-------- tox.ini | 26 ---------------- 6 files changed, 57 insertions(+), 72 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5023169ef..34001bf7f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ on: jobs: lint: name: Lint - uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v21.0.0 + uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v23.0.4 unit-test: name: Unit test charm @@ -91,7 +91,7 @@ jobs: - tests/integration/sharding_tests/application - tests/integration/relation_tests/new_relations/application-charm name: Build charm - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v21.0.0 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v23.0.4 with: path-to-charm-directory: ${{ matrix.path }} cache: true @@ -112,7 +112,7 @@ jobs: - lint - unit-test - build - uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v21.0.0 + uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v23.0.4 with: artifact-prefix: packed-charm-cache-true cloud: lxd diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 686a3f6c3..9bb208ea5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,14 +14,14 @@ jobs: build: name: Build charm - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v21.0.0 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v23.0.4 release-charm: name: Release charm needs: - ci-tests - build - uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v21.0.0 + uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v23.0.4 with: channel: 6/edge artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} diff --git a/charmcraft.yaml b/charmcraft.yaml index 749048191..520689021 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -3,31 +3,49 @@ 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 + # 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}")' + + 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_internal_version"); file.write_text(f"{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 + - charm_internal_version + - workload_version + charm: build-snaps: - rustup build-packages: - - build-essential - libffi-dev - libssl-dev - pkg-config - - rustc - - cargo - version_data: - plugin: dump - source: . - prime: - - charm_version - - charm_internal_version - - workload_version + 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 + charm-strict-dependencies: true + charm-requirements: [requirements.txt] diff --git a/poetry.lock b/poetry.lock index cb2f73bbe..36c4d14ca 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "allure-pytest" @@ -31,8 +31,8 @@ pytest = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v21.0.0" -resolved_reference = "c0eccd0a2229ce88cd09765d8260e22e12db0b13" +reference = "v23.0.4" +resolved_reference = "60f088b7f0f967a8e35d45339f5123a6e74786f7" subdirectory = "python/pytest_plugins/allure_pytest_collection_report" [[package]] @@ -1712,8 +1712,8 @@ develop = false [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v21.0.0" -resolved_reference = "c0eccd0a2229ce88cd09765d8260e22e12db0b13" +reference = "v23.0.4" +resolved_reference = "60f088b7f0f967a8e35d45339f5123a6e74786f7" subdirectory = "python/pytest_plugins/github_secrets" [[package]] @@ -1767,8 +1767,8 @@ pyyaml = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v21.0.0" -resolved_reference = "c0eccd0a2229ce88cd09765d8260e22e12db0b13" +reference = "v23.0.4" +resolved_reference = "60f088b7f0f967a8e35d45339f5123a6e74786f7" subdirectory = "python/pytest_plugins/pytest_operator_cache" [[package]] @@ -1786,8 +1786,8 @@ pytest = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v21.0.0" -resolved_reference = "c0eccd0a2229ce88cd09765d8260e22e12db0b13" +reference = "v23.0.4" +resolved_reference = "60f088b7f0f967a8e35d45339f5123a6e74786f7" subdirectory = "python/pytest_plugins/pytest_operator_groups" [[package]] @@ -2352,4 +2352,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.10.12" -content-hash = "cf3b3442797e8f7ff73e587135c06ee94c67c9fcb968b25dc5c7b4b8a2704ad6" +content-hash = "21ea7d726ba5b7dc700dbc55e6cb4f5a65909bd271cada2373a71eefab823c3f" diff --git a/pyproject.toml b/pyproject.toml index 6ee9af179..35d83f774 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,5 @@ [tool.poetry] -name = "mongodb" -version = "0.0.1" -description = "" -license = "Apache-2.0" -authors = [] -readme = "README.md" -homepage = "https://charmhub.io/mongodb?channel=6/edge" -repository = "https://github.com/canonical/mongodb-operator" +package-mode = false [tool.poetry.dependencies] python = "^3.10.12" @@ -70,10 +63,10 @@ pytest = "^8.1.1" pytest-asyncio = "^0.21.1" pytest-mock = "^3.14.0" pytest-operator = "^0.36.0" -pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"} -pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"} -pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.0", subdirectory = "python/pytest_plugins/github_secrets"} -allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.0", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"} +pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v23.0.4", subdirectory = "python/pytest_plugins/pytest_operator_cache"} +pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v23.0.4", subdirectory = "python/pytest_plugins/pytest_operator_groups"} +pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v23.0.4", subdirectory = "python/pytest_plugins/github_secrets"} +allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v23.0.4", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"} [build-system] requires = ["poetry-core>=1.9.0"] diff --git a/tox.ini b/tox.ini index d23137996..511ceb284 100644 --- a/tox.ini +++ b/tox.ini @@ -20,27 +20,6 @@ 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_internal_version"); file.write_text(f"{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 - rm charm_internal_version - - [testenv:format] description = Apply coding style standards to code commands_pre = @@ -93,15 +72,10 @@ 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