From be08480e77284e72a43491cfb40ecccdcfc8143a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Juli=C3=A1n=20Espina?= Date: Thu, 12 Dec 2024 17:31:08 -0600 Subject: [PATCH 1/2] ci: add ci workflows --- .github/ISSUE_TEMPLATE/bug_report.yaml | 70 ++++++++++++++++ .github/workflows/ci.yaml | 110 +++++++++++++++++++++++++ justfile | 2 +- src/charm.py | 2 +- tests/integration/test_charm.py | 8 +- 5 files changed, 189 insertions(+), 3 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yaml create mode 100644 .github/workflows/ci.yaml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..1c5b04d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,70 @@ +# Copyright 2024 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Bug Report +description: File a bug report +labels: ["Type: Bug", "Status: Triage"] +body: + - type: markdown + attributes: + value: > + Thanks for taking the time to fill out this bug report! Before submitting your issue, please make + sure you are using the latest version of the charm. If not, please switch to the latest version of this charm + before posting your report to make sure it's not already solved. + - type: textarea + id: bug-description + attributes: + label: Bug Description + description: > + Provide a description of the issue you are facing. If applicable, add screenshots to help explain the problem. + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: To Reproduce + description: > + Please provide a step-by-step instruction of how to reproduce the behaviour. + placeholder: | + 1. `juju deploy ...` + 2. `juju integrate ...` + 3. `juju status --integrations` + validations: + required: true + - type: textarea + id: environment + attributes: + label: Environment + description: > + We need to know a bit more about the context in which you run the charm. + - Are you running Juju locally, on lxd, in multipass or on some other platform? + - What track and channel you deployed the charm from (ie. `latest/edge` or similar). + - Version of any applicable components, like the juju snap, the model controller, lxd, microk8s, and/or multipass. + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: > + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + Fetch the logs using `juju debug-log --replay`. Additional details on how to retrieve logs are available in the juju + documentation at https://juju.is/docs/juju/log. + render: shell + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: Additional context diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..3e3ec5b --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,110 @@ +# Copyright 2024 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: filesystem-client tests +on: + workflow_call: + pull_request: + branches: + - main + +jobs: + inclusive-naming-check: + name: Inclusive naming check + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run tests + uses: get-woke/woke-action@v0 + with: + fail-on-error: true + + lint: + name: Lint + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Just + uses: extractions/setup-just@v2 + with: + just-version: 1.38.0 + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "0.5.8" + - name: Run linters + run: just lint + + unit-test: + name: Unit tests + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Just + uses: extractions/setup-just@v2 + with: + just-version: 1.38.0 + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: 0.5.8 + - name: Run unit tests + run: just unit + + type-check: + name: Static type checking + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Just + uses: extractions/setup-just@v2 + with: + just-version: 1.38.0 + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: 0.5.8 + - name: Run tests + run: just type + + integration-test: + name: Integration tests (LXD) + runs-on: ubuntu-24.04 + needs: + - inclusive-naming-check + - lint + - unit-test + - type-check + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Just + uses: extractions/setup-just@v2 + with: + just-version: 1.38.0 + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: 0.5.8 + - name: Setup operator environment + uses: charmed-kubernetes/actions-operator@main + with: + provider: lxd + juju-channel: 3.4/stable + - name: Run tests + run: just integration \ No newline at end of file diff --git a/justfile b/justfile index 633fb7f..5061b8b 100644 --- a/justfile +++ b/justfile @@ -39,7 +39,7 @@ lint: lock {{uv_run}} ruff format --check --diff {{all}} # Run static type checks -static *args: lock +type *args: lock {{uv_run}} pyright {{args}} # Run unit tests diff --git a/src/charm.py b/src/charm.py index c742c54..9bbe0de 100755 --- a/src/charm.py +++ b/src/charm.py @@ -129,7 +129,7 @@ def _mount_filesystems(self, config: dict[str, dict[str, str | bool]]): self.app.status = ops.BlockedStatus( f"Missing configuration for mount type `{fs_type}." ) - return + raise StopCharmError() options["uri"] = share.uri diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 5992f87..f71712c 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -6,6 +6,7 @@ import logging from pathlib import Path +import juju import pytest import yaml from charms.filesystem_client.v0.interfaces import CephfsInfo, NfsInfo @@ -44,7 +45,12 @@ async def test_build_and_deploy(ops_test: OpsTest): # Deploy the charm and wait for active/idle status await asyncio.gather( - ops_test.model.deploy("ubuntu", application_name="ubuntu", base="ubuntu@24.04"), + ops_test.model.deploy( + "ubuntu", + application_name="ubuntu", + base="ubuntu@24.04", + constraints=juju.constraints.parse("virt-type=virtual-machine"), + ), ops_test.model.deploy( charm, application_name=APP_NAME, From 2cdb002e572e54c2f269c741ad5dc63d26faa292 Mon Sep 17 00:00:00 2001 From: Jason Nucciarone <40342202+NucciTheBoss@users.noreply.github.com> Date: Fri, 13 Dec 2024 12:21:10 -0500 Subject: [PATCH 2/2] fix(ci): add newline to end of workflow file --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3e3ec5b..6f5942a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -107,4 +107,4 @@ jobs: provider: lxd juju-channel: 3.4/stable - name: Run tests - run: just integration \ No newline at end of file + run: just integration