Skip to content
Draft
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
63 changes: 8 additions & 55 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,68 +80,21 @@ jobs:
cache-mode: none

build:
# The test charms can't use data-platform-workflows build_charm.yaml: scripts/build_charm.sh
# has to copy the library into them before packing
# The test charms install the library from the repository root (pyproject.toml path
# dependency); build_charm.yaml packs with charmcraft monorepo support to make it available
strategy:
fail-fast: false
matrix:
substrate:
- vm
- k8s
platform:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-26.04-arm
name: Build ${{ matrix.substrate }} test charm | ${{ matrix.platform.arch }}
runs-on: ${{ matrix.platform.runner }}
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
# Same set up as data-platform-workflows build_charm.yaml (v54.0.0)
- name: Set up environment
run: |
sudo snap install lxd
sudo adduser "$USER" lxd
newgrp lxd --command 'lxd waitready'
newgrp lxd --command 'lxd init --auto'
# Workaround for Docker & LXD on same machine
sudo iptables -F FORWARD
sudo iptables -P FORWARD ACCEPT

sudo snap install charmcraft --classic
pipx install poetry
pipx install charmcraftcache
- run: snap list
- name: Build test charm
id: pack
run: |
newgrp lxd --command \
'scripts/build_charm.sh \
-p "ubuntu@24.04:'"${VAR_ARCH}"'" \
-c "tests/charms/postgresql_'"${VAR_SUBSTRATE}"'_test_charm"'
env:
# Used by charmcraftcache (to avoid GitHub API rate limit)
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

VAR_SUBSTRATE: ${{ matrix.substrate }}
VAR_ARCH: ${{ matrix.platform.arch }}
CI_CACHE: true
- name: Charmcraft logs
if: ${{ success() || (failure() && steps.pack.outcome == 'failure') }}
run: cat ~/.local/state/charmcraft/log/*
- name: Upload test charm
uses: actions/upload-artifact@v7
with:
name: test-charm-${{ matrix.substrate }}-${{ matrix.platform.arch }}
path: tests/charms/postgresql_${{ matrix.substrate }}_test_charm/*.charm
if-no-files-found: error
outputs:
name: Build ${{ matrix.substrate }} test charm
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v56.0.0
with:
artifact-prefix: test-charm
permissions: {}
path-to-charm-directory: tests/charms/postgresql_${{ matrix.substrate }}_test_charm
permissions:
contents: read
cache-mode: none

integration-test:
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
description: |
Prefix for the test charm package GitHub artifacts

Built in ci.yaml with scripts/build_charm.sh: one artifact per substrate and
architecture (`<prefix>-vm-amd64`, `<prefix>-vm-arm64`, `<prefix>-k8s-amd64`, ...)
Built in ci.yaml with data-platform-workflows build_charm.yaml: one artifact per test
charm and platform (`<prefix>-tests-charms-postgresql_vm_test_charm--platform-ubuntu@24.04-amd64`, ...)
required: true
type: string
secrets:
Expand Down Expand Up @@ -152,10 +152,12 @@ jobs:
uses: actions/download-artifact@v8
with:
# All architectures: test_wrong_arch.py deploys the charm of the other architecture
pattern: ${{ inputs.artifact-prefix }}-${{ matrix.job.substrate }}-*
pattern: ${{ inputs.artifact-prefix }}-tests-charms-postgresql_${{ matrix.job.substrate }}_test_charm--platform-*
merge-multiple: true
# Where the `charm` fixture (tests/integration/charm/conftest.py) looks for it
path: tests/charms/postgresql_${{ matrix.job.substrate }}_test_charm/
# The artifacts keep the path from the repository root, so the charms land in
# tests/charms/postgresql_<substrate>_test_charm/, where the `charm` fixture
# (tests/integration/charm/conftest.py) looks for them
path: .
- name: Run spread job
timeout-minutes: 180
id: spread
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@ lint = [
unit = [
"coverage[toml]==7.16.2",
"pytest==9.1.1",
"pytest-asyncio==0.21.2",
]
integration = [
"pytest==9.1.1",
"pytest-operator==0.43.2",
"juju==3.6.1.3",
"jubilant==1.14.0",
"kubernetes==30.1.0",
"allure-pytest==2.16.2",
"allure-pytest-default-results==0.1.4",
"tomli-w==1.2.0",
Expand All @@ -104,7 +102,7 @@ show_missing = true
[tool.pytest.ini_options]
minversion = "6.0"
log_cli_level = "INFO"
asyncio_mode = "auto"
addopts = "--exitfirst"

# Linting tools configuration
[tool.ruff]
Expand Down
126 changes: 0 additions & 126 deletions scripts/build_charm.sh

This file was deleted.

2 changes: 1 addition & 1 deletion spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project: postgresql-single-kernel-library

# Integration tests of the VM and K8s test charms (tests/charms/), run on GitHub Actions.
# Each task runs on both backends: github-ci-vm (lxd) and github-ci-k8s (Canonical K8s).
# The test charms are built beforehand (scripts/build_charm.sh) and downloaded into
# The test charms are built beforehand (data-platform-workflows build_charm.yaml) and downloaded into
# tests/charms/<charm>/ by .github/workflows/integration_test.yaml.
backends:
github-ci-vm:
Expand Down
6 changes: 5 additions & 1 deletion tests/charms/postgresql_k8s_test_charm/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ parts:
# (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: .
# Repository root, so the library (path dependency in pyproject.toml) is available.
# Needs CHARMCRAFT_EXPERIMENTAL_MONOREPO=1
# (https://canonical.com/juju/docs/charmcraft/latest/howto/pack-a-charm-in-a-monorepo/)
source: ../../..
source-subdir: tests/charms/postgresql_k8s_test_charm
after:
- poetry-deps
poetry-export-extra-args: ['--only', 'main,charm-libs', "--without-hashes"] # For the library build locally
Expand Down
29 changes: 26 additions & 3 deletions tests/charms/postgresql_k8s_test_charm/poetry.lock

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

2 changes: 2 additions & 0 deletions tests/charms/postgresql_k8s_test_charm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ charmlibs-interfaces-tls-certificates = "^1.12.0"
charm-refresh = "^3.1.1.2"
charmlibs-pathops = "^1.3.0"
data-platform-helpers = "^1.1.1"
# The library from the root of this repository (packed with charmcraft monorepo support)
postgresql-charms-single-kernel = {path = "../../..", develop = false}

[tool.poetry.group.charm-libs.dependencies]
# data_platform_libs/v0/data_interfaces.py
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
charm_major = 1
charm = "test/0.0.0+dirty"
workload = "16.15"
6 changes: 5 additions & 1 deletion tests/charms/postgresql_vm_test_charm/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ parts:
# (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: .
# Repository root, so the library (path dependency in pyproject.toml) is available.
# Needs CHARMCRAFT_EXPERIMENTAL_MONOREPO=1
# (https://canonical.com/juju/docs/charmcraft/latest/howto/pack-a-charm-in-a-monorepo/)
source: ../../..
source-subdir: tests/charms/postgresql_vm_test_charm
after:
- poetry-deps
poetry-export-extra-args: ['--only', 'main,charm-libs', "--without-hashes"] # For the library build locally
Expand Down
25 changes: 24 additions & 1 deletion tests/charms/postgresql_vm_test_charm/poetry.lock

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

2 changes: 2 additions & 0 deletions tests/charms/postgresql_vm_test_charm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ charmlibs-systemd = "^1.0.0.post0"
charmlibs-interfaces-tls-certificates = "^1.12.0"
charmlibs-pathops = "^1.3.0"
data-platform-helpers = "^1.1.1"
# The library from the root of this repository (packed with charmcraft monorepo support)
postgresql-charms-single-kernel = {path = "../../..", develop = false}

[tool.poetry.group.charm-libs.dependencies]
# data_platform_libs/v0/data_interfaces.py
Expand Down
Loading
Loading