From 5c64f4617dc5b435d1bf4ad69269be379f197adf Mon Sep 17 00:00:00 2001 From: Gabriel Cocenza Date: Wed, 15 Feb 2023 17:30:16 -0300 Subject: [PATCH] Fix charm for tox4 compatibility Related-Bug: 2002788 Change-Id: Iecd83b01980d3b9f25da1f5594a009990ef94307 --- osci.yaml | 8 ++++---- pip.sh | 18 ------------------ test-requirements.txt | 1 - tox.ini | 35 +++++++++++++++-------------------- 4 files changed, 19 insertions(+), 43 deletions(-) delete mode 100755 pip.sh diff --git a/osci.yaml b/osci.yaml index 47a8030..d990643 100644 --- a/osci.yaml +++ b/osci.yaml @@ -13,7 +13,7 @@ needs_charm_build: true charm_build_name: gnocchi build_type: charmcraft - charmcraft_channel: 2.0/stable + charmcraft_channel: 2.1/stable - job: name: test-s3-jammy-yoga-s3 @@ -21,18 +21,18 @@ dependencies: - jammy-yoga vars: - tox_extra_args: test-s3:jammy-yoga-s3 + tox_extra_args: '-- test-s3:jammy-yoga-s3' - job: name: test-s3-jammy-zed-s3 parent: func-target dependencies: - jammy-zed vars: - tox_extra_args: test-s3:jammy-zed-s3 + tox_extra_args: '-- test-s3:jammy-zed-s3' - job: name: test-s3-kinetic-zed-s3 parent: func-target dependencies: - kinetic-zed vars: - tox_extra_args: test-s3:kinetic-zed-s3 + tox_extra_args: '-- test-s3:kinetic-zed-s3' diff --git a/pip.sh b/pip.sh deleted file mode 100755 index 9a7e6b0..0000000 --- a/pip.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -# -# This file is managed centrally by release-tools and should not be modified -# within individual charm repos. See the 'global' dir contents for available -# choices of tox.ini for OpenStack Charms: -# https://github.com/openstack-charmers/release-tools -# -# setuptools 58.0 dropped the support for use_2to3=true which is needed to -# install blessings (an indirect dependency of charm-tools). -# -# More details on the beahvior of tox and virtualenv creation can be found at -# https://github.com/tox-dev/tox/issues/448 -# -# This script is wrapper to force the use of the pinned versions early in the -# process when the virtualenv was created and upgraded before installing the -# depedencies declared in the target. -pip install 'pip<20.3' 'setuptools<50.0.0' -pip "$@" diff --git a/test-requirements.txt b/test-requirements.txt index a7936e6..3fd5feb 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,7 +4,6 @@ # https://github.com/openstack-charmers/release-tools # pyparsing<3.0.0 # aodhclient is pinned in zaza and needs pyparsing < 3.0.0, but cffi also needs it, so pin here. -setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb244e9b27bc56750c44b7c85 stestr>=2.2.0 diff --git a/tox.ini b/tox.ini index bdde110..399fef5 100644 --- a/tox.ini +++ b/tox.ini @@ -5,51 +5,46 @@ # https://github.com/openstack-charmers/release-tools [tox] -skipsdist = True envlist = pep8,py3 # NOTE: Avoid build/test env pollution by not enabling sitepackages. sitepackages = False # NOTE: Avoid false positives by not skipping missing interpreters. skip_missing_interpreters = False -# NOTES: -# * We avoid the new dependency resolver by pinning pip < 20.3, see -# https://github.com/pypa/pip/issues/9187 -# * Pinning dependencies requires tox >= 3.2.0, see -# https://tox.readthedocs.io/en/latest/config.html#conf-requires -# * 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 -requires = - pip < 20.3 - virtualenv < 20.0 - setuptools<50.0.0 - -# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci -minversion = 3.18.0 [testenv] +# We use tox mainly for virtual environment management for test requirements +# and do not install the charm code as a Python package into that environment. +# Ref: https://tox.wiki/en/latest/config.html#skip_install +skip_install = True setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 TERM=linux JUJU_REPOSITORY={toxinidir}/build -passenv = no_proxy http_proxy https_proxy JUJU_REPOSITORY -install_command = - {toxinidir}/pip.sh install {opts} {packages} +passenv = + no_proxy + http_proxy + https_proxy + JUJU_REPOSITORY allowlist_externals = charmcraft bash tox - rename.sh + {toxinidir}/rename.sh deps = -r{toxinidir}/requirements.txt [testenv:build] basepython = python3 deps = -r{toxinidir}/build-requirements.txt +# charmcraft clean is done to ensure that +# `tox -e build` always performs a clean, repeatable build. +# For faster rebuilds during development, +# directly run `charmcraft -v pack && ./rename.sh`. commands = charmcraft clean charmcraft -v pack {toxinidir}/rename.sh + charmcraft clean [testenv:build-reactive] basepython = python3