From 6751832bb65606ee54d8701bcff1a6c0fee5aa37 Mon Sep 17 00:00:00 2001 From: Alex Kavanagh Date: Mon, 18 Apr 2022 20:59:55 +0100 Subject: [PATCH] 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 --- .gitignore | 3 ++ build-requirements.txt | 7 ++++ charmcraft.yaml | 33 +++++++++++++++++++ osci.yaml | 8 +++-- rename.sh | 13 ++++++++ tests/bundles/bionic-nagios.yaml | 9 ++--- tests/bundles/bionic.yaml | 5 +-- tests/bundles/overlays/ha.yaml | 3 +- .../xenial-queens-ha-series-upgrade.yaml | 6 ++-- tox.ini | 29 ++++++++-------- 10 files changed, 91 insertions(+), 25 deletions(-) create mode 100644 build-requirements.txt create mode 100644 charmcraft.yaml create mode 100755 rename.sh diff --git a/.gitignore b/.gitignore index cb99163..bdd4194 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ __pycache__ .stestr .unit-state.db func-results.json + +*.charm + diff --git a/build-requirements.txt b/build-requirements.txt new file mode 100644 index 0000000..b6d2452 --- /dev/null +++ b/build-requirements.txt @@ -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. diff --git a/charmcraft.yaml b/charmcraft.yaml new file mode 100644 index 0000000..d45dcab --- /dev/null +++ b/charmcraft.yaml @@ -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] diff --git a/osci.yaml b/osci.yaml index cd7c0c8..01e1b16 100644 --- a/osci.yaml +++ b/osci.yaml @@ -1,9 +1,13 @@ - project: templates: - - charm-yoga-unit-jobs + - charm-unit-jobs-py36 check: jobs: - bionic_model-bionic-ha + vars: + needs_charm_build: true + charm_build_name: percona-cluster + build_type: charmcraft - job: name: bionic_model-bionic-ha @@ -11,7 +15,5 @@ dependencies: - osci-lint - tox-py36 - - tox-py38 - - tox-py39 vars: tox_extra_args: bionic_model:bionic-ha diff --git a/rename.sh b/rename.sh new file mode 100755 index 0000000..d0c35c9 --- /dev/null +++ b/rename.sh @@ -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 diff --git a/tests/bundles/bionic-nagios.yaml b/tests/bundles/bionic-nagios.yaml index b09d826..f13c21a 100644 --- a/tests/bundles/bionic-nagios.yaml +++ b/tests/bundles/bionic-nagios.yaml @@ -3,19 +3,20 @@ series: bionic applications: percona-cluster: series: bionic - charm: ../../../percona-cluster + charm: ../../percona-cluster.charm num_units: 1 keystone: - charm: cs:~openstack-charmers-next/keystone + charm: ch:keystone + channel: queens/edge num_units: 1 options: token-expiration: 60 nagios: - charm: cs:nagios + charm: ch:nagios series: bionic num_units: 1 nrpe: - charm: cs:nrpe + charm: ch:nrpe relations: - - keystone:shared-db diff --git a/tests/bundles/bionic.yaml b/tests/bundles/bionic.yaml index e887743..3db15dd 100644 --- a/tests/bundles/bionic.yaml +++ b/tests/bundles/bionic.yaml @@ -5,10 +5,11 @@ relations: applications: percona-cluster: series: bionic - charm: ../../../percona-cluster + charm: ../../percona-cluster.charm num_units: 1 keystone: - charm: cs:~openstack-charmers-next/keystone + charm: ch:keystone + channel: queens/edge num_units: 1 options: token-expiration: 60 diff --git a/tests/bundles/overlays/ha.yaml b/tests/bundles/overlays/ha.yaml index a08e916..db34a55 100644 --- a/tests/bundles/overlays/ha.yaml +++ b/tests/bundles/overlays/ha.yaml @@ -9,7 +9,8 @@ applications: vip: {{ TEST_VIP00 }} min-cluster-size: 3 hacluster: - charm: cs:~openstack-charmers-next/hacluster + charm: ch:hacluster + channel: 1.1.18/edge num_units: 0 options: cluster_count: 3 diff --git a/tests/bundles/xenial-queens-ha-series-upgrade.yaml b/tests/bundles/xenial-queens-ha-series-upgrade.yaml index 0e784ac..77bce15 100644 --- a/tests/bundles/xenial-queens-ha-series-upgrade.yaml +++ b/tests/bundles/xenial-queens-ha-series-upgrade.yaml @@ -5,10 +5,12 @@ relations: applications: percona-cluster: series: xenial - charm: ../../../percona-cluster + charm: ../../percona-cluster.charm num_units: 1 keystone: - charm: cs:~openstack-charmers-next/keystone + charm: ch:keystone + channel: queens/edge + series: xenial num_units: 1 options: openstack-origin: cloud:xenial-queens diff --git a/tox.ini b/tox.ini index 86d1e90..457ddfe 100644 --- a/tox.ini +++ b/tox.ini @@ -37,12 +37,22 @@ setenv = VIRTUAL_ENV={envdir} install_command = {toxinidir}/pip.sh install {opts} {packages} commands = stestr run --slowest {posargs} -allowlist_externals = juju +allowlist_externals = + charmcraft + rename.sh passenv = HOME TERM CS_* OS_* TEST_* deps = -r{toxinidir}/test-requirements.txt -[testenv:py35] -basepython = python3.5 +[testenv:build] +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 -r{toxinidir}/test-requirements.txt @@ -50,26 +60,19 @@ deps = -r{toxinidir}/requirements.txt basepython = python3.6 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt - -[testenv:py37] -basepython = python3.7 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +commands = stestr run --slowest {posargs} [testenv:py38] basepython = python3.8 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +commands = stestr run --slowest {posargs} [testenv:py39] basepython = python3.9 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt - -[testenv:py3] -basepython = python3 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +commands = stestr run --slowest {posargs} [testenv:pep8] basepython = python3