Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:
on:
pull_request:
schedule:
- cron: '53 0 * * *' # Daily at 00:53 UTC
- cron: "53 0 * * *" # Daily at 00:53 UTC
# Triggered on push to branch "main" by .github/workflows/release.yaml
workflow_call:
outputs:
Expand All @@ -20,7 +20,7 @@ on:
jobs:
lint:
name: Lint
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v29.0.0
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v35.0.4

terraform-test:
name: Terraform - Validation and replica-set product
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
path:
- .
name: Build charm | ${{ matrix.path }}
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v29.0.0
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v35.0.4
with:
path-to-charm-directory: ${{ matrix.path }}
cache: false
Expand All @@ -138,11 +138,11 @@ jobs:
needs:
- lint
- build
uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v29.0.0
uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v35.0.4
with:
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
cloud: lxd
juju-agent-version: 3.6.1 # renovate: juju-agent-pin-minor
juju-agent-version: 3.6.1 # renovate: juju-agent-pin-minor
_beta_allure_report: true
permissions:
contents: write # Needed for Allure Report beta
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ jobs:
uses: ./.github/workflows/ci.yaml
secrets: inherit
permissions:
contents: write # Needed for Allure Report beta
contents: write # Needed for Allure Report beta

release:
name: Release charm
needs:
- ci-tests
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v29.0.0
uses: canonical/data-platform-workflows/.github/workflows/release_charm_edge.yaml@v35.0.4
with:
channel: 8-transition/edge
track: 8-transition/edge
artifact-prefix: ${{ needs.ci-tests.outputs.artifact-prefix }}
secrets:
charmhub-token: ${{ secrets.CHARMHUB_TOKEN }}
permissions:
contents: write # Needed to create git tags
contents: write # Needed to create git tags

release-libraries:
name: Release libraries
Expand Down
1 change: 1 addition & 0 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
type: charm
platforms:
ubuntu@24.04:amd64:
ubuntu@24.04:arm64:
# Files implicitly created by charmcraft without a part:
# - dispatch (https://github.com/canonical/charmcraft/pull/1898)
# - manifest.yaml
Expand Down
44 changes: 22 additions & 22 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ poetry-core = "^2.0"
data-platform-helpers = "^0.1.3"
rpds-py = "0.18.0"
pyOpenSSL = "^24.2.1"
mongo-charms-single-kernel = "1.7.14"
mongo-charms-single-kernel = "1.7.15"

[tool.poetry.group.charm-libs.dependencies]
ops = ">=2.21"
Expand Down Expand Up @@ -57,10 +57,10 @@ pytest = "^8.1.1"
pytest-asyncio = "^0.21.1"
pytest-mock = "^3.14.0"
pytest-operator = "^0.36.0"
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v29.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v29.0.0", subdirectory = "python/pytest_plugins/github_secrets"}
allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v29.0.0", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"}
mongo-charms-single-kernel = "1.7.14"
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v35.0.4", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v35.0.4", subdirectory = "python/pytest_plugins/github_secrets"}
allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v35.0.4", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"}
mongo-charms-single-kernel = "1.7.15"

[build-system]
build-backend = "poetry.core.masonry.api"
Expand Down
52 changes: 37 additions & 15 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,47 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

import json
import os
from pathlib import Path
import pathlib
import subprocess

from pytest_operator.plugin import OpsTest


def ops_test(ops_test: OpsTest) -> OpsTest:
def pytest_configure(config) -> None:
if os.environ.get("CI") == "true":
# Running in GitHub Actions; skip build step
# (GitHub Actions uses a separate, cached build step. See .github/workflows/ci.yaml)
packed_charms = json.loads(os.environ["CI_PACKED_CHARMS"])
plugin = config.pluginmanager.get_plugin("pytest-operator")
plugin.OpsTest.build_charm = _build_charm

# Remove charmcraft dependency from `ops_test` fixture
check_deps = plugin.check_deps
plugin.check_deps = lambda *deps: check_deps(*(dep for dep in deps if dep != "charmcraft"))

async def build_charm(charm_path, bases_index: int = None) -> Path:
for charm in packed_charms:
if Path(charm_path) == Path(charm["directory_path"]):
if bases_index is None or bases_index == charm["bases_index"]:
return charm["file_path"]
raise ValueError(f"Unable to find .charm file for {bases_index=} at {charm_path=}")

ops_test.build_charm = build_charm
return ops_test
async def _build_charm(self, charm_path: str | os.PathLike) -> pathlib.Path:
charm_path = pathlib.Path(charm_path)
architecture = subprocess.run(
["dpkg", "--print-architecture"],
capture_output=True,
check=True,
encoding="utf-8",
).stdout.strip()
assert architecture in ("amd64", "arm64")
packed_charms = list(charm_path.glob(f"*{architecture}.charm"))
if len(packed_charms) == 1:
# python-libjuju's model.deploy(), juju deploy, and juju bundle files expect local charms
# to begin with `./` or `/` to distinguish them from Charmhub charms.
# Therefore, we need to return an absolute path—a relative `pathlib.Path` does not start
# with `./` when cast to a str.
# (python-libjuju model.deploy() expects a str but will cast any input to a str as a
# workaround for pytest-operator's non-compliant `build_charm` return type of
# `pathlib.Path`.)
return packed_charms[0].resolve(strict=True)
elif len(packed_charms) > 1:
raise ValueError(
f"More than one matching .charm file found at {charm_path=} for {architecture=} and "
f"Ubuntu 24.04: {packed_charms}."
)
else:
raise ValueError(
f"Unable to find .charm file for {architecture=} and Ubuntu 24.04 at {charm_path=}"
)
2 changes: 0 additions & 2 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
MEDIAN_REELECTION_TIME = 12


@pytest.mark.runner(["self-hosted", "linux", "X64", "jammy", "large"])
@pytest.mark.group(1)
@pytest.mark.skipif(
os.environ.get("PYTEST_SKIP_DEPLOY", False),
Expand All @@ -43,7 +42,6 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await ops_test.model.wait_for_idle(timeout=DEPLOYMENT_TIMEOUT, status="active")


@pytest.mark.runner(["self-hosted", "linux", "X64", "jammy", "large"])
@pytest.mark.group(1)
@pytest.mark.abort_on_fail
@pytest.mark.parametrize("unit_id", UNIT_IDS)
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/test_sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
TIMEOUT = 30 * 60


@pytest.mark.runner(["self-hosted", "linux", "X64", "jammy", "large"])
@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test: OpsTest) -> None:
Expand Down Expand Up @@ -81,7 +80,6 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await wait_for_mongodb_units_blocked(ops_test, SHARD_THREE_APP_NAME, timeout=300)


@pytest.mark.runner(["self-hosted", "linux", "X64", "jammy", "large"])
@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_cluster_active(ops_test: OpsTest) -> None:
Expand Down
Loading