From 0461a0cc816779b5c297570a180602d7740b1e81 Mon Sep 17 00:00:00 2001 From: Chris MacNaughton Date: Fri, 25 Mar 2022 13:53:33 +0100 Subject: [PATCH] Migrate to charmhub handling --- build-requirements.txt | 8 +++++++- charmcraft.yaml | 26 ++++++++++++++++++++++++++ osci.yaml | 13 +++++++++++++ rename.sh | 13 +++++++++++++ tox.ini | 19 ++++++++++++++++--- 5 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 charmcraft.yaml create mode 100755 rename.sh diff --git a/build-requirements.txt b/build-requirements.txt index 271d895..0fbd084 100644 --- a/build-requirements.txt +++ b/build-requirements.txt @@ -1 +1,7 @@ -git+https://github.com/canonical/charmcraft.git@0.10.2#egg=charmcraft +# 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. \ No newline at end of file diff --git a/charmcraft.yaml b/charmcraft.yaml new file mode 100644 index 0000000..c879200 --- /dev/null +++ b/charmcraft.yaml @@ -0,0 +1,26 @@ +type: charm + +parts: + charm: + after: + - update-certificates + charm-python-packages: + # NOTE(lourot): see + # * https://github.com/canonical/charmcraft/issues/551 + # * https://github.com/canonical/charmcraft/issues/632 + - setuptools < 58 + build-packages: + - git + + update-certificates: + plugin: nil + # See https://github.com/canonical/charmcraft/issues/658 + override-build: | + apt update + apt install -y ca-certificates + update-ca-certificates +bases: + - name: ubuntu + channel: "20.04" + architectures: + - amd64 \ No newline at end of file diff --git a/osci.yaml b/osci.yaml index e5ee05d..7f46aa7 100644 --- a/osci.yaml +++ b/osci.yaml @@ -12,6 +12,7 @@ name: focal-pacific parent: func-target dependencies: + charm-build - osci-lint - tox-py35 - tox-py36 @@ -19,3 +20,15 @@ - tox-py38 vars: tox_extra_args: focal-pacific +- job: + name: focal-quincy + parent: func-target + dependencies: + - charm-build + - osci-lint + - tox-py35 + - tox-py36 + - tox-py37 + - tox-py38 + vars: + tox_extra_args: focal-quincy \ No newline at end of file diff --git a/rename.sh b/rename.sh new file mode 100755 index 0000000..283a01b --- /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 \ No newline at end of file diff --git a/tox.ini b/tox.ini index 52928f3..09f4980 100644 --- a/tox.ini +++ b/tox.ini @@ -15,8 +15,12 @@ skip_missing_interpreters = False # * It is also necessary to pin virtualenv as a newer virtualenv would still # lead to fetching the latest pip in the func* tox targets, see # https://stackoverflow.com/a/38133283 +# * It is necessary to declare setuptools as a dependency otherwise tox will +# fail very early at not being able to load it. The version pinning is in +# line with `pip.sh`. requires = pip < 20.3 virtualenv < 20.0 + setuptools < 50.0.0 # NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci minversion = 3.2.0 @@ -27,10 +31,12 @@ setenv = VIRTUAL_ENV={envdir} install_command = pip install {opts} {packages} commands = stestr run --slowest {posargs} -whitelist_externals = +allowlist_externals = git add-to-archive.py bash + charmcraft + rename.sh passenv = HOME TERM CS_* OS_* TEST_* deps = -r{toxinidir}/test-requirements.txt @@ -54,6 +60,11 @@ basepython = python3.8 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +[testenv:py39] +basepython = python3.9 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + [testenv:py3] basepython = python3 deps = -r{toxinidir}/requirements.txt @@ -101,7 +112,9 @@ commands = {posargs} basepython = python3 deps = -r{toxinidir}/build-requirements.txt commands = - charmcraft build + charmcraft clean + charmcraft -v build + {toxinidir}/rename.sh [testenv:func-noop] basepython = python3 @@ -130,4 +143,4 @@ commands = [flake8] # Ignore E902 because the unit_tests directory is missing in the built charm. -ignore = E402,E226,E902,W504 +ignore = E402,E226,E902 \ No newline at end of file