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
47 changes: 47 additions & 0 deletions .github/workflows/kepler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: kepler

on:
pull_request:
paths:
- .github/workflows/kepler.yaml
- kepler/**
workflow_dispatch:

permissions: {}

jobs:
pack-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Lint
working-directory: kepler
run: |
uvx --python 3.10 --with tox-uv tox -e lint
- name: Run unit tests
working-directory: kepler
run: |
uvx --python 3.10 --with tox-uv tox -e unit
- name: Set up Concierge
run: sudo snap install --classic concierge
- name: Set up Juju and charm development tools
run: sudo concierge prepare -p k8s
- name: Pack the charm
working-directory: kepler
run: charmcraft pack
- name: Run integration tests
working-directory: kepler
run: tox -e integration -- --juju-dump-logs logs
- name: Upload logs
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: juju-dump-logs
path: kepler/logs
47 changes: 47 additions & 0 deletions .github/workflows/kosmos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: kosmos

on:
pull_request:
paths:
- .github/workflows/kosmos.yaml
- kosmos/**
workflow_dispatch:

permissions: {}

jobs:
pack-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Lint
working-directory: kosmos
run: |
uvx --python 3.10 --with tox-uv tox -e lint
- name: Run unit tests
working-directory: kosmos
run: |
uvx --python 3.10 --with tox-uv tox -e unit
- name: Set up Concierge
run: sudo snap install --classic concierge
- name: Set up Juju and charm development tools
run: sudo concierge prepare -p k8s
- name: Pack the charm
working-directory: kosmos
run: charmcraft pack
- name: Run integration tests
working-directory: kosmos
run: tox -e integration -- --juju-dump-logs logs
- name: Upload logs
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: juju-dump-logs
path: kosmos/logs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
name: Charm with minimal use of Pydantic
name: meteor

on:
pull_request:
paths:
- .github/workflows/charm-pydantic-minimal.yaml
- charms/pydantic-minimal/**
- .github/workflows/meteor.yaml
- meteor/**
workflow_dispatch:

permissions: {}

jobs:
pack-and-test:
name: Test the charm
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -22,23 +21,27 @@ jobs:
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Lint and run unit tests
working-directory: charms/pydantic-minimal
- name: Lint
working-directory: meteor
run: |
uvx --python 3.10 --with tox-uv tox -e lint,unit
uvx --python 3.10 --with tox-uv tox -e lint
- name: Run unit tests
working-directory: meteor
run: |
uvx --python 3.10 --with tox-uv tox -e unit
- name: Set up Concierge
run: sudo snap install --classic concierge
- name: Set up Juju and charm development tools
run: sudo concierge prepare -p machine
- name: Pack the charm
working-directory: charms/pydantic-minimal
working-directory: meteor
run: charmcraft pack
- name: Run integration tests
working-directory: charms/pydantic-minimal
working-directory: meteor
run: tox -e integration -- --juju-dump-logs logs
- name: Upload logs
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: juju-dump-logs
path: charms/pydantic-minimal/logs
path: meteor/logs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Charmcraft main's machine profile
name: micron

on:
pull_request:
paths:
- .github/workflows/charmcraft-main-machine.yaml
- .github/workflows/micron.yaml
- micron/**
workflow_dispatch:

permissions: {}

jobs:
generate-and-test:
name: Test a generated charm
pack-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -19,33 +19,29 @@ jobs:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Generate a charm
run: |
mkdir -p charms/myapp-machine
uvx git+https://github.com/canonical/charmcraft init \
--profile machine \
--project-dir charms/myapp-machine \
--author Charmer
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Lock, lint, and run unit tests
working-directory: charms/myapp-machine
- name: Lint
working-directory: micron
run: |
uvx --python 3.10 --with tox-uv tox -e lint
- name: Run unit tests
working-directory: micron
run: |
uv lock
uvx --python 3.10 --with tox-uv tox -e lint,unit
uvx --python 3.10 --with tox-uv tox -e unit
- name: Set up Concierge
run: sudo snap install --classic concierge
- name: Set up Juju and charm development tools
run: sudo concierge prepare -p machine
- name: Pack the charm
working-directory: charms/myapp-machine
working-directory: micron
run: charmcraft pack
- name: Run integration tests
working-directory: charms/myapp-machine
working-directory: micron
run: tox -e integration -- --juju-dump-logs logs
- name: Upload logs
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: juju-dump-logs
path: charms/myapp-machine/logs
path: micron/logs
2 changes: 1 addition & 1 deletion .github/workflows/zizmor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Workflow checks
name: zizmor

on:
pull_request:
Expand Down
60 changes: 60 additions & 0 deletions kepler/charmcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This file configures Charmcraft.
# See https://documentation.ubuntu.com/charmcraft/stable/reference/files/charmcraft-yaml-file/
type: charm
name: kosmos
title: Web Server Demo
summary: A demo charm that operates a small Python FastAPI server.
description: |
This charm demonstrates how to write a Kubernetes charm with Ops.

# Documentation:
# https://documentation.ubuntu.com/charmcraft/stable/howto/build-guides/select-platforms/
base: ubuntu@24.04
platforms:
amd64:
arm64:

assumes:
- juju >= 3.6
- k8s-api

parts:
charm:
plugin: uv
source: .
build-snaps:
- astral-uv

# (Optional) Configuration options for the charm
# This config section defines charm config options, and populates the Configure
# tab on Charmhub.
# More information on this section at:
# https://documentation.ubuntu.com/charmcraft/stable/reference/files/charmcraft-yaml-file/#config
# General configuration documentation:
# https://documentation.ubuntu.com/juju/3.6/reference/configuration/#application-configuration
config:
options:
# An example config option to customise the log level of the workload
log-level:
description: |
Configures the log level of gunicorn.

Acceptable values are: "info", "debug", "warning", "error" and "critical"
default: "info"
type: string

containers:
demo-server:
resource: demo-server-image

resources:
# An OCI image resource for the container listed above.
demo-server-image:
type: oci-image
description: OCI image from GitHub Container Repository
# The upstream-source field is ignored by Charmcraft and Juju, but it can be
# useful to developers in identifying the source of the OCI image. It is also
# used by the 'canonical/charming-actions' GitHub action for automated releases.
# The test_deploy function in tests/integration/test_charm.py reads upstream-source
# to determine which OCI image to use when running the charm's integration tests.
upstream-source: ghcr.io/canonical/api_demo_server:1.0.4
91 changes: 91 additions & 0 deletions kepler/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright 2026 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.

[project]
name = "kosmos"
version = "0.0.1"
requires-python = ">=3.10"

# Dependencies of the charm code
# You should list the dependencies of the code in src/, including any charm libraries from PyPI.
# We recommend using uv to maintain this list. For example, 'uv add charmlibs-pathops'.
# If your code uses any libraries from Charmhub, don't list those libraries here. Instead, add a
# 'charm-libs' block in charmcraft.yaml, run `charmcraft fetch-libs` to download the libraries,
# then inspect the libraries for dependencies specified in PYDEPS. List those dependencies here.
dependencies = [
"ops~=3.7",
]

[dependency-groups]
# Dependencies of linting and static type checks
lint = [
"ruff",
"codespell",
"pyright",
]
# Dependencies of unit tests
unit = [
"coverage[toml]",
"ops[testing]",
"pytest",
]
# Dependencies of integration tests
integration = [
"jubilant>=1.8,<2",
"pytest",
"pytest-jubilant>=2.0.1,<3",
"PyYAML",
]

# Testing tools configuration
[tool.coverage.run]
branch = true

[tool.coverage.report]
show_missing = true

[tool.pytest.ini_options]
minversion = "6.0"
log_cli_level = "INFO"

# Linting tools configuration
[tool.ruff]
line-length = 99
lint.select = ["E", "W", "F", "C", "N", "D", "I001"]
lint.ignore = [
"D105",
"D107",
"D203",
"D204",
"D213",
"D215",
"D400",
"D404",
"D406",
"D407",
"D408",
"D409",
"D413",
]
lint.per-file-ignores = {"tests/*" = ["D100","D101","D102","D103","D104"]}
extend-exclude = ["__pycache__", "*.egg_info"]

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.codespell]
skip = "build,lib,venv,icon.svg,.tox,.git,.mypy_cache,.ruff_cache,.coverage"

[tool.pyright]
include = ["src", "tests"]
Loading
Loading