Skip to content

Commit 385e8da

Browse files
committed
Using charmcraft, build for jammy and focal
Signed-off-by: Adam Dyess <adam.dyess@canonical.com>
1 parent ccc55c4 commit 385e8da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+228
-57
lines changed

.charmcraft-channel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.x/stable

.github/workflows/charm-build.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
charmcraft-build:
10+
name: Build Charm
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v4
15+
- name: Read charmcraft version file
16+
id: charmcraft
17+
run: echo "channel=$(cat .charmcraft-channel)" >> $GITHUB_OUTPUT
18+
- name: Install and prepare LXD snap environment
19+
run: |
20+
sudo apt-get remove -qy lxd lxd-client | true
21+
sudo snap list lxd | true
22+
sudo snap install lxd --channel=latest/stable
23+
sudo snap refresh lxd --channel=latest/stable
24+
sudo lxd waitready
25+
sudo lxd init --auto
26+
sudo chmod a+wr /var/snap/lxd/common/lxd/unix.socket
27+
sudo lxc network set lxdbr0 ipv6.address none
28+
sudo usermod -a -G lxd $USER
29+
sg lxd -c 'lxc version'
30+
- name: Remove Docker
31+
run: |
32+
# https://github.com/canonical/lxd-cloud/blob/f20a64a8af42485440dcbfd370faf14137d2f349/test/includes/lxd.sh#L13-L23
33+
sudo rm -rf /etc/docker
34+
sudo apt-get purge moby-buildx moby-engine moby-cli moby-compose moby-containerd moby-runc -y
35+
sudo iptables -P FORWARD ACCEPT
36+
- name: Install Charmcraft
37+
run: |
38+
sudo snap install charmcraft --classic --channel=${{ steps.charmcraft.outputs.channel }}
39+
- name: Build Charm
40+
run: |
41+
sg lxd -c 'charmcraft pack -v'
42+
- name: Upload charm artifact
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: aws-integrator.charm
46+
path: ./aws-integrator*.charm
47+
- name: Upload debug artifacts
48+
if: ${{ failure() }}
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: charmcraft-logs
52+
path: ~/.local/state/charmcraft/log/charmcraft-*.log

.github/workflows/tox.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Run tests with Tox
22

3-
on: [pull_request]
3+
on:
4+
- pull_request
45

56
jobs:
67
call-inclusive-naming-check:
@@ -13,4 +14,6 @@ jobs:
1314
name: Lint Unit
1415
uses: charmed-kubernetes/workflows/.github/workflows/lint-unit.yaml@main
1516
needs:
16-
- call-inclusive-naming-check
17+
- call-inclusive-naming-check
18+
with:
19+
python: "['3.10', '3.12']"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Charmed Kubernetes Reactive wheelhouse test
2+
on:
3+
- pull_request
4+
5+
jobs:
6+
validate-wheelhouse:
7+
uses: charmed-kubernetes/workflows/.github/workflows/validate-wheelhouse.yaml@main
8+
with:
9+
python: "['3.10', '3.12']"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.tox/
22
__pycache__/
33
*.pyc
4+
.coverage
5+
*.charm

charmcraft.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
type: charm
2+
3+
bases:
4+
- build-on:
5+
- name: ubuntu
6+
channel: "22.04"
7+
architectures: ["amd64"]
8+
run-on:
9+
- name: ubuntu
10+
channel: "22.04"
11+
architectures: ["amd64", "arm64", "s390x"]
12+
- name: ubuntu
13+
channel: "24.04"
14+
architectures: ["amd64", "arm64", "s390x"]
15+
parts:
16+
charm:
17+
source: src
18+
plugin: reactive
19+
override-build: |
20+
./download_layers.sh
21+
git -C $CRAFT_PROJECT_DIR rev-parse --short HEAD > $CRAFT_PART_INSTALL/version
22+
craftctl default
23+
reactive-charm-build-arguments:
24+
- --layer-index
25+
- 'http://localhost/' # Fake layer index to force a local build
26+
- --debug
27+
- --force
28+
build-packages:
29+
- git
30+
- wget
31+
- python3-dev
32+
build-snaps:
33+
- charm/3.x/stable
34+
- yq
35+
build-environment:
36+
- CHARM_LAYERS_DIR: $CRAFT_STAGE/tmp/layers/
37+
- CHARM_INTERFACES_DIR: $CRAFT_STAGE/tmp/interfaces/
38+
- RELEASE_BRANCH: main

metadata.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.

metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/metadata.yaml

LICENSE renamed to src/LICENSE

File renamed without changes.

README.md renamed to src/README.md

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

copyright renamed to src/copyright

File renamed without changes.

src/download_layers.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
# This script is used to download reactive layers for the charm build process.
3+
# It pulls the layers from the gh and place them in the tmp directory.
4+
set -eu
5+
6+
# ensure we have environment variables set
7+
: "${RELEASE_BRANCH:?Environment variable RELEASE_BRANCH is not set.}"
8+
: "${CHARM_LAYERS_DIR:?Environment variable CHARM_LAYERS_DIR is not set.}"
9+
: "${CHARM_INTERFACES_DIR:?Environment variable CHARM_INTERFACES_DIR is not set.}"
10+
11+
# Ensure the temporary directory was created successfully
12+
TMP_DIR=$(mktemp -d)
13+
if [ ! -d "$TMP_DIR" ]; then
14+
echo "Failed to create a temporary directory."
15+
exit 1
16+
fi
17+
trap 'rm -rf "$TMP_DIR"' EXIT
18+
19+
# ensure we have the right prerequisites
20+
for cmd in charm wget yq; do
21+
if ! command -v $cmd &> /dev/null; then
22+
echo "$cmd command not found. Please install $cmd."
23+
exit 1
24+
fi
25+
done
26+
27+
rm -rf $CHARM_LAYERS_DIR && mkdir -p $CHARM_LAYERS_DIR
28+
rm -rf $CHARM_INTERFACES_DIR && mkdir -p $CHARM_INTERFACES_DIR
29+
wget "https://raw.githubusercontent.com/charmed-kubernetes/jenkins/refs/heads/main/jobs/includes/charm-layer-list.inc" -O ${TMP_DIR}/layers.yaml
30+
for layer in $(cat ${TMP_DIR}/layers.yaml | yq '.[] | keys | .[]' - ); do
31+
if [[ ! "$layer" =~ ^(interface:|layer:) ]]; then continue; fi
32+
echo "Pulling layer: ${layer}"
33+
charm pull-source \
34+
--layer-index ${LAYER_INDEX:-'https://raw.githubusercontent.com/charmed-kubernetes/layer-index/main/'} \
35+
--branch ${RELEASE_BRANCH} \
36+
${layer} &
37+
done
38+
wait
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

icon.svg renamed to src/icon.svg

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/metadata.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: aws-integrator
2+
display-name: AWS-Integrator
3+
summary: |
4+
Charm to enable AWS integrations via Juju relations.
5+
description: |
6+
This charm can grant select permissions to instances of applications
7+
related to it which enable integration with AWS specific features,
8+
such as ELB, EBS, etc.
9+
docs: https://discourse.charmhub.io/t/aws-integrator-docs-index/6100
10+
maintainers: ['Cory Johns <cory.johns@canonical.com>']
11+
series:
12+
- jammy
13+
- noble
14+
tags: ['aws', 'native', 'integration']
15+
provides:
16+
aws:
17+
interface: aws-integration
18+
rds-mysql:
19+
interface: mysql
20+
resources:
21+
aws-cli:
22+
type: file
23+
filename: aws-cli.snap
24+
description: |
25+
Resource to side-load aws-cli snap in network-restricted deployments.
26+
[DEPRECATED] in favor of using a Snap Store Proxy.
27+
See https://ubuntu.com/kubernetes/docs/proxies for more details.
File renamed without changes.

src/wheelhouse.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setuptools==70.3.0

terraform/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ variable "base" {
1313
default = "ubuntu@22.04"
1414

1515
validation {
16-
condition = contains(["ubuntu@20.04", "ubuntu@22.04"], var.base)
17-
error_message = "Base must be one of ubuntu@20.04, ubuntu@22.04"
16+
condition = contains(["ubuntu@22.04", "ubuntu@24.04"], var.base)
17+
error_message = "Base must be one of ubuntu@22.04, ubuntu@24.04"
1818
}
1919
}
2020

2121
variable "channel" {
2222
description = "The channel to use when deploying a charm."
2323
type = string
24-
default = "1.31/stable"
24+
default = "latest/stable"
2525
}
2626

2727
variable "config" {

tests/validate-wheelhouse.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -eux
3+
4+
build_dir="$(mktemp -d --tmpdir=${TOX_ENV_DIR}/tmp)"
5+
charm="$(egrep '^name\S*:' ./metadata.yaml | awk '{ print $2 }')"
6+
function cleanup { rm -rf "$build_dir"; }
7+
trap cleanup EXIT
8+
9+
charm-build src --build-dir "$build_dir" --debug
10+
pip install -f "$build_dir/$charm/wheelhouse" --no-index --no-cache-dir "$build_dir"/$charm/wheelhouse/*

tox.ini

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,64 @@
1+
[flake8]
2+
max-line-length = 88
3+
ignore =
4+
# line break before binary operator
5+
W503
6+
# whitespace before ':'
7+
E203
8+
19
[tox]
10+
envlist = lint,unit
211
skipsdist = True
12+
minversion = 3.2.0
13+
14+
[pytest]
15+
filterwarnings =
16+
ignore::DeprecationWarning
317

418
[testenv]
519
basepython = python3
620
setenv =
7-
PYTHONPATH={toxinidir}:{toxinidir}/lib
21+
PYTHONPATH={toxinidir}/src:{toxinidir}/src/lib
822
PYTHONBREAKPOINT=ipdb.set_trace
923

1024
[testenv:unit]
1125
deps =
12-
pytest
26+
pyyaml
27+
pytest-cov
1328
ipdb
1429
git+https://github.com/juju-solutions/charms.unit_test/#egg=charms.unit_test
15-
commands = pytest --tb native -s {posargs} {toxinidir}/tests/unit
16-
17-
[testenv:integration]
18-
deps =
19-
pytest
20-
pytest-operator
21-
lightkube
30+
python-openstackclient
31+
-r src/wheelhouse.txt
2232
commands =
23-
pytest --tb native \
24-
--asyncio-mode=auto \
25-
--show-capture=no \
26-
--log-cli-level=INFO \
27-
-s {posargs} \
28-
{toxinidir}/tests/integration
29-
33+
pytest --tb native -s -vv \
34+
--cov-report term-missing --cov=src \
35+
{posargs} {toxinidir}/tests/unit
3036

3137
[testenv:lint]
3238
deps =
3339
flake8
3440
black
35-
commands =
36-
flake8 {toxinidir}/actions {toxinidir}/lib {toxinidir}/reactive {toxinidir}/tests
37-
black --check {toxinidir}/actions {toxinidir}/lib {toxinidir}/reactive {toxinidir}/tests
41+
commands =
42+
black --check {toxinidir}/src {toxinidir}/tests
43+
flake8 {toxinidir}/src {toxinidir}/tests
3844

3945
[testenv:format]
40-
envdir = {toxworkdir}/lint
4146
deps = black
42-
commands = black {toxinidir}/actions {toxinidir}/lib {toxinidir}/reactive {toxinidir}/tests
43-
47+
commands =
48+
black {toxinidir}/src {toxinidir}/tests
4449

45-
[flake8]
46-
max-line-length = 88
47-
extend-ignore = E203
50+
[testenv:integration]
51+
deps =
52+
juju
53+
pytest
54+
pytest-operator
55+
lightkube
56+
ipdb
57+
commands = pytest --tb native --show-capture=no --log-cli-level=INFO -s {posargs} {toxinidir}/tests/integration
4858

59+
[testenv:validate-wheelhouse]
60+
deps =
61+
git+https://github.com/juju/charm-tools.git
62+
path<17
63+
allowlist_externals = {toxinidir}/tests/validate-wheelhouse.sh
64+
commands = {toxinidir}/tests/validate-wheelhouse.sh

0 commit comments

Comments
 (0)