From a8785bc2cf0a8c61a725c59562efdca0c1d8d65b Mon Sep 17 00:00:00 2001 From: Alex Kavanagh Date: Tue, 15 Feb 2022 16:16:00 +0000 Subject: [PATCH] Update to classic charms to build using charmcraft in CI This update is to ensure that the Zuul Canonical CI builds the charm before functional tests and ensure that that artifact is used for the functional tests. This is to try to ensure that the charm that gets landed to the charmhub is the same charm that was tested with. Change-Id: I2b4ecddd0aa8b7dfcb3cf739a2f52ef93dc7ecf2 --- .gitignore | 1 + build-requirements.txt | 7 +++++++ charmcraft.yaml | 3 +-- osci.yaml | 4 ++++ rename.sh | 13 +++++++++++++ tests/bundles/focal-xena.yaml | 12 ++++++------ tests/bundles/focal-yoga.yaml | 12 ++++++------ tests/bundles/impish-xena.yaml | 12 ++++++------ tests/bundles/jammy-yoga.yaml | 12 ++++++------ tox.ini | 12 +++++++++++- 10 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 build-requirements.txt create mode 100755 rename.sh diff --git a/.gitignore b/.gitignore index 295e7c9..a7c4d52 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ tags .testrepository *.sw[nop] *.pyc +*.charm .unit-state.db tests/*.img .idea 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 index ba84f31..b77a966 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -6,6 +6,7 @@ parts: source: . prime: - actions/* + - charmhelpers/* - files/* - hooks/* - lib/* @@ -13,8 +14,6 @@ parts: - actions.yaml - config.yaml - copyright - - hardening.yaml - - icon.svg - LICENSE - Makefile - metadata.yaml diff --git a/osci.yaml b/osci.yaml index da6cd31..ec6b398 100644 --- a/osci.yaml +++ b/osci.yaml @@ -4,3 +4,7 @@ - charm-unit-jobs-py39 - charm-xena-functional-jobs - charm-yoga-functional-jobs + vars: + needs_charm_build: true + charm_build_name: glance-simplestreams-sync + build_type: charmcraft 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/focal-xena.yaml b/tests/bundles/focal-xena.yaml index 2984faa..1dab0d9 100644 --- a/tests/bundles/focal-xena.yaml +++ b/tests/bundles/focal-xena.yaml @@ -63,7 +63,7 @@ applications: openstack-origin: *source to: - '4' - channel: latest/edge + channel: yoga/edge glance: charm: ch:glance @@ -72,10 +72,10 @@ applications: openstack-origin: *source to: - '5' - channel: latest/edge + channel: yoga/edge glance-simplestreams-sync: - charm: ../../glance-simplestreams-sync + charm: ../../glance-simplestreams-sync.charm num_units: 1 to: - '6' @@ -87,7 +87,7 @@ applications: source: *source to: - '7' - channel: latest/edge + channel: quincy/edge ceph-osd: charm: ch:ceph-osd @@ -100,7 +100,7 @@ applications: - '8' - '9' - '10' - channel: latest/edge + channel: quincy/edge ceph-mon: charm: ch:ceph-mon @@ -111,7 +111,7 @@ applications: - '11' - '12' - '13' - channel: latest/edge + channel: quincy/edge relations: - ['keystone:certificates', 'vault:certificates'] diff --git a/tests/bundles/focal-yoga.yaml b/tests/bundles/focal-yoga.yaml index f24a486..4415497 100644 --- a/tests/bundles/focal-yoga.yaml +++ b/tests/bundles/focal-yoga.yaml @@ -63,7 +63,7 @@ applications: openstack-origin: *source to: - '4' - channel: latest/edge + channel: yoga/edge glance: charm: ch:glance @@ -72,10 +72,10 @@ applications: openstack-origin: *source to: - '5' - channel: latest/edge + channel: yoga/edge glance-simplestreams-sync: - charm: ../../glance-simplestreams-sync + charm: ../../glance-simplestreams-sync.charm num_units: 1 to: - '6' @@ -87,7 +87,7 @@ applications: source: *source to: - '7' - channel: latest/edge + channel: quincy/edge ceph-osd: charm: ch:ceph-osd @@ -100,7 +100,7 @@ applications: - '8' - '9' - '10' - channel: latest/edge + channel: quincy/edge ceph-mon: charm: ch:ceph-mon @@ -111,7 +111,7 @@ applications: - '11' - '12' - '13' - channel: latest/edge + channel: quincy/edge relations: - ['keystone:certificates', 'vault:certificates'] diff --git a/tests/bundles/impish-xena.yaml b/tests/bundles/impish-xena.yaml index ba91b20..07855b1 100644 --- a/tests/bundles/impish-xena.yaml +++ b/tests/bundles/impish-xena.yaml @@ -63,7 +63,7 @@ applications: openstack-origin: *source to: - '4' - channel: latest/edge + channel: yoga/edge glance: charm: ch:glance @@ -72,10 +72,10 @@ applications: openstack-origin: *source to: - '5' - channel: latest/edge + channel: yoga/edge glance-simplestreams-sync: - charm: ../../glance-simplestreams-sync + charm: ../../glance-simplestreams-sync.charm num_units: 1 to: - '6' @@ -87,7 +87,7 @@ applications: source: *source to: - '7' - channel: latest/edge + channel: quincy/edge ceph-osd: charm: ch:ceph-osd @@ -100,7 +100,7 @@ applications: - '8' - '9' - '10' - channel: latest/edge + channel: quincy/edge ceph-mon: charm: ch:ceph-mon @@ -111,7 +111,7 @@ applications: - '11' - '12' - '13' - channel: latest/edge + channel: quincy/edge relations: - ['keystone:certificates', 'vault:certificates'] diff --git a/tests/bundles/jammy-yoga.yaml b/tests/bundles/jammy-yoga.yaml index 488e8d4..7327b1b 100644 --- a/tests/bundles/jammy-yoga.yaml +++ b/tests/bundles/jammy-yoga.yaml @@ -63,7 +63,7 @@ applications: openstack-origin: *source to: - '4' - channel: latest/edge + channel: yoga/edge glance: charm: ch:glance @@ -72,10 +72,10 @@ applications: openstack-origin: *source to: - '5' - channel: latest/edge + channel: yoga/edge glance-simplestreams-sync: - charm: ../../glance-simplestreams-sync + charm: ../../glance-simplestreams-sync.charm num_units: 1 to: - '6' @@ -87,7 +87,7 @@ applications: source: *source to: - '7' - channel: latest/edge + channel: quincy/edge ceph-osd: charm: ch:ceph-osd @@ -100,7 +100,7 @@ applications: - '8' - '9' - '10' - channel: latest/edge + channel: quincy/edge ceph-mon: charm: ch:ceph-mon @@ -111,7 +111,7 @@ applications: - '11' - '12' - '13' - channel: latest/edge + channel: quincy/edge relations: - ['keystone:certificates', 'vault:certificates'] diff --git a/tox.ini b/tox.ini index 86d1e90..81fd249 100644 --- a/tox.ini +++ b/tox.ini @@ -37,10 +37,20 @@ 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:build] +basepython = python3 +deps = -r{toxinidir}/build-requirements.txt +commands = + charmcraft clean + charmcraft -v build + {toxinidir}/rename.sh + [testenv:py35] basepython = python3.5 deps = -r{toxinidir}/requirements.txt