Migrate percona-cluster to charmcraft build

- add *.charm  to .gitignore
- add build-requirements.txt
- add charmcraft.yaml (build on 18.04, run on 18.04)
- modify osci.yaml to do build
- add rename.sh to clean-up naming of charms
- modify bundles to work with *.charm and use the charmhub
- modify tox.ini to include the build target

Note that this charm doesn't officially support xenial, but the bundle
has been left in the tests for debugging/test purposes.  It Launchpad it
will be build on bionic to run on bionic.

This patch adds *.charm to the .gitignore to ensure that any built
artifacts are ignored.

Change-Id: Icd4942262a8dfcd3a194684571861121d92f8ed2
This commit is contained in:
Alex Kavanagh 2022-04-18 20:59:55 +01:00 committed by Billy Olsen
parent 6ff8acbd6a
commit 6751832bb6
10 changed files with 91 additions and 25 deletions

3
.gitignore vendored
View File

@ -11,3 +11,6 @@ __pycache__
.stestr .stestr
.unit-state.db .unit-state.db
func-results.json func-results.json
*.charm

7
build-requirements.txt Normal file
View File

@ -0,0 +1,7 @@
# NOTES(lourot):
# * We don't install charmcraft via pip anymore because it anyway spins up a
# container and scp the system's charmcraft snap inside it. So the charmcraft
# snap is necessary on the system anyway.
# * `tox -e build` successfully validated with charmcraft 1.2.1
cffi==1.14.6; python_version < '3.6' # cffi 1.15.0 drops support for py35.

33
charmcraft.yaml Normal file
View File

@ -0,0 +1,33 @@
type: charm
parts:
charm:
plugin: dump
source: .
prime:
- actions/*
- charmhelpers/*
- files/*
- hooks/*
- lib/*
- ocf/*
- scripts/*
- templates/*
- actions.yaml
- config.yaml
- copyright
- hardening.yaml
- Makefile
- metadata.yaml
- README.md
bases:
- build-on:
- name: ubuntu
channel: "18.04"
architectures:
- amd64
run-on:
- name: ubuntu
channel: "18.04"
architectures: [amd64, s390x, ppc64el, arm64]

View File

@ -1,9 +1,13 @@
- project: - project:
templates: templates:
- charm-yoga-unit-jobs - charm-unit-jobs-py36
check: check:
jobs: jobs:
- bionic_model-bionic-ha - bionic_model-bionic-ha
vars:
needs_charm_build: true
charm_build_name: percona-cluster
build_type: charmcraft
- job: - job:
name: bionic_model-bionic-ha name: bionic_model-bionic-ha
@ -11,7 +15,5 @@
dependencies: dependencies:
- osci-lint - osci-lint
- tox-py36 - tox-py36
- tox-py38
- tox-py39
vars: vars:
tox_extra_args: bionic_model:bionic-ha tox_extra_args: bionic_model:bionic-ha

13
rename.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
charm=$(grep "charm_build_name" osci.yaml | awk '{print $2}')
echo "renaming ${charm}_*.charm to ${charm}.charm"
echo -n "pwd: "
pwd
ls -al
echo "Removing bad downloaded charm maybe?"
if [[ -e "${charm}.charm" ]];
then
rm "${charm}.charm"
fi
echo "Renaming charm here."
mv ${charm}_*.charm ${charm}.charm

View File

@ -3,19 +3,20 @@ series: bionic
applications: applications:
percona-cluster: percona-cluster:
series: bionic series: bionic
charm: ../../../percona-cluster charm: ../../percona-cluster.charm
num_units: 1 num_units: 1
keystone: keystone:
charm: cs:~openstack-charmers-next/keystone charm: ch:keystone
channel: queens/edge
num_units: 1 num_units: 1
options: options:
token-expiration: 60 token-expiration: 60
nagios: nagios:
charm: cs:nagios charm: ch:nagios
series: bionic series: bionic
num_units: 1 num_units: 1
nrpe: nrpe:
charm: cs:nrpe charm: ch:nrpe
relations: relations:
- - keystone:shared-db - - keystone:shared-db

View File

@ -5,10 +5,11 @@ relations:
applications: applications:
percona-cluster: percona-cluster:
series: bionic series: bionic
charm: ../../../percona-cluster charm: ../../percona-cluster.charm
num_units: 1 num_units: 1
keystone: keystone:
charm: cs:~openstack-charmers-next/keystone charm: ch:keystone
channel: queens/edge
num_units: 1 num_units: 1
options: options:
token-expiration: 60 token-expiration: 60

View File

@ -9,7 +9,8 @@ applications:
vip: {{ TEST_VIP00 }} vip: {{ TEST_VIP00 }}
min-cluster-size: 3 min-cluster-size: 3
hacluster: hacluster:
charm: cs:~openstack-charmers-next/hacluster charm: ch:hacluster
channel: 1.1.18/edge
num_units: 0 num_units: 0
options: options:
cluster_count: 3 cluster_count: 3

View File

@ -5,10 +5,12 @@ relations:
applications: applications:
percona-cluster: percona-cluster:
series: xenial series: xenial
charm: ../../../percona-cluster charm: ../../percona-cluster.charm
num_units: 1 num_units: 1
keystone: keystone:
charm: cs:~openstack-charmers-next/keystone charm: ch:keystone
channel: queens/edge
series: xenial
num_units: 1 num_units: 1
options: options:
openstack-origin: cloud:xenial-queens openstack-origin: cloud:xenial-queens

29
tox.ini
View File

@ -37,12 +37,22 @@ setenv = VIRTUAL_ENV={envdir}
install_command = install_command =
{toxinidir}/pip.sh install {opts} {packages} {toxinidir}/pip.sh install {opts} {packages}
commands = stestr run --slowest {posargs} commands = stestr run --slowest {posargs}
allowlist_externals = juju allowlist_externals =
charmcraft
rename.sh
passenv = HOME TERM CS_* OS_* TEST_* passenv = HOME TERM CS_* OS_* TEST_*
deps = -r{toxinidir}/test-requirements.txt deps = -r{toxinidir}/test-requirements.txt
[testenv:py35] [testenv:build]
basepython = python3.5 basepython = python3
deps = -r{toxinidir}/build-requirements.txt
commands =
charmcraft clean
charmcraft -v build
{toxinidir}/rename.sh
[testenv:py3]
basepython = python3
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
@ -50,26 +60,19 @@ deps = -r{toxinidir}/requirements.txt
basepython = python3.6 basepython = python3.6
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs}
[testenv:py37]
basepython = python3.7
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:py38] [testenv:py38]
basepython = python3.8 basepython = python3.8
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs}
[testenv:py39] [testenv:py39]
basepython = python3.9 basepython = python3.9
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs}
[testenv:py3]
basepython = python3
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:pep8] [testenv:pep8]
basepython = python3 basepython = python3