From 1910a5857c6bddb318a2fa70a2e5923f00443545 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 9 Apr 2023 14:02:53 -0400 Subject: [PATCH 01/42] Remove references to {envbindir} tox prepends the {env_bin_dir} to $PATH, so commands will default to using the virtual environment first. See: https://tox.wiki/en/4.4.11/config.html#commands One of tox's core maintainers also discourages its use: https://github.com/tox-dev/tox/issues/2909#issuecomment-1409806654 --- eng/tox/tox.ini | 120 ++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index e72a2d8a880b..317efc149085 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -67,9 +67,9 @@ deps = {[base]deps} changedir = {toxinidir} install_command = python -m pip install {opts} {packages} --cache-dir {toxinidir}/../.tox_pip_cache_{envname} --ignore-installed commands = - {envbindir}/python -m pip --version - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} - {envbindir}/python -m pip freeze + python -m pip --version + python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} + python -m pip freeze pytest \ {[testenv]default_pytest_params} \ {posargs} \ @@ -87,13 +87,13 @@ setenv = deps = {[base]deps} commands = - {envbindir}/python -m pip install azure-pylint-guidelines-checker==0.0.5 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python -m pip install azure-pylint-guidelines-checker==0.0.5 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python {toxinidir}/../../../eng/tox/run_pylint.py -t {toxinidir} + python {toxinidir}/../../../eng/tox/run_pylint.py -t {toxinidir} [testenv:next-pylint] skipsdist = true @@ -106,14 +106,14 @@ setenv = deps = {[base]deps} commands = - {envbindir}/python -m pip install pylint==2.15.8 - {envbindir}/python -m pip install azure-pylint-guidelines-checker==0.0.8 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python -m pip install pylint==2.15.8 + python -m pip install azure-pylint-guidelines-checker==0.0.8 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python {toxinidir}/../../../eng/tox/run_pylint.py -t {toxinidir} --next=True + python {toxinidir}/../../../eng/tox/run_pylint.py -t {toxinidir} --next=True [testenv:mypy] skipsdist = true @@ -131,12 +131,12 @@ deps = types-six==1.16.10 types-redis==4.3.21.2 commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python {toxinidir}/../../../eng/tox/run_mypy.py -t {toxinidir} + python {toxinidir}/../../../eng/tox/run_mypy.py -t {toxinidir} [testenv:next-mypy] skipsdist = true @@ -154,12 +154,12 @@ deps = types-six types-redis commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python {toxinidir}/../../../eng/tox/run_mypy.py -t {toxinidir} --next=True + python {toxinidir}/../../../eng/tox/run_mypy.py -t {toxinidir} --next=True [testenv:pyright] @@ -174,14 +174,14 @@ deps = {[base]deps} pyright==1.1.287 commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python {toxinidir}/../../../eng/tox/create_dependencies_and_install.py \ + python {toxinidir}/../../../eng/tox/create_dependencies_and_install.py \ -p {toxinidir} - {envbindir}/python {toxinidir}/../../../eng/tox/run_pyright.py -t {toxinidir} + python {toxinidir}/../../../eng/tox/run_pyright.py -t {toxinidir} [testenv:next-pyright] @@ -196,14 +196,14 @@ deps = {[base]deps} pyright commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python {toxinidir}/../../../eng/tox/create_dependencies_and_install.py \ + python {toxinidir}/../../../eng/tox/create_dependencies_and_install.py \ -p {toxinidir} - {envbindir}/python {toxinidir}/../../../eng/tox/run_pyright.py -t {toxinidir} --next=True + python {toxinidir}/../../../eng/tox/run_pyright.py -t {toxinidir} --next=True [testenv:verifytypes] @@ -218,14 +218,14 @@ deps = {[base]deps} pyright==1.1.287 commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python {toxinidir}/../../../eng/tox/create_dependencies_and_install.py \ + python {toxinidir}/../../../eng/tox/create_dependencies_and_install.py \ -p {toxinidir} - {envbindir}/python {toxinidir}/../../../eng/tox/run_verifytypes.py -t {toxinidir} + python {toxinidir}/../../../eng/tox/run_verifytypes.py -t {toxinidir} [testenv:whl_no_aio] @@ -238,10 +238,10 @@ setenv = {[testenv]setenv} PROXY_URL=http://localhost:5004 commands = - - {envbindir}/python -m pip uninstall aiohttp --yes - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} - {envbindir}/python {toxinidir}/../../../eng/tox/try_import.py aiohttp -p {toxinidir} - {envbindir}/python -m pip freeze + - python -m pip uninstall aiohttp --yes + python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} + python {toxinidir}/../../../eng/tox/try_import.py aiohttp -p {toxinidir} + python -m pip freeze pytest \ {[testenv]default_pytest_params} \ --ignore-glob='*async*.py' \ @@ -259,12 +259,12 @@ setenv = deps = {[base]deps} commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {envtmpdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python -m pip freeze + python -m pip freeze pytest \ {posargs} \ --no-cov \ @@ -305,17 +305,17 @@ deps = mistune<2.0.0 m2r==0.2.1 commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python {toxinidir}/../../../eng/tox/prep_sphinx_env.py -d {distdir} -t {toxinidir} - {envbindir}/python {toxinidir}/../../../eng/tox/run_sphinx_apidoc.py \ + python {toxinidir}/../../../eng/tox/prep_sphinx_env.py -d {distdir} -t {toxinidir} + python {toxinidir}/../../../eng/tox/run_sphinx_apidoc.py \ -w {distdir} \ -r {toxinidir} - {envbindir}/python {toxinidir}/../../../eng/tox/run_sphinx_build.py \ + python {toxinidir}/../../../eng/tox/run_sphinx_build.py \ -w {distdir}/unzipped/docgen \ -o {distdir}/site \ -r {toxinidir} @@ -333,15 +333,15 @@ deps = {[packaging]pkgs} cryptography<4 commands = - {envbindir}/python -m pip install {toxinidir}/../../../tools/azure-sdk-tools --no-deps - {envbindir}/python {toxinidir}/../../../eng/tox/sanitize_setup.py -t {toxinidir} - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python -m pip install {toxinidir}/../../../tools/azure-sdk-tools --no-deps + python {toxinidir}/../../../eng/tox/sanitize_setup.py -t {toxinidir} + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {envtmpdir} \ -p {toxinidir} \ -w {envtmpdir} \ --force-create true - {envbindir}/python -m pip freeze - {envbindir}/python {toxinidir}/../../../eng/tox/import_all.py -t {toxinidir} + python -m pip freeze + python {toxinidir}/../../../eng/tox/import_all.py -t {toxinidir} [testenv:verifywhl] @@ -354,9 +354,9 @@ setenv = deps = {[packaging]pkgs} commands = - {envbindir}/python -m pip install {toxinidir}/../../../tools/azure-sdk-tools --no-deps - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} --skip-install True - {envbindir}/python {toxinidir}/../../../eng/tox/verify_whl.py -d {envtmpdir} -t {toxinidir} + python -m pip install {toxinidir}/../../../tools/azure-sdk-tools --no-deps + python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} --skip-install True + python {toxinidir}/../../../eng/tox/verify_whl.py -d {envtmpdir} -t {toxinidir} [testenv:verifysdist] @@ -369,9 +369,9 @@ setenv = deps = {[packaging]pkgs} commands = - {envbindir}/python -m pip install {toxinidir}/../../../tools/azure-sdk-tools --no-deps - {envbindir}/python {toxinidir}/setup.py --q sdist --format zip -d {envtmpdir} - {envbindir}/python {toxinidir}/../../../eng/tox/verify_sdist.py -d {envtmpdir} -t {toxinidir} + python -m pip install {toxinidir}/../../../tools/azure-sdk-tools --no-deps + python {toxinidir}/setup.py --q sdist --format zip -d {envtmpdir} + python {toxinidir}/../../../eng/tox/verify_sdist.py -d {envtmpdir} -t {toxinidir} [testenv:devtest] @@ -381,8 +381,8 @@ setenv = {[testenv]setenv} PROXY_URL=http://localhost:5011 commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} - {envbindir}/python {toxinidir}/../../../eng/tox/install_dev_build_dependency.py -t {toxinidir} + python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} + python {toxinidir}/../../../eng/tox/install_dev_build_dependency.py -t {toxinidir} pytest \ {[testenv]default_pytest_params} \ --ignore=.tox \ @@ -392,10 +392,10 @@ commands = [deptestcommands] commands = - {envbindir}/python {toxinidir}/../../../eng/tox/install_depend_packages.py -t {toxinidir} -d {env:DEPENDENCY_TYPE:} -w {envtmpdir} - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} --pre-download-disabled - {envbindir}/python -m pip freeze - {envbindir}/python {toxinidir}/../../../eng/tox/verify_installed_packages.py --packages-file {envtmpdir}/packages.txt + python {toxinidir}/../../../eng/tox/install_depend_packages.py -t {toxinidir} -d {env:DEPENDENCY_TYPE:} -w {envtmpdir} + python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} --pre-download-disabled + python -m pip freeze + python {toxinidir}/../../../eng/tox/verify_installed_packages.py --packages-file {envtmpdir}/packages.txt pytest {[testenv]default_pytest_params} {posargs} --no-cov {toxinidir} @@ -443,9 +443,9 @@ deps = {[base]deps} commands = # install API stub generator - {envbindir}/python -m pip install -r {toxinidir}/../../../eng/apiview_reqs.txt --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" - {envbindir}/python -m pip freeze - {envbindir}/python {toxinidir}/../../../eng/tox/run_apistubgen.py -t {toxinidir} -w {envtmpdir} {posargs} + python -m pip install -r {toxinidir}/../../../eng/apiview_reqs.txt --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" + python -m pip freeze + python {toxinidir}/../../../eng/tox/run_apistubgen.py -t {toxinidir} -w {envtmpdir} {posargs} [testenv:bandit] @@ -460,13 +460,13 @@ deps = {[base]deps} importlib-metadata<5.0 commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {envtmpdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python -m pip freeze - {envbindir}/python {toxinidir}/../../../eng/tox/run_bandit.py -t {toxinidir} + python -m pip freeze + python {toxinidir}/../../../eng/tox/run_bandit.py -t {toxinidir} [testenv:samples] @@ -481,8 +481,8 @@ deps = {[base]deps} subprocess32; python_version < '3.5' commands = - {envbindir}/python -m pip freeze - {envbindir}/python {toxinidir}/../../../scripts/devops_tasks/test_run_samples.py -t {toxinidir} + python -m pip freeze + python {toxinidir}/../../../scripts/devops_tasks/test_run_samples.py -t {toxinidir} [testenv:breaking] @@ -498,9 +498,9 @@ deps = jsondiff==1.2.0 -e {toxinidir}/../../scripts/breaking_changes_checker commands = - {envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {toxinidir}/../../../eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - {envbindir}/python {toxinidir}/../../../scripts/breaking_changes_checker/detect_breaking_changes.py -t {toxinidir} + python {toxinidir}/../../../scripts/breaking_changes_checker/detect_breaking_changes.py -t {toxinidir} From 3a4449d9cfb9afdbfcffb89ffb9b5cec7b57964a Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 9 Apr 2023 14:15:19 -0400 Subject: [PATCH 02/42] refactor: Write paths relative to git root, instead of package dir Uses an inline plugin (toxfile.py) to make a computed config value avaiable to tox environments. --- eng/tox/tox.ini | 98 +++++++++++++++++++++++----------------------- eng/tox/toxfile.py | 19 +++++++++ 2 files changed, 68 insertions(+), 49 deletions(-) create mode 100644 eng/tox/toxfile.py diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index 317efc149085..e510b0e8b27c 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -12,7 +12,7 @@ envlist = whl,sdist [tools] deps = - -r ../../../eng/test_tools.txt + -r {repository_root}/eng/test_tools.txt [coverage:paths] @@ -31,7 +31,7 @@ deps = [dependencytools] deps = - -r ../../../eng/dependency_tools.txt + -r {repository_root}/eng/dependency_tools.txt [packaging] @@ -68,7 +68,7 @@ changedir = {toxinidir} install_command = python -m pip install {opts} {packages} --cache-dir {toxinidir}/../.tox_pip_cache_{envname} --ignore-installed commands = python -m pip --version - python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} python -m pip freeze pytest \ {[testenv]default_pytest_params} \ @@ -88,12 +88,12 @@ deps = {[base]deps} commands = python -m pip install azure-pylint-guidelines-checker==0.0.5 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - python {toxinidir}/../../../eng/tox/run_pylint.py -t {toxinidir} + python {repository_root}/eng/tox/run_pylint.py -t {toxinidir} [testenv:next-pylint] skipsdist = true @@ -108,12 +108,12 @@ deps = commands = python -m pip install pylint==2.15.8 python -m pip install azure-pylint-guidelines-checker==0.0.8 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - python {toxinidir}/../../../eng/tox/run_pylint.py -t {toxinidir} --next=True + python {repository_root}/eng/tox/run_pylint.py -t {toxinidir} --next=True [testenv:mypy] skipsdist = true @@ -131,12 +131,12 @@ deps = types-six==1.16.10 types-redis==4.3.21.2 commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - python {toxinidir}/../../../eng/tox/run_mypy.py -t {toxinidir} + python {repository_root}/eng/tox/run_mypy.py -t {toxinidir} [testenv:next-mypy] skipsdist = true @@ -154,12 +154,12 @@ deps = types-six types-redis commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - python {toxinidir}/../../../eng/tox/run_mypy.py -t {toxinidir} --next=True + python {repository_root}/eng/tox/run_mypy.py -t {toxinidir} --next=True [testenv:pyright] @@ -174,14 +174,14 @@ deps = {[base]deps} pyright==1.1.287 commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - python {toxinidir}/../../../eng/tox/create_dependencies_and_install.py \ + python {repository_root}/eng/tox/create_dependencies_and_install.py \ -p {toxinidir} - python {toxinidir}/../../../eng/tox/run_pyright.py -t {toxinidir} + python {repository_root}/eng/tox/run_pyright.py -t {toxinidir} [testenv:next-pyright] @@ -196,14 +196,14 @@ deps = {[base]deps} pyright commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - python {toxinidir}/../../../eng/tox/create_dependencies_and_install.py \ + python {repository_root}/eng/tox/create_dependencies_and_install.py \ -p {toxinidir} - python {toxinidir}/../../../eng/tox/run_pyright.py -t {toxinidir} --next=True + python {repository_root}/eng/tox/run_pyright.py -t {toxinidir} --next=True [testenv:verifytypes] @@ -218,14 +218,14 @@ deps = {[base]deps} pyright==1.1.287 commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - python {toxinidir}/../../../eng/tox/create_dependencies_and_install.py \ + python {repository_root}/eng/tox/create_dependencies_and_install.py \ -p {toxinidir} - python {toxinidir}/../../../eng/tox/run_verifytypes.py -t {toxinidir} + python {repository_root}/eng/tox/run_verifytypes.py -t {toxinidir} [testenv:whl_no_aio] @@ -239,8 +239,8 @@ setenv = PROXY_URL=http://localhost:5004 commands = - python -m pip uninstall aiohttp --yes - python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} - python {toxinidir}/../../../eng/tox/try_import.py aiohttp -p {toxinidir} + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} + python {repository_root}/eng/tox/try_import.py aiohttp -p {toxinidir} python -m pip freeze pytest \ {[testenv]default_pytest_params} \ @@ -259,7 +259,7 @@ setenv = deps = {[base]deps} commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {envtmpdir} \ -p {toxinidir} \ -w {envtmpdir} \ @@ -305,17 +305,17 @@ deps = mistune<2.0.0 m2r==0.2.1 commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - python {toxinidir}/../../../eng/tox/prep_sphinx_env.py -d {distdir} -t {toxinidir} - python {toxinidir}/../../../eng/tox/run_sphinx_apidoc.py \ + python {repository_root}/eng/tox/prep_sphinx_env.py -d {distdir} -t {toxinidir} + python {repository_root}/eng/tox/run_sphinx_apidoc.py \ -w {distdir} \ -r {toxinidir} - python {toxinidir}/../../../eng/tox/run_sphinx_build.py \ + python {repository_root}/eng/tox/run_sphinx_build.py \ -w {distdir}/unzipped/docgen \ -o {distdir}/site \ -r {toxinidir} @@ -333,15 +333,15 @@ deps = {[packaging]pkgs} cryptography<4 commands = - python -m pip install {toxinidir}/../../../tools/azure-sdk-tools --no-deps - python {toxinidir}/../../../eng/tox/sanitize_setup.py -t {toxinidir} - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python -m pip install {repository_root}/tools/azure-sdk-tools --no-deps + python {repository_root}/eng/tox/sanitize_setup.py -t {toxinidir} + python {repository_root}/eng/tox/create_package_and_install.py \ -d {envtmpdir} \ -p {toxinidir} \ -w {envtmpdir} \ --force-create true python -m pip freeze - python {toxinidir}/../../../eng/tox/import_all.py -t {toxinidir} + python {repository_root}/eng/tox/import_all.py -t {toxinidir} [testenv:verifywhl] @@ -354,9 +354,9 @@ setenv = deps = {[packaging]pkgs} commands = - python -m pip install {toxinidir}/../../../tools/azure-sdk-tools --no-deps - python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} --skip-install True - python {toxinidir}/../../../eng/tox/verify_whl.py -d {envtmpdir} -t {toxinidir} + python -m pip install {repository_root}/tools/azure-sdk-tools --no-deps + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} --skip-install True + python {repository_root}/eng/tox/verify_whl.py -d {envtmpdir} -t {toxinidir} [testenv:verifysdist] @@ -369,9 +369,9 @@ setenv = deps = {[packaging]pkgs} commands = - python -m pip install {toxinidir}/../../../tools/azure-sdk-tools --no-deps + python -m pip install {repository_root}/tools/azure-sdk-tools --no-deps python {toxinidir}/setup.py --q sdist --format zip -d {envtmpdir} - python {toxinidir}/../../../eng/tox/verify_sdist.py -d {envtmpdir} -t {toxinidir} + python {repository_root}/eng/tox/verify_sdist.py -d {envtmpdir} -t {toxinidir} [testenv:devtest] @@ -381,8 +381,8 @@ setenv = {[testenv]setenv} PROXY_URL=http://localhost:5011 commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} - python {toxinidir}/../../../eng/tox/install_dev_build_dependency.py -t {toxinidir} + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} + python {repository_root}/eng/tox/install_dev_build_dependency.py -t {toxinidir} pytest \ {[testenv]default_pytest_params} \ --ignore=.tox \ @@ -392,10 +392,10 @@ commands = [deptestcommands] commands = - python {toxinidir}/../../../eng/tox/install_depend_packages.py -t {toxinidir} -d {env:DEPENDENCY_TYPE:} -w {envtmpdir} - python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} --pre-download-disabled + python {repository_root}/eng/tox/install_depend_packages.py -t {toxinidir} -d {env:DEPENDENCY_TYPE:} -w {envtmpdir} + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} --pre-download-disabled python -m pip freeze - python {toxinidir}/../../../eng/tox/verify_installed_packages.py --packages-file {envtmpdir}/packages.txt + python {repository_root}/eng/tox/verify_installed_packages.py --packages-file {envtmpdir}/packages.txt pytest {[testenv]default_pytest_params} {posargs} --no-cov {toxinidir} @@ -443,9 +443,9 @@ deps = {[base]deps} commands = # install API stub generator - python -m pip install -r {toxinidir}/../../../eng/apiview_reqs.txt --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" + python -m pip install -r {repository_root}/eng/apiview_reqs.txt --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" python -m pip freeze - python {toxinidir}/../../../eng/tox/run_apistubgen.py -t {toxinidir} -w {envtmpdir} {posargs} + python {repository_root}/eng/tox/run_apistubgen.py -t {toxinidir} -w {envtmpdir} {posargs} [testenv:bandit] @@ -460,13 +460,13 @@ deps = {[base]deps} importlib-metadata<5.0 commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {envtmpdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist python -m pip freeze - python {toxinidir}/../../../eng/tox/run_bandit.py -t {toxinidir} + python {repository_root}/eng/tox/run_bandit.py -t {toxinidir} [testenv:samples] @@ -482,7 +482,7 @@ deps = subprocess32; python_version < '3.5' commands = python -m pip freeze - python {toxinidir}/../../../scripts/devops_tasks/test_run_samples.py -t {toxinidir} + python {repository_root}/scripts/devops_tasks/test_run_samples.py -t {toxinidir} [testenv:breaking] @@ -496,11 +496,11 @@ setenv = deps = {[base]deps} jsondiff==1.2.0 - -e {toxinidir}/../../scripts/breaking_changes_checker + -e {repository_root}/scripts/breaking_changes_checker commands = - python {toxinidir}/../../../eng/tox/create_package_and_install.py \ + python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ -p {toxinidir} \ -w {envtmpdir} \ --package-type sdist - python {toxinidir}/../../../scripts/breaking_changes_checker/detect_breaking_changes.py -t {toxinidir} + python {repository_root}/scripts/breaking_changes_checker/detect_breaking_changes.py -t {toxinidir} diff --git a/eng/tox/toxfile.py b/eng/tox/toxfile.py new file mode 100644 index 000000000000..6fbe64a8d1cf --- /dev/null +++ b/eng/tox/toxfile.py @@ -0,0 +1,19 @@ +from logging import getLogger +from pathlib import Path + +from tox import plugin +from tox.config.sets import CoreConfigSet +from tox.session.state import State + +logger = getLogger(__file__) + +NAME = "azure-sdk-for-python tox plugin" + +@plugin.impl +def tox_add_core_config(core_conf: CoreConfigSet, state: State): + core_conf.add_constant( + "repository_root", + "The root of this git repository", + next(p for p in Path(core_conf["config_file_path"]).resolve().parents if (p / ".git").exists()), + ) + From e4d6043abd83f844dcff6e52e5093dde4a2287e5 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 9 Apr 2023 14:26:46 -0400 Subject: [PATCH 03/42] refactor: Rename {toxinidir} to {tox_root} {toxinidir} is an alias for {tox_root}, but {tox_root} is: * More clear: {tox_root} isn't necessarily where the ini file is * Shorter --- eng/tox/tox.ini | 139 ++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 70 deletions(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index e510b0e8b27c..b105ff48a283 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -44,7 +44,7 @@ pkgs = [testenv] ignore_args=--ignore=.tox --ignore=build --ignore=.eggs -default_pytest_params = --junitxml={toxinidir}/test-junit-{envname}.xml --verbose --durations=10 --ignore=azure {[testenv]ignore_args} +default_pytest_params = --junitxml={tox_root}/test-junit-{envname}.xml --verbose --durations=10 --ignore=azure {[testenv]ignore_args} parallel_show_output =True skip_install = true skipsdist = true @@ -64,23 +64,23 @@ setenv = VIRTUALENV_PIP=20.3.3 VIRTUALENV_SETUPTOOLS=67.6.0 deps = {[base]deps} -changedir = {toxinidir} -install_command = python -m pip install {opts} {packages} --cache-dir {toxinidir}/../.tox_pip_cache_{envname} --ignore-installed +changedir = {tox_root} +install_command = python -m pip install {opts} {packages} --cache-dir {tox_root}/../.tox_pip_cache_{envname} --ignore-installed commands = python -m pip --version - python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} python -m pip freeze pytest \ {[testenv]default_pytest_params} \ {posargs} \ - {toxinidir} + {tox_root} [testenv:pylint] skipsdist = true skip_install = true usedevelop = false -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5002 @@ -90,16 +90,16 @@ commands = python -m pip install azure-pylint-guidelines-checker==0.0.5 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/eng/tox/run_pylint.py -t {toxinidir} + python {repository_root}/eng/tox/run_pylint.py -t {tox_root} [testenv:next-pylint] skipsdist = true skip_install = true usedevelop = false -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5002 @@ -110,16 +110,16 @@ commands = python -m pip install azure-pylint-guidelines-checker==0.0.8 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/eng/tox/run_pylint.py -t {toxinidir} --next=True + python {repository_root}/eng/tox/run_pylint.py -t {tox_root} --next=True [testenv:mypy] skipsdist = true skip_install = true usedevelop = true -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5003 @@ -133,16 +133,16 @@ deps = commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/eng/tox/run_mypy.py -t {toxinidir} + python {repository_root}/eng/tox/run_mypy.py -t {tox_root} [testenv:next-mypy] skipsdist = true skip_install = true usedevelop = true -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5020 @@ -156,17 +156,17 @@ deps = commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/eng/tox/run_mypy.py -t {toxinidir} --next=True + python {repository_root}/eng/tox/run_mypy.py -t {tox_root} --next=True [testenv:pyright] skipsdist = true skip_install = true usedevelop = true -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5018 @@ -176,19 +176,18 @@ deps = commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/eng/tox/create_dependencies_and_install.py \ - -p {toxinidir} - python {repository_root}/eng/tox/run_pyright.py -t {toxinidir} + python {repository_root}/eng/tox/create_dependencies_and_install.py -p {tox_root} + python {repository_root}/eng/tox/run_pyright.py -t {tox_root} [testenv:next-pyright] skipsdist = true skip_install = true usedevelop = true -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5021 @@ -198,19 +197,19 @@ deps = commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist python {repository_root}/eng/tox/create_dependencies_and_install.py \ - -p {toxinidir} - python {repository_root}/eng/tox/run_pyright.py -t {toxinidir} --next=True + -p {tox_root} + python {repository_root}/eng/tox/run_pyright.py -t {tox_root} --next=True [testenv:verifytypes] skipsdist = true skip_install = true usedevelop = true -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5019 @@ -220,18 +219,18 @@ deps = commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist python {repository_root}/eng/tox/create_dependencies_and_install.py \ - -p {toxinidir} - python {repository_root}/eng/tox/run_verifytypes.py -t {toxinidir} + -p {tox_root} + python {repository_root}/eng/tox/run_verifytypes.py -t {tox_root} [testenv:whl_no_aio] skipsdist = true skip_install = true -changedir = {toxinidir} +changedir = {tox_root} deps = {[base]deps} setenv = @@ -239,20 +238,20 @@ setenv = PROXY_URL=http://localhost:5004 commands = - python -m pip uninstall aiohttp --yes - python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} - python {repository_root}/eng/tox/try_import.py aiohttp -p {toxinidir} + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} + python {repository_root}/eng/tox/try_import.py aiohttp -p {tox_root} python -m pip freeze pytest \ {[testenv]default_pytest_params} \ --ignore-glob='*async*.py' \ {posargs} \ - {toxinidir} + {tox_root} [testenv:sdist] skipsdist = true skip_install = true -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5005 @@ -261,7 +260,7 @@ deps = commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {envtmpdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist python -m pip freeze @@ -269,14 +268,14 @@ commands = {posargs} \ --no-cov \ {[testenv]ignore_args} \ - {toxinidir} + {tox_root} [testenv:develop] skipsdist = false skip_install = false usedevelop = true -changedir = {toxinidir} +changedir = {tox_root} deps = {[base]deps} setenv = @@ -286,13 +285,13 @@ commands = pytest \ {posargs} \ --ignore=.tox \ - {toxinidir} + {tox_root} [testenv:sphinx] skipsdist = true skip_install = true -changedir = {toxinidir} +changedir = {tox_root} passenv = * setenv = {[testenv]setenv} @@ -307,25 +306,25 @@ deps = commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/eng/tox/prep_sphinx_env.py -d {distdir} -t {toxinidir} + python {repository_root}/eng/tox/prep_sphinx_env.py -d {distdir} -t {tox_root} python {repository_root}/eng/tox/run_sphinx_apidoc.py \ -w {distdir} \ - -r {toxinidir} + -r {tox_root} python {repository_root}/eng/tox/run_sphinx_build.py \ -w {distdir}/unzipped/docgen \ -o {distdir}/site \ - -r {toxinidir} + -r {tox_root} [testenv:depends] platform = linux: linux macos: darwin windows: win32 -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5008 @@ -334,20 +333,20 @@ deps = cryptography<4 commands = python -m pip install {repository_root}/tools/azure-sdk-tools --no-deps - python {repository_root}/eng/tox/sanitize_setup.py -t {toxinidir} + python {repository_root}/eng/tox/sanitize_setup.py -t {tox_root} python {repository_root}/eng/tox/create_package_and_install.py \ -d {envtmpdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --force-create true python -m pip freeze - python {repository_root}/eng/tox/import_all.py -t {toxinidir} + python {repository_root}/eng/tox/import_all.py -t {tox_root} [testenv:verifywhl] skipsdist = true skip_install = true -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5009 @@ -355,14 +354,14 @@ deps = {[packaging]pkgs} commands = python -m pip install {repository_root}/tools/azure-sdk-tools --no-deps - python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} --skip-install True - python {repository_root}/eng/tox/verify_whl.py -d {envtmpdir} -t {toxinidir} + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} --skip-install True + python {repository_root}/eng/tox/verify_whl.py -d {envtmpdir} -t {tox_root} [testenv:verifysdist] skipsdist = true skip_install = true -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5010 @@ -370,33 +369,33 @@ deps = {[packaging]pkgs} commands = python -m pip install {repository_root}/tools/azure-sdk-tools --no-deps - python {toxinidir}/setup.py --q sdist --format zip -d {envtmpdir} - python {repository_root}/eng/tox/verify_sdist.py -d {envtmpdir} -t {toxinidir} + python {tox_root}/setup.py --q sdist --format zip -d {envtmpdir} + python {repository_root}/eng/tox/verify_sdist.py -d {envtmpdir} -t {tox_root} [testenv:devtest] deps = {[base]deps} -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5011 commands = - python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} - python {repository_root}/eng/tox/install_dev_build_dependency.py -t {toxinidir} + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} + python {repository_root}/eng/tox/install_dev_build_dependency.py -t {tox_root} pytest \ {[testenv]default_pytest_params} \ --ignore=.tox \ {posargs} \ - {toxinidir} + {tox_root} [deptestcommands] commands = - python {repository_root}/eng/tox/install_depend_packages.py -t {toxinidir} -d {env:DEPENDENCY_TYPE:} -w {envtmpdir} - python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir} --pre-download-disabled + python {repository_root}/eng/tox/install_depend_packages.py -t {tox_root} -d {env:DEPENDENCY_TYPE:} -w {envtmpdir} + python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} --pre-download-disabled python -m pip freeze python {repository_root}/eng/tox/verify_installed_packages.py --packages-file {envtmpdir}/packages.txt - pytest {[testenv]default_pytest_params} {posargs} --no-cov {toxinidir} + pytest {[testenv]default_pytest_params} {posargs} --no-cov {tox_root} [testenv:latestdependency] @@ -404,7 +403,7 @@ deps = {[dependencytools]deps} {[tools]deps} changedir = - {toxinidir} + {tox_root} passenv = * setenv = {[testenv]setenv} @@ -421,7 +420,7 @@ deps = azure-mgmt-storage<15.0.0 {[dependencytools]deps} {[tools]deps} -changedir = {toxinidir} +changedir = {tox_root} passenv = * setenv = {[testenv]setenv} @@ -445,7 +444,7 @@ commands = # install API stub generator python -m pip install -r {repository_root}/eng/apiview_reqs.txt --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" python -m pip freeze - python {repository_root}/eng/tox/run_apistubgen.py -t {toxinidir} -w {envtmpdir} {posargs} + python {repository_root}/eng/tox/run_apistubgen.py -t {tox_root} -w {envtmpdir} {posargs} [testenv:bandit] @@ -462,11 +461,11 @@ deps = commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {envtmpdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist python -m pip freeze - python {repository_root}/eng/tox/run_bandit.py -t {toxinidir} + python {repository_root}/eng/tox/run_bandit.py -t {tox_root} [testenv:samples] @@ -482,14 +481,14 @@ deps = subprocess32; python_version < '3.5' commands = python -m pip freeze - python {repository_root}/scripts/devops_tasks/test_run_samples.py -t {toxinidir} + python {repository_root}/scripts/devops_tasks/test_run_samples.py -t {tox_root} [testenv:breaking] skipsdist = true skip_install = true usedevelop = true -changedir = {toxinidir} +changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5017 @@ -500,7 +499,7 @@ deps = commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {distdir} \ - -p {toxinidir} \ + -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/scripts/breaking_changes_checker/detect_breaking_changes.py -t {toxinidir} + python {repository_root}/scripts/breaking_changes_checker/detect_breaking_changes.py -t {tox_root} From c453c0be0656e02fbe18a38e19d53482b35e393a Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 9 Apr 2023 14:31:51 -0400 Subject: [PATCH 04/42] refactor: Flatten some commands that are no longer super long --- eng/tox/tox.ini | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index b105ff48a283..ea91a8319dd9 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -70,10 +70,7 @@ commands = python -m pip --version python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} python -m pip freeze - pytest \ - {[testenv]default_pytest_params} \ - {posargs} \ - {tox_root} + pytest {[testenv]default_pytest_params} {posargs} {tox_root} [testenv:pylint] @@ -200,8 +197,7 @@ commands = -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/eng/tox/create_dependencies_and_install.py \ - -p {tox_root} + python {repository_root}/eng/tox/create_dependencies_and_install.py -p {tox_root} python {repository_root}/eng/tox/run_pyright.py -t {tox_root} --next=True @@ -222,8 +218,7 @@ commands = -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/eng/tox/create_dependencies_and_install.py \ - -p {tox_root} + python {repository_root}/eng/tox/create_dependencies_and_install.py -p {tox_root} python {repository_root}/eng/tox/run_verifytypes.py -t {tox_root} @@ -241,11 +236,7 @@ commands = python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} python {repository_root}/eng/tox/try_import.py aiohttp -p {tox_root} python -m pip freeze - pytest \ - {[testenv]default_pytest_params} \ - --ignore-glob='*async*.py' \ - {posargs} \ - {tox_root} + pytest {[testenv]default_pytest_params} --ignore-glob='*async*.py' {posargs} {tox_root} [testenv:sdist] @@ -264,11 +255,7 @@ commands = -w {envtmpdir} \ --package-type sdist python -m pip freeze - pytest \ - {posargs} \ - --no-cov \ - {[testenv]ignore_args} \ - {tox_root} + pytest {posargs} --no-cov {[testenv]ignore_args} {tox_root} [testenv:develop] @@ -282,10 +269,7 @@ setenv = {[testenv]setenv} PROXY_URL=http://localhost:5006 commands = - pytest \ - {posargs} \ - --ignore=.tox \ - {tox_root} + pytest {posargs} --ignore=.tox {tox_root} [testenv:sphinx] @@ -310,9 +294,7 @@ commands = -w {envtmpdir} \ --package-type sdist python {repository_root}/eng/tox/prep_sphinx_env.py -d {distdir} -t {tox_root} - python {repository_root}/eng/tox/run_sphinx_apidoc.py \ - -w {distdir} \ - -r {tox_root} + python {repository_root}/eng/tox/run_sphinx_apidoc.py -w {distdir} -r {tox_root} python {repository_root}/eng/tox/run_sphinx_build.py \ -w {distdir}/unzipped/docgen \ @@ -382,11 +364,7 @@ setenv = commands = python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} python {repository_root}/eng/tox/install_dev_build_dependency.py -t {tox_root} - pytest \ - {[testenv]default_pytest_params} \ - --ignore=.tox \ - {posargs} \ - {tox_root} + pytest {[testenv]default_pytest_params} --ignore=.tox {posargs} {tox_root} [deptestcommands] From 04a8b7864d53e42787e21f8ac2ad411c549183d0 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 9 Apr 2023 14:35:27 -0400 Subject: [PATCH 05/42] refactor: Make a pytest section --- eng/tox/tox.ini | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index ea91a8319dd9..c8b2c34a09f0 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -41,10 +41,11 @@ pkgs = urllib3==1.26.12 tomli==2.0.1 +[pytest] +ignore_args=--ignore=.tox --ignore=build --ignore=.eggs +default_args = --junitxml={tox_root}/test-junit-{envname}.xml --verbose --durations=10 --ignore=azure {[pytest]ignore_args} [testenv] -ignore_args=--ignore=.tox --ignore=build --ignore=.eggs -default_pytest_params = --junitxml={tox_root}/test-junit-{envname}.xml --verbose --durations=10 --ignore=azure {[testenv]ignore_args} parallel_show_output =True skip_install = true skipsdist = true @@ -70,7 +71,7 @@ commands = python -m pip --version python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} python -m pip freeze - pytest {[testenv]default_pytest_params} {posargs} {tox_root} + pytest {[pytest]default_args} {posargs} {tox_root} [testenv:pylint] @@ -236,7 +237,7 @@ commands = python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} python {repository_root}/eng/tox/try_import.py aiohttp -p {tox_root} python -m pip freeze - pytest {[testenv]default_pytest_params} --ignore-glob='*async*.py' {posargs} {tox_root} + pytest {[pytest]default_args} --ignore-glob='*async*.py' {posargs} {tox_root} [testenv:sdist] @@ -255,7 +256,7 @@ commands = -w {envtmpdir} \ --package-type sdist python -m pip freeze - pytest {posargs} --no-cov {[testenv]ignore_args} {tox_root} + pytest {posargs} --no-cov {[pytest]ignore_args} {tox_root} [testenv:develop] @@ -364,7 +365,7 @@ setenv = commands = python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} python {repository_root}/eng/tox/install_dev_build_dependency.py -t {tox_root} - pytest {[testenv]default_pytest_params} --ignore=.tox {posargs} {tox_root} + pytest {[pytest]default_args} --ignore=.tox {posargs} {tox_root} [deptestcommands] @@ -373,7 +374,7 @@ commands = python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} --pre-download-disabled python -m pip freeze python {repository_root}/eng/tox/verify_installed_packages.py --packages-file {envtmpdir}/packages.txt - pytest {[testenv]default_pytest_params} {posargs} --no-cov {tox_root} + pytest {[pytest]default_args} {posargs} --no-cov {tox_root} [testenv:latestdependency] From 7d3da58e179c7907ec1d89d66cb98f23a9f3cf63 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 9 Apr 2023 14:52:33 -0400 Subject: [PATCH 06/42] refactor: Remove `changedir = {tox_root}` This is the default behavior, see: https://tox.wiki/en/4.4.11/config.html#change_dir-external --- eng/tox/tox.ini | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index c8b2c34a09f0..ed6dffe6a1ea 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -65,7 +65,6 @@ setenv = VIRTUALENV_PIP=20.3.3 VIRTUALENV_SETUPTOOLS=67.6.0 deps = {[base]deps} -changedir = {tox_root} install_command = python -m pip install {opts} {packages} --cache-dir {tox_root}/../.tox_pip_cache_{envname} --ignore-installed commands = python -m pip --version @@ -78,7 +77,6 @@ commands = skipsdist = true skip_install = true usedevelop = false -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5002 @@ -97,7 +95,6 @@ commands = skipsdist = true skip_install = true usedevelop = false -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5002 @@ -117,7 +114,6 @@ commands = skipsdist = true skip_install = true usedevelop = true -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5003 @@ -140,7 +136,6 @@ commands = skipsdist = true skip_install = true usedevelop = true -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5020 @@ -164,7 +159,6 @@ commands = skipsdist = true skip_install = true usedevelop = true -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5018 @@ -185,7 +179,6 @@ commands = skipsdist = true skip_install = true usedevelop = true -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5021 @@ -206,7 +199,6 @@ commands = skipsdist = true skip_install = true usedevelop = true -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5019 @@ -226,7 +218,6 @@ commands = [testenv:whl_no_aio] skipsdist = true skip_install = true -changedir = {tox_root} deps = {[base]deps} setenv = @@ -243,7 +234,6 @@ commands = [testenv:sdist] skipsdist = true skip_install = true -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5005 @@ -263,7 +253,6 @@ commands = skipsdist = false skip_install = false usedevelop = true -changedir = {tox_root} deps = {[base]deps} setenv = @@ -276,7 +265,6 @@ commands = [testenv:sphinx] skipsdist = true skip_install = true -changedir = {tox_root} passenv = * setenv = {[testenv]setenv} @@ -307,7 +295,6 @@ commands = platform = linux: linux macos: darwin windows: win32 -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5008 @@ -329,7 +316,6 @@ commands = [testenv:verifywhl] skipsdist = true skip_install = true -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5009 @@ -344,7 +330,6 @@ commands = [testenv:verifysdist] skipsdist = true skip_install = true -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5010 @@ -358,7 +343,6 @@ commands = [testenv:devtest] deps = {[base]deps} -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5011 @@ -381,8 +365,6 @@ commands = deps = {[dependencytools]deps} {[tools]deps} -changedir = - {tox_root} passenv = * setenv = {[testenv]setenv} @@ -399,7 +381,6 @@ deps = azure-mgmt-storage<15.0.0 {[dependencytools]deps} {[tools]deps} -changedir = {tox_root} passenv = * setenv = {[testenv]setenv} @@ -467,7 +448,6 @@ commands = skipsdist = true skip_install = true usedevelop = true -changedir = {tox_root} setenv = {[testenv]setenv} PROXY_URL=http://localhost:5017 From 48291cdc6b916fa27a3b6666610869dee65f2c15 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 9 Apr 2023 16:45:42 -0400 Subject: [PATCH 07/42] fix: {distdir} is deprecated See: https://tox.wiki/en/latest/upgrading.html#removed-tox-ini-keys --- eng/tox/tox.ini | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index ed6dffe6a1ea..55cee739ea44 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -85,7 +85,7 @@ deps = commands = python -m pip install azure-pylint-guidelines-checker==0.0.5 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" python {repository_root}/eng/tox/create_package_and_install.py \ - -d {distdir} \ + -d {envtmpdir}/dist \ -p {tox_root} \ -w {envtmpdir} \ --package-type sdist @@ -104,7 +104,7 @@ commands = python -m pip install pylint==2.15.8 python -m pip install azure-pylint-guidelines-checker==0.0.8 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" python {repository_root}/eng/tox/create_package_and_install.py \ - -d {distdir} \ + -d {envtmpdir}/dist \ -p {tox_root} \ -w {envtmpdir} \ --package-type sdist @@ -126,7 +126,7 @@ deps = types-redis==4.3.21.2 commands = python {repository_root}/eng/tox/create_package_and_install.py \ - -d {distdir} \ + -d {envtmpdir}/dist \ -p {tox_root} \ -w {envtmpdir} \ --package-type sdist @@ -148,7 +148,7 @@ deps = types-redis commands = python {repository_root}/eng/tox/create_package_and_install.py \ - -d {distdir} \ + -d {envtmpdir}/dist \ -p {tox_root} \ -w {envtmpdir} \ --package-type sdist @@ -167,7 +167,7 @@ deps = pyright==1.1.287 commands = python {repository_root}/eng/tox/create_package_and_install.py \ - -d {distdir} \ + -d {envtmpdir}/dist \ -p {tox_root} \ -w {envtmpdir} \ --package-type sdist @@ -187,7 +187,7 @@ deps = pyright commands = python {repository_root}/eng/tox/create_package_and_install.py \ - -d {distdir} \ + -d {envtmpdir}/dist \ -p {tox_root} \ -w {envtmpdir} \ --package-type sdist @@ -207,7 +207,7 @@ deps = pyright==1.1.287 commands = python {repository_root}/eng/tox/create_package_and_install.py \ - -d {distdir} \ + -d {envtmpdir}/dist \ -p {tox_root} \ -w {envtmpdir} \ --package-type sdist @@ -278,16 +278,15 @@ deps = m2r==0.2.1 commands = python {repository_root}/eng/tox/create_package_and_install.py \ - -d {distdir} \ + -d {envtmpdir}/dist \ -p {tox_root} \ -w {envtmpdir} \ --package-type sdist - python {repository_root}/eng/tox/prep_sphinx_env.py -d {distdir} -t {tox_root} - python {repository_root}/eng/tox/run_sphinx_apidoc.py -w {distdir} -r {tox_root} - + python {repository_root}/eng/tox/prep_sphinx_env.py -d {envtmpdir}/dist -t {tox_root} + python {repository_root}/eng/tox/run_sphinx_apidoc.py -w {envtmpdir}/dist -r {tox_root} python {repository_root}/eng/tox/run_sphinx_build.py \ - -w {distdir}/unzipped/docgen \ - -o {distdir}/site \ + -w {envtmpdir}/dist/unzipped/docgen \ + -o {envtmpdir}/dist/site \ -r {tox_root} @@ -457,7 +456,7 @@ deps = -e {repository_root}/scripts/breaking_changes_checker commands = python {repository_root}/eng/tox/create_package_and_install.py \ - -d {distdir} \ + -d {envtmpdir}/dist \ -p {tox_root} \ -w {envtmpdir} \ --package-type sdist From c0fd18b052f04ef27d35d073b1352075c5402bdb Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 9 Apr 2023 16:59:47 -0400 Subject: [PATCH 08/42] fix: Remove --ignore-installed from pip command --ignore-installed can break a python installation if multiple conflicting versions of a package are installed --- eng/tox/tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index 55cee739ea44..b62573454ef1 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -65,7 +65,7 @@ setenv = VIRTUALENV_PIP=20.3.3 VIRTUALENV_SETUPTOOLS=67.6.0 deps = {[base]deps} -install_command = python -m pip install {opts} {packages} --cache-dir {tox_root}/../.tox_pip_cache_{envname} --ignore-installed +install_command = python -m pip install {opts} {packages} --cache-dir {tox_root}/../.tox_pip_cache_{envname} commands = python -m pip --version python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} From df6b4282331e7ee5742163c98b4e6bc49955f133 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 9 Apr 2023 20:33:35 -0400 Subject: [PATCH 09/42] refactor: Add descriptions to all tox environments --- eng/tox/tox.ini | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index b62573454ef1..3a338dca6da9 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -74,6 +74,7 @@ commands = [testenv:pylint] +description=Lints a package with a pinned version of pylint skipsdist = true skip_install = true usedevelop = false @@ -92,6 +93,8 @@ commands = python {repository_root}/eng/tox/run_pylint.py -t {tox_root} [testenv:next-pylint] +description=Lints a package with pylint (version {[testenv:next-pylint]pylint_version}) +pylint_version=2.15.8 skipsdist = true skip_install = true usedevelop = false @@ -101,7 +104,7 @@ setenv = deps = {[base]deps} commands = - python -m pip install pylint==2.15.8 + python -m pip install {[testenv:next-pylint]pylint_version} python -m pip install azure-pylint-guidelines-checker==0.0.8 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" python {repository_root}/eng/tox/create_package_and_install.py \ -d {envtmpdir}/dist \ @@ -111,6 +114,8 @@ commands = python {repository_root}/eng/tox/run_pylint.py -t {tox_root} --next=True [testenv:mypy] +description=Typechecks a package with mypy (version {[testenv:mypy]mypy_version}) +mypy_version=1.0.0 skipsdist = true skip_install = true usedevelop = true @@ -119,7 +124,7 @@ setenv = PROXY_URL=http://localhost:5003 deps = {[base]deps} - mypy==1.0.0 + mypy=={[testenv:mypy]mypy_version} types-chardet==4.0.3 types-requests==2.27.9 types-six==1.16.10 @@ -133,6 +138,7 @@ commands = python {repository_root}/eng/tox/run_mypy.py -t {tox_root} [testenv:next-mypy] +description=Typechecks a package with the latest version of mypy skipsdist = true skip_install = true usedevelop = true @@ -156,6 +162,8 @@ commands = [testenv:pyright] +description=Typechecks a package with pyright (version {[testenv:pyright]pyright_version}) +pyright_version=1.1.287 skipsdist = true skip_install = true usedevelop = true @@ -164,7 +172,7 @@ setenv = PROXY_URL=http://localhost:5018 deps = {[base]deps} - pyright==1.1.287 + pyright=={[testenv:pyright]pyright_version} commands = python {repository_root}/eng/tox/create_package_and_install.py \ -d {envtmpdir}/dist \ @@ -176,6 +184,7 @@ commands = [testenv:next-pyright] +description=Typechecks a package with the latest version of static type-checker pyright skipsdist = true skip_install = true usedevelop = true @@ -196,6 +205,7 @@ commands = [testenv:verifytypes] +description=Verifies the "type completeness" of a package with pyright skipsdist = true skip_install = true usedevelop = true @@ -216,6 +226,7 @@ commands = [testenv:whl_no_aio] +description=Builds a wheel without aio and runs tests skipsdist = true skip_install = true deps = @@ -231,7 +242,11 @@ commands = pytest {[pytest]default_args} --ignore-glob='*async*.py' {posargs} {tox_root} +[testenv:whl] +description=Builds a wheel and runs tests + [testenv:sdist] +description=Builds a source distribution and runs tests skipsdist = true skip_install = true setenv = @@ -250,6 +265,7 @@ commands = [testenv:develop] +description=Tests a package skipsdist = false skip_install = false usedevelop = true @@ -263,6 +279,7 @@ commands = [testenv:sphinx] +description=Builds a package's documentation with sphinx skipsdist = true skip_install = true passenv = * @@ -291,6 +308,7 @@ commands = [testenv:depends] +description = Ensures all modules in a target package can be successfully imported platform = linux: linux macos: darwin windows: win32 @@ -313,6 +331,7 @@ commands = [testenv:verifywhl] +description=Verify directories included in whl and contents in manifest file skipsdist = true skip_install = true setenv = @@ -327,6 +346,7 @@ commands = [testenv:verifysdist] +description=Verify directories included in sdist and contents in manifest file. Also ensures that py.typed configuration is correct within the setup.py skipsdist = true skip_install = true setenv = @@ -341,6 +361,7 @@ commands = [testenv:devtest] +description=Tests a package against dependencies installed from a dev index deps = {[base]deps} setenv = {[testenv]setenv} @@ -361,6 +382,7 @@ commands = [testenv:latestdependency] +description=Tests a package against the released, upper-bound versions of its azure dependencies deps = {[dependencytools]deps} {[tools]deps} @@ -374,6 +396,7 @@ commands = [testenv:mindependency] +description=Tests a package against the released, lower-bound versions of its azure dependencies deps = azure-mgmt-keyvault<7.0.0 azure-mgmt-resource<15.0.0 @@ -390,6 +413,7 @@ commands = [testenv:apistub] +description=Generate an api stub of a package ( for https://apiview.dev ) skipsdist = true skip_install = true usedevelop = false @@ -407,6 +431,7 @@ commands = [testenv:bandit] +description=Runs bandit, a tool to find common security issues, against a package skipsdist = true skip_install = true usedevelop = false @@ -428,6 +453,7 @@ commands = [testenv:samples] +description=Runs a package's samples skipsdist = false skip_install = false usedevelop = false @@ -444,6 +470,7 @@ commands = [testenv:breaking] +description=Runs the breaking changes checker against a package skipsdist = true skip_install = true usedevelop = true From 0280e052f7300d3b9b772628b0c338c2f204eb79 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Mon, 10 Apr 2023 19:04:19 -0400 Subject: [PATCH 10/42] fix: Remove ineffective platform config platform = linux: linux macos: darwin windows: win32 Setting the above in the base environment has no effect: * None of the environments have {linux,macos,windows} in the name, so the platform config is always empty. --- eng/tox/tox.ini | 6 ------ 1 file changed, 6 deletions(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index 3a338dca6da9..f23648d0530b 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -50,9 +50,6 @@ parallel_show_output =True skip_install = true skipsdist = true usedevelop = false -platform = linux: linux - macos: darwin - windows: win32 passenv = * download=true requires= @@ -309,9 +306,6 @@ commands = [testenv:depends] description = Ensures all modules in a target package can be successfully imported -platform = linux: linux - macos: darwin - windows: win32 setenv = {[testenv]setenv} PROXY_URL=http://localhost:5008 From 359c9dbf88c8e6a3a8e839d10e41318ff18c95f1 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 30 Apr 2023 15:16:41 -0400 Subject: [PATCH 11/42] chore: Bump `tox` to `>4.4.11` and no longer install `tox-monorepo` tox4 natively solves what `tox-monorepo` was written to solve: `--root` lets you set `toxinidir` independently of the config file in use. 4.4.11 was chosen as the cutoff since it was the first release to include a fix to `--root` that prevented `{work_dir}` from being changed when `{toxinidir}` was changed by `--root`. `tox-monorepo` should no longer be needed --- eng/ci_tools.txt | 3 +-- eng/pipelines/templates/jobs/tests-nightly-python.yml | 6 +++--- eng/regression_tools.txt | 3 +-- sdk/media/azure-media-analytics-edge/dev_requirements.txt | 3 +-- .../azure-media-videoanalyzer-edge/dev_requirements.txt | 3 +-- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/eng/ci_tools.txt b/eng/ci_tools.txt index 641ce899429c..8d1a56c59417 100644 --- a/eng/ci_tools.txt +++ b/eng/ci_tools.txt @@ -6,8 +6,7 @@ virtualenv==20.13.2 wheel==0.37.0 Jinja2==2.11.2 packaging==20.4 -tox==3.25.1 -tox-monorepo==0.1.2 +tox==4.5.0 twine==3.1.1; python_version >= '3.6' pathlib2==2.3.5 doc-warden==0.7.2 diff --git a/eng/pipelines/templates/jobs/tests-nightly-python.yml b/eng/pipelines/templates/jobs/tests-nightly-python.yml index 1f61661382a8..516b71a4bed2 100644 --- a/eng/pipelines/templates/jobs/tests-nightly-python.yml +++ b/eng/pipelines/templates/jobs/tests-nightly-python.yml @@ -22,7 +22,7 @@ jobs: - script: | python -m pip freeze python -m pip --version - python -m pip install setuptools==58.3.0 wheel==0.37.0 tox==3.24.3 tox-monorepo==0.1.2 packaging==21.0 requests + python -m pip install setuptools==58.3.0 wheel==0.37.0 tox==4.5.0 packaging==21.0 requests python -m pip install $(Build.SourcesDirectory)/tools/azure-sdk-tools[build] displayName: Install Dependencies @@ -67,7 +67,7 @@ jobs: sudo apt-get install build-essential -y python -m pip freeze python -m pip --version - python -m pip install setuptools==58.3.0 wheel==0.37.0 tox==3.24.3 tox-monorepo==0.1.2 packaging==21.0 requests + python -m pip install setuptools==58.3.0 wheel==0.37.0 tox==4.5.0 packaging==21.0 requests python -m pip install $(Build.SourcesDirectory)/tools/azure-sdk-tools[build] displayName: Install Dependencies @@ -131,7 +131,7 @@ jobs: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python3 get-pip.py python3 -m pip install setuptools==67.6.0 wheel - python3 -m pip install tox tox-monorepo packaging twine beautifulsoup4 + python3 -m pip install tox packaging twine beautifulsoup4 python3 --version cd $(Build.SourcesDirectory) python3 ./scripts/devops_tasks/setup_execute_tests.py "$(BuildTargetingString)" --junitxml="junit/test_results_38.xml" --toxenv="whl" --filter-type="None" diff --git a/eng/regression_tools.txt b/eng/regression_tools.txt index 6d60efad586e..46b7b8c2632b 100644 --- a/eng/regression_tools.txt +++ b/eng/regression_tools.txt @@ -6,8 +6,7 @@ virtualenv==20.0.23 wheel==0.34.2 Jinja2==2.11.2 packaging==20.4 -tox==3.25.1 -tox-monorepo==0.1.2 +tox==4.5.0 twine==1.15.0; python_version == '2.7' or python_version == '3.5' twine==3.1.1; python_version >= '3.6' pathlib2==2.3.5 diff --git a/sdk/media/azure-media-analytics-edge/dev_requirements.txt b/sdk/media/azure-media-analytics-edge/dev_requirements.txt index 08b52149d5f2..79416d013ec2 100644 --- a/sdk/media/azure-media-analytics-edge/dev_requirements.txt +++ b/sdk/media/azure-media-analytics-edge/dev_requirements.txt @@ -4,5 +4,4 @@ -e ../../identity/azure-identity aiohttp>=3.0; python_version >= '3.5' aiodns>=2.0; python_version >= '3.5' -tox>=3.20.0 -tox-monorepo>=0.1.2 \ No newline at end of file +tox>=4.4.11 diff --git a/sdk/videoanalyzer/azure-media-videoanalyzer-edge/dev_requirements.txt b/sdk/videoanalyzer/azure-media-videoanalyzer-edge/dev_requirements.txt index 6d14633f7d01..087574a22d2a 100644 --- a/sdk/videoanalyzer/azure-media-videoanalyzer-edge/dev_requirements.txt +++ b/sdk/videoanalyzer/azure-media-videoanalyzer-edge/dev_requirements.txt @@ -4,5 +4,4 @@ -e ../../identity/azure-identity aiohttp>=3.0 aiodns>=2.0 -tox>=3.20.0 -tox-monorepo>=0.1.2 \ No newline at end of file +tox>=4.4.11 From 796e553590793a583567095902f3901f5a9b386a Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 30 Apr 2023 16:35:38 -0400 Subject: [PATCH 12/42] docs: Update CONTRIBUTING.md to use tox 4 commands * References to tox-monorepo were removed * Replaced discussion of `tox -l` with tox4's `tox list` * Updated examples to use `--root` --- CONTRIBUTING.md | 71 +++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eafc195fdce5..040649627cfa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ The Azure SDK team's Python CI leverages the tool `tox` to distribute tests to v Traditionally, the `tox.ini` file for a package sits _alongside the setup.py_ in source code. The `azure-sdk-for-python` necessarily does not adhere to this policy. There are over one-hundred packages contained here-in. That's a lot of `tox.ini` files to maintain! -Instead, the CI system leverages an tox plugin called `tox-monorepo`. This plugin allows `tox` to act as if the `tox.ini` is located in whatever directory you executed tox in! +Instead, the CI system leverages the `--root` argument which is new to `tox4`. The `--root` argument allows `tox` to act as if the `tox.ini` is located in whatever directory you specify! #### Tox Environments @@ -32,26 +32,47 @@ Internally `tox` leverages `virtualenv` to create each test environment's virtua This means that once the `tox` workflow is in place, all tests will be executed _within a virtual environment._ -To see the default environments from a specific `tox.ini` file, use the command `tox -l` in the same directory as the file itself. - -> sdk-for-python/eng/tox> tox -l - -``` - -whl -sdist - +You can use the command `tox list` to list all the environments provided by a `tox.ini` file. You can either use that command in the +same directory as the file itself, or use the `--conf` argument to specify the path to it directly. + + +Sample output of `tox list`: + +``` +sdk-for-python/eng/tox> tox list +default environments: +whl -> Builds a wheel and runs tests +sdist -> Builds a source distribution and runs tests + +additional environments: +pylint -> Lints a package with a pinned version of pylint +next-pylint -> Lints a package with pylint (version 2.15.8) +mypy -> Typechecks a package with mypy (version 1.0.0) +next-mypy -> Typechecks a package with the latest version of mypy +pyright -> Typechecks a package with pyright (version 1.1.287) +next-pyright -> Typechecks a package with the latest version of static type-checker pyright +verifytypes -> Verifies the "type completeness" of a package with pyright +whl_no_aio -> Builds a wheel without aio and runs tests +develop -> Tests a package +sphinx -> Builds a package's documentation with sphinx +depends -> Ensures all modules in a target package can be successfully imported +verifywhl -> Verify directories included in whl and contents in manifest file +verifysdist -> Verify directories included in sdist and contents in manifest file. Also ensures that py.typed configuration is correct within the setup.py +devtest -> Tests a package against dependencies installed from a dev index +latestdependency -> Tests a package against the released, upper-bound versions of its azure dependencies +mindependency -> Tests a package against the released, lower-bound versions of its azure dependencies +apistub -> Generate an api stub of a package ( for https://apiview.dev ) +bandit -> Runs bandit, a tool to find common security issues, against a package +samples -> Runs a package's samples +breaking -> Runs the breaking changes checker against a package ``` -Unfortunately, the command `tox -l` only returns the _default_ test builds. The common `tox.ini` file also supports `pylint` and `mypy` environments. - ### Example Usage of the common Azure SDK For Python `tox.ini` Basic usage of `tox` within this monorepo is: -1. `pip install tox<4 tox-monorepo` -2. `cd` to target package folder -3. run `tox -c path/to/tox.ini` +1. `pip install tox<5` +2. Run `tox -c path/to/tox.ini --root path/to/python_package` The common `tox.ini` location is `eng/tox/tox.ini` within the repository. @@ -59,13 +80,11 @@ If at any time you want to blow away the tox created virtual environments and st #### Example `azure-core` mypy -1. `cd` to `sdk/core/azure-core` -2. Run `tox -e mypy -c ../../../eng/tox/tox.ini` +1. Run `tox -e mypy -c ../../../eng/tox/tox.ini --root sdk/core/azure-core` #### Example `azure-storage-blob` tests -1. `cd` to `sdk/storage/azure-storage-blob` -2. Execute `tox -c ../../../eng/tox/tox.ini` +2. Execute `tox -c ../../../eng/tox/tox.ini --root sdk/storage/azure-storage-blob` Note that we didn't provide an `environment` argument for this example. Reason here is that the _default_ environment selected by our common `tox.ini` file is one that runs `pytest`. @@ -75,7 +94,7 @@ Used for test execution across the spectrum of all the platforms we want to supp * Installs the wheel, runs tests using the wheel ``` -\> tox -e whl -c +\> tox -e whl -c --root ``` @@ -87,7 +106,7 @@ Used for the local dev loop. ``` -\> tox -e sdist -c +\> tox -e sdist -c --root ``` @@ -95,7 +114,7 @@ Used for the local dev loop. Pylint install and run. ``` -\> tox -e pylint -c +\> tox -e pylint -c --root ``` @@ -103,14 +122,14 @@ Pylint install and run. Mypy install and run. ``` -\> tox -e mypy -c +\> tox -e mypy -c --root ``` #### `sphinx` environment Generate sphinx doc for this package. ``` -\> tox -e sphinx -c +\> tox -e sphinx -c --root ``` ### Custom Pytest Arguments @@ -120,7 +139,7 @@ Generate sphinx doc for this package. [Tox Documentation on Positional Arguments](https://tox.wiki/en/latest/config.html#substitutions-for-positional-arguments-in-commands) **Example: Invoke tox, breaking into the debugger on failure** -`tox -e whl -c ../../../eng/tox/tox.ini -- --pdb` +`tox -e whl -c --root -- --pdb` ### Performance Testing @@ -150,7 +169,7 @@ a. cd to package root folder b. run tox environment devtest ``` -\> tox -e devtest -c +\> tox -e devtest -c --root ``` This tox test( devtest) will fail if installed dependent packages are not dev build version. From d4966e744e04d73e4c18c04db99483cea3b81f18 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 30 Apr 2023 16:50:47 -0400 Subject: [PATCH 13/42] docs: Make `azure-media-{videoanalyzer,analytics}-edge`'s DevTips.md point to CONTRIBUTING.md for tox --- .../docs/DevTips.md | 22 ++----------------- .../docs/DevTips.md | 22 ++----------------- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/sdk/media/azure-media-analytics-edge/docs/DevTips.md b/sdk/media/azure-media-analytics-edge/docs/DevTips.md index 0b9d965181eb..e4d02545fd8f 100644 --- a/sdk/media/azure-media-analytics-edge/docs/DevTips.md +++ b/sdk/media/azure-media-analytics-edge/docs/DevTips.md @@ -11,26 +11,8 @@ Tox is the testing and virtual environment management tool that is used to verify our sdk will be installed correctly with different Python versions and interpreters. To run tox follow these instructions -``` -pip install tox tox-monorepo -cd path/to/target/folder -tox -c eng/tox/tox.ini -``` -To run a specific tox command from your directory use the following commands: -```bash -> tox -c ../../../eng/tox/tox.ini -e sphinx -> tox -c ../../../eng/tox/tox.ini -e pylint -> tox -c ../../../eng/tox/tox.ini -e mypy -> tox -c ../../../eng/tox/tox.ini -e whl -> tox -c ../../../eng/tox/tox.ini -e sdist -``` -A quick description of the five commands above: -* sphinx: documentation generation using the inline comments written in our code -* lint: runs pylint to make sure our code adheres to the style guidance -* mypy: runs the mypy static type checker for Python to make sure that our types are valid -* whl: creates a whl package for installing our package -* sdist: creates a zipped distribution of our files that the end user could install with pip - +Please see the repo's [contributing guide](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md#building-and-testing) for instructions +on how to install and run `tox`. ### Troubleshooting tox errors diff --git a/sdk/videoanalyzer/azure-media-videoanalyzer-edge/docs/DevTips.md b/sdk/videoanalyzer/azure-media-videoanalyzer-edge/docs/DevTips.md index 265409765a60..3d451b42e908 100644 --- a/sdk/videoanalyzer/azure-media-videoanalyzer-edge/docs/DevTips.md +++ b/sdk/videoanalyzer/azure-media-videoanalyzer-edge/docs/DevTips.md @@ -11,26 +11,8 @@ Tox is the testing and virtual environment management tool that is used to verify our sdk will be installed correctly with different Python versions and interpreters. To run tox follow these instructions -``` -pip install tox tox-monorepo -cd path/to/target/folder -tox -c eng/tox/tox.ini -``` -To run a specific tox command from your directory use the following commands: -```bash -> tox -c ../../../eng/tox/tox.ini -e sphinx -> tox -c ../../../eng/tox/tox.ini -e pylint -> tox -c ../../../eng/tox/tox.ini -e mypy -> tox -c ../../../eng/tox/tox.ini -e whl -> tox -c ../../../eng/tox/tox.ini -e sdist -``` -A quick description of the five commands above: -* sphinx: documentation generation using the inline comments written in our code -* lint: runs pylint to make sure our code adheres to the style guidance -* mypy: runs the mypy static type checker for Python to make sure that our types are valid -* whl: creates a whl package for installing our package -* sdist: creates a zipped distribution of our files that the end user could install with pip - +Please see the repo's [contributing guide](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md#building-and-testing) for instructions +on how to install and run `tox`. ### Troubleshooting tox errors From 47e62a035fe07ba43bec792ec964952644c17f83 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 30 Apr 2023 16:59:58 -0400 Subject: [PATCH 14/42] docs: Remove remaining references to tox-monorepo --- doc/dev/dev_setup.md | 5 ++--- doc/dev/static_type_checking.md | 4 ++-- doc/dev/tests.md | 2 +- scripts/breaking_changes_checker/README.md | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/dev/dev_setup.md b/doc/dev/dev_setup.md index 4f2171f49123..56e03f5e2585 100644 --- a/doc/dev/dev_setup.md +++ b/doc/dev/dev_setup.md @@ -33,11 +33,11 @@ or execute the various commands available in the toolbox. 4. Setup your development environment - Install the development requirements for a specific library (located in the `dev_requirements.txt` file at the root of the library), [Tox][tox], [Tox monorepo][tox_monorepo] and an editable install of your library. For example, to install requirements for `azure-ai-formrecognizer`: + Install the development requirements for a specific library (located in the `dev_requirements.txt` file at the root of the library), [Tox][tox] and an editable install of your library. For example, to install requirements for `azure-ai-formrecognizer`: ``` azure-sdk-for-python> cd sdk/formrecognizer/azure-ai-formrecognizer azure-sdk-for-python/sdk/formrecognizer/azure-ai-formrecognizer> pip install -r dev_requirements.txt - azure-sdk-for-python/sdk/formrecognizer/azure-ai-formrecognizer> pip install tox tox-monorepo + azure-sdk-for-python/sdk/formrecognizer/azure-ai-formrecognizer> pip install tox<5 azure-sdk-for-python/sdk/formrecognizer/azure-ai-formrecognizer> pip install -e . ``` @@ -59,5 +59,4 @@ Follow the instructions in the [Perform one-time test proxy setup][proxy_setup] [proxy_setup]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md#perform-one-time-test-proxy-setup [tests]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md [tox]: https://tox.readthedocs.io/en/latest/ -[tox_monorepo]: https://pypi.org/project/tox-monorepo/ [virtual_environment]: https://docs.python.org/3/tutorial/venv.html diff --git a/doc/dev/static_type_checking.md b/doc/dev/static_type_checking.md index 25a9c7a3a449..bcd01d032273 100644 --- a/doc/dev/static_type_checking.md +++ b/doc/dev/static_type_checking.md @@ -175,9 +175,9 @@ version of the type checker ships. All client libraries in the Python SDK repo a The easiest way to install and run the type checkers locally is with [tox](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md#tox). This reproduces the exact type checking -environment run in CI and brings in the third party stub packages necessary. To begin, first install `tox` and `tox-monorepo`: +environment run in CI and brings in the third party stub packages necessary. To begin, first install `tox`: -`pip install tox tox-monorepo` +`pip install tox<5` ### Run mypy diff --git a/doc/dev/tests.md b/doc/dev/tests.md index 5f22aa6581af..0986a303b0b1 100644 --- a/doc/dev/tests.md +++ b/doc/dev/tests.md @@ -124,7 +124,7 @@ If you have print statements in your tests for debugging you can add the `-s` fl ## Tox The Python SDK uses the [tox project](https://tox.readthedocs.io/en/latest/) to automate releases, run tests, run linters, and build our documentation. The `tox.ini` file is located at `azure-sdk-for-python/eng/tox/tox.ini` for reference. You do not need to make any changes to the tox file for tox to work with your project. Tox will create a directory (`.tox`) in the head of your branch. The first time you run tox commands it may take several moments, but subsequent runs will be quicker. To install tox run the following command from within your virtual environment. -`(env) > pip install tox tox-monorepo`. +`(env) > pip install tox<5`. To run a tox command from your directory use the following commands: ```cmd diff --git a/scripts/breaking_changes_checker/README.md b/scripts/breaking_changes_checker/README.md index 6846916da9de..d24eaafbc567 100644 --- a/scripts/breaking_changes_checker/README.md +++ b/scripts/breaking_changes_checker/README.md @@ -9,9 +9,9 @@ Add your package name to the `RUN_BREAKING_CHANGES_PACKAGES` found [here](https: ## Run locally with tox -**1) Install tox and tox-monorepo:** +**1) Install tox:** -`pip install tox tox-monorepo` +`pip install tox<5` **2) Run the `breaking` environment.** From ff88741a5d3b10e3993780405c8c9ee2aec85a91 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 30 Apr 2023 17:08:52 -0400 Subject: [PATCH 15/42] doc: Use `--root` throughout documentation --- doc/dev/pylint_checking.md | 4 ++-- doc/dev/sample_guide.md | 4 ++-- doc/dev/static_type_checking.md | 6 +++--- doc/dev/tests.md | 18 +++++++++--------- doc/eng_sys_checks.md | 20 ++++++++++---------- scripts/breaking_changes_checker/README.md | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/doc/dev/pylint_checking.md b/doc/dev/pylint_checking.md index ccc5494b59ed..e087542323c8 100644 --- a/doc/dev/pylint_checking.md +++ b/doc/dev/pylint_checking.md @@ -24,7 +24,7 @@ In the Azure SDK for Python repository, in addition to the standard pylint libra One way to run pylint is to run at the package level with tox: - .../azure-sdk-for-python/sdk/eventgrid/azure-eventgrid>tox -e pylint -c ../../../eng/tox/tox.ini + .../azure-sdk-for-python/sdk/eventgrid/azure-eventgrid>tox -e pylint -c ../../../eng/tox/tox.ini --root . If you don't want to use tox, you can also install and run pylint on its own: @@ -60,7 +60,7 @@ There is now a new step on the CI pipeline called `Run Pylint Next`. This is mer This next-pylint enviornment can also be run locally through tox: - tox -e next-pylint -c ../../../eng/tox/tox.ini + tox -e next-pylint -c ../../../eng/tox/tox.ini --root The errors generated by the `Run Pylint Next` step will not break your weekly test pipelines, but make sure to fix the warnings so that your client library is up to date for the next pylint release. diff --git a/doc/dev/sample_guide.md b/doc/dev/sample_guide.md index 056c02579ec8..7e8d2f905937 100644 --- a/doc/dev/sample_guide.md +++ b/doc/dev/sample_guide.md @@ -52,13 +52,13 @@ The given `START`/`END` keywords can be used in a [sphinx literalinclude][sphinx [Literalinclude example][literalinclude] The rendered code snippets are sensitive to the indentation in the sample file. Adjust the `dedent` accordingly to ensure the sample is captured accurately and not accidentally trimmed. -You can preview how published reference documentation will look by running [tox][tox]: `tox -e sphinx -c ../../../eng/tox/tox.ini`. +You can preview how published reference documentation will look by running [tox][tox]: `tox -e sphinx -c ../../../eng/tox/tox.ini --root `. ## Test run samples in CI live tests Per the [Python guidelines][snippet_guidelines], sample code and snippets should be test run in CI to ensure they remain functional. Samples should be run in the package's live test pipeline which is scheduled to run daily. To ensure samples do get tested as part of regular CI runs, add these [lines][live_tests] to the package's tests.yml. -You can test this CI step locally first, by utilizing [tox][tox] and running `tox -e samples -c ../../../eng/tox/tox.ini` at the package-level. +You can test this CI step locally first, by utilizing [tox][tox] and running `tox -e samples -c ../../../eng/tox/tox.ini --root `. The `Test Samples` step in CI will rely on the resources provisioned and environment variables used for running the package's tests. diff --git a/doc/dev/static_type_checking.md b/doc/dev/static_type_checking.md index bcd01d032273..bffd299a7446 100644 --- a/doc/dev/static_type_checking.md +++ b/doc/dev/static_type_checking.md @@ -185,7 +185,7 @@ mypy is currently pinned to version [1.0.0](https://pypi.org/project/mypy/1.0.0/ To run mypy on your library, run the tox mypy env at the package level: -`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e mypy -c ../../../eng/tox/tox.ini` +`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e mypy -c ../../../eng/tox/tox.ini --root .` If you don't want to use `tox` you can also install and run mypy on its own: @@ -217,7 +217,7 @@ Note that pyright requires that node is installed. The command-line [wrapper pac To run pyright on your library, run the tox pyright env at the package level: -`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e pyright -c ../../../eng/tox/tox.ini` +`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e pyright -c ../../../eng/tox/tox.ini --root .` If you don't want to use `tox` you can also install and run pyright on its own: @@ -249,7 +249,7 @@ from the code in the PR vs. the latest release on PyPi. To run verifytypes on your library, run the tox verifytypes env at the package level: -`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e verifytypes -c ../../../eng/tox/tox.ini` +`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e verifytypes -c ../../../eng/tox/tox.ini --root .` If you don't want to use `tox` you can also install and run pyright/verifytypes on its own: diff --git a/doc/dev/tests.md b/doc/dev/tests.md index 0986a303b0b1..fc8e5581d519 100644 --- a/doc/dev/tests.md +++ b/doc/dev/tests.md @@ -128,15 +128,15 @@ The Python SDK uses the [tox project](https://tox.readthedocs.io/en/latest/) to To run a tox command from your directory use the following commands: ```cmd -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini -e sphinx -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini -e pylint -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini -e mypy -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini -e pyright -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini -e verifytypes -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini -e whl -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini -e sdist -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini -e samples -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini -e apistub +(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e sphinx +(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e pylint +(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e mypy +(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e pyright +(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e verifytypes +(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e whl +(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e sdist +(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e samples +(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e apistub ``` A quick description of the five commands above: * sphinx: documentation generation using the inline comments written in our code diff --git a/doc/eng_sys_checks.md b/doc/eng_sys_checks.md index c22c12e4d76c..17ddb46fef7e 100644 --- a/doc/eng_sys_checks.md +++ b/doc/eng_sys_checks.md @@ -169,14 +169,14 @@ Analyze job in both nightly CI and pull request validation pipeline runs a set o [`MyPy`](https://pypi.org/project/mypy/) is a static analysis tool that runs type checking of python package. Following are the steps to run `MyPy` locally for a specific package: 1. Go to root of the package -2. Execute following command: `tox -e mypy -c ../../../eng/tox/tox.ini` +2. Execute following command: `tox -e mypy -c ../../../eng/tox/tox.ini --root .` ### Pyright [`Pyright`](https://github.com/microsoft/pyright/) is a static analysis tool that runs type checking of python package. Following are the steps to run `pyright` locally for a specific package: 1. Go to root of the package -2. Execute following command: `tox -e pyright -c ../../../eng/tox/tox.ini` +2. Execute following command: `tox -e pyright -c ../../../eng/tox/tox.ini --root .` ### Verifytypes @@ -184,7 +184,7 @@ Analyze job in both nightly CI and pull request validation pipeline runs a set o [`Verifytypes`](https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#verifying-type-completeness) is a feature of pyright that checks the type completeness of a python package. Following are the steps to run `verifytypes` locally for a specific package: 1. Go to root of the package -2. Execute following command: `tox -e verifytypes -c ../../../eng/tox/tox.ini` +2. Execute following command: `tox -e verifytypes -c ../../../eng/tox/tox.ini --root .` ### Pylint @@ -192,14 +192,14 @@ Analyze job in both nightly CI and pull request validation pipeline runs a set o [`Pylint`](https://pypi.org/project/pylint/) is a static analysis tool to run lint checking, it is automatically run on all PRs. Following are the steps to run `pylint` locally for a specific package. 1. Go to root of the package. -2. Execute following command: `tox -e pylint -c ../../../eng/tox/tox.ini` +2. Execute following command: `tox -e pylint -c ../../../eng/tox/tox.ini --root .` ### Bandit `Bandit` is static security analysis tool. This check is triggered for all Azure SDK package as part of analyze job. Following are the steps to `Bandit` tool locally for a specific package. 1. Got to package root directory. -2. Execute command: `tox -e bandit -c ../../../eng/tox/tox.ini` +2. Execute command: `tox -e bandit -c ../../../eng/tox/tox.ini --root .` ### ApiStubGen @@ -255,7 +255,7 @@ This test installs wheel of the package being tested and runs all tests cases in 1. Go to package root folder on a command line 2. Run following command - ``tox -e whl -c ../../../eng/tox/tox.ini`` + `tox -e whl -c ../../../eng/tox/tox.ini --root .` #### sdist @@ -263,7 +263,7 @@ This test installs sdist of the package being tested and runs all tests cases in 1. Go to package root folder on a command line 2. Run following command - ``tox -e sdist -c ../../../eng/tox/tox.ini`` + `tox -e sdist -c ../../../eng/tox/tox.ini --root .` #### depends @@ -273,7 +273,7 @@ Following is the command to run this test environment locally. 1. Go to package root folder on a command line 2. Run following command - ``tox -e sdist -c ../../../eng/tox/tox.ini`` + `tox -e sdist -c ../../../eng/tox/tox.ini --root .` ## Nightly CI Checks @@ -321,7 +321,7 @@ Note: Any dependency mentioned only in dev_requirements are not considered to id Tox name of this test is `latestdependency` and steps to manually run this test locally is as follows. 1. Go to package root. For e.g azure-storage-blob or azure-identity -2. Run command `Tox –e latestdependency –c ../../../tox/tox.ini` +2. Run command `tox –e latestdependency –c ../../../tox/tox.ini --root .` #### Minimum Dependency Test @@ -338,7 +338,7 @@ Tox name of this test is `mindependency` and steps to manually run this test loc 1. Go to package root. For e.g azure-storage-blob or azure-identity 2. Run following command -`Tox –e mindependency –c ../../../tox/tox.ini` +`tox –e mindependency –c ../../../tox/tox.ini --root .` #### Regression Test diff --git a/scripts/breaking_changes_checker/README.md b/scripts/breaking_changes_checker/README.md index d24eaafbc567..943091874315 100644 --- a/scripts/breaking_changes_checker/README.md +++ b/scripts/breaking_changes_checker/README.md @@ -17,7 +17,7 @@ Add your package name to the `RUN_BREAKING_CHANGES_PACKAGES` found [here](https: Here we run the breaking changes tool against azure-storage-blob, for example: -`C:\azure-sdk-for-python\sdk\storage\azure-storage-blob>tox -c ../../../eng/tox/tox.ini -e breaking` +`C:\azure-sdk-for-python\sdk\storage\azure-storage-blob>tox -c ../../../eng/tox/tox.ini --root . -e breaking` ## Ignore a reported breaking change From 4f99e5afc8d986a3e5bd42207d0b3c9568513625 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 30 Apr 2023 17:16:39 -0400 Subject: [PATCH 16/42] engsys: Make tox_harness set `{toxinidir}` when invoking tox --- scripts/devops_tasks/tox_harness.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/devops_tasks/tox_harness.py b/scripts/devops_tasks/tox_harness.py index 44239fb331e7..7c075d128b8f 100644 --- a/scripts/devops_tasks/tox_harness.py +++ b/scripts/devops_tasks/tox_harness.py @@ -259,7 +259,8 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace, optio destination_dev_req = os.path.join(package_dir, "dev_requirements.txt") tox_execution_array = [sys.executable, "-m", "tox"] - + # Tox command is run in package root, make tox set package root as {toxinidir} + tox_execution_array.append(["--root", "."]) local_options_array = options_array[:] # Get code coverage params for current package From 236e179d1ed6f1f8ec72c1158a542e8b3f9fd519 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 30 Apr 2023 17:27:52 -0400 Subject: [PATCH 17/42] engsys: Set required tox version in config --- eng/tox/tox.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index f23648d0530b..92d520c4a33a 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -6,6 +6,11 @@ # In all cases, whenever we install an azure-* package from a requirement (read: not a specific file), the only source will be from the dev feed. # once we've downloaded these dependencies, only then do we install other packages from pypi. [tox] +requires= + # Ensure that we're running a version of tox compatible with this config + # 4.4.10 is the lower bound because it incorporates a fix for a bug with `--root`: + # https://github.com/tox-dev/tox/pull/2962 + tox>=4.4.10 # note that this envlist is the default set of environments that will run if a target environment is not selected. envlist = whl,sdist From c27d32400a642ec587a24e4961c3c11c84024e20 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 30 Apr 2023 17:30:08 -0400 Subject: [PATCH 18/42] docs: Use the new url for tox docs --- CONTRIBUTING.md | 2 +- doc/dev/dev_setup.md | 2 +- doc/dev/tests.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 040649627cfa..447945ec9d0b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ If you want to contribute to a file that is generated (header contains `Code gen The Azure SDK team's Python CI leverages the tool `tox` to distribute tests to virtual environments, handle test dependency installation, and coordinate tooling reporting during PR/CI builds. This means that a dev working locally can reproduce _exactly_ what the build machine is doing. -[A Brief Overview of Tox](https://tox.readthedocs.io/en/latest/) +[A Brief Overview of Tox](https://tox.wiki/en/latest/) #### A Monorepo and Tox in Harmony diff --git a/doc/dev/dev_setup.md b/doc/dev/dev_setup.md index 56e03f5e2585..c324f23ec794 100644 --- a/doc/dev/dev_setup.md +++ b/doc/dev/dev_setup.md @@ -58,5 +58,5 @@ Follow the instructions in the [Perform one-time test proxy setup][proxy_setup] [python_39]: https://www.microsoft.com/p/python-39/9p7qfqmjrfp7 [proxy_setup]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md#perform-one-time-test-proxy-setup [tests]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md -[tox]: https://tox.readthedocs.io/en/latest/ +[tox]: https://tox.wiki/en/latest/ [virtual_environment]: https://docs.python.org/3/tutorial/venv.html diff --git a/doc/dev/tests.md b/doc/dev/tests.md index fc8e5581d519..6aaeb721e44c 100644 --- a/doc/dev/tests.md +++ b/doc/dev/tests.md @@ -123,7 +123,7 @@ If you have print statements in your tests for debugging you can add the `-s` fl ## Tox -The Python SDK uses the [tox project](https://tox.readthedocs.io/en/latest/) to automate releases, run tests, run linters, and build our documentation. The `tox.ini` file is located at `azure-sdk-for-python/eng/tox/tox.ini` for reference. You do not need to make any changes to the tox file for tox to work with your project. Tox will create a directory (`.tox`) in the head of your branch. The first time you run tox commands it may take several moments, but subsequent runs will be quicker. To install tox run the following command from within your virtual environment. +The Python SDK uses the [tox project](https://tox.wiki/en/latest/) to automate releases, run tests, run linters, and build our documentation. The `tox.ini` file is located at `azure-sdk-for-python/eng/tox/tox.ini` for reference. You do not need to make any changes to the tox file for tox to work with your project. Tox will create a directory (`.tox`) in the head of your branch. The first time you run tox commands it may take several moments, but subsequent runs will be quicker. To install tox run the following command from within your virtual environment. `(env) > pip install tox<5`. To run a tox command from your directory use the following commands: From e9929cb5b348457ea78f5602b3b766c4df2b9d0c Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Sun, 30 Apr 2023 19:03:37 -0400 Subject: [PATCH 19/42] docs: Add a callout that TOX_* environment variables control defaults * TOX_CONFIG_DIR can be used to permanently set --conf * TOX_ROOT_DIR can be used to permanently set --root --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 447945ec9d0b..e6c195f7d7a4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -73,6 +73,9 @@ Basic usage of `tox` within this monorepo is: 1. `pip install tox<5` 2. Run `tox -c path/to/tox.ini --root path/to/python_package` + * **Note**: You can use environment variables to provide defaults for tox config values + * With `TOX_CONFIG_FILE` set to the absolute path of `tox.ini`, you can avoid needing `-c path/to/tox.ini` in your tox invocations + * With `TOX_ROOT_DIR` set to the absolute path to your python package, you can avoid needing `--root path/to/python_package` The common `tox.ini` location is `eng/tox/tox.ini` within the repository. From f3b64dcf95891f32ae9992d0a023093f0c5b8e36 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Mon, 1 May 2023 14:34:47 -0700 Subject: [PATCH 20/42] update packaging requirement everywhere it is used. --- eng/ci_tools.txt | 2 +- eng/pipelines/templates/jobs/tests-nightly-python.yml | 4 ++-- eng/pipelines/templates/jobs/update_pr.yml | 2 +- eng/pipelines/templates/steps/use-python-version.yml | 2 +- eng/regression_test_tools.txt | 2 +- eng/regression_tools.txt | 2 +- eng/test_tools.txt | 2 +- eng/tox/tox.ini | 6 +++--- scripts/auto_release/requirement.txt | 2 +- scripts/release_helper/requirement.txt | 2 +- scripts/release_sdk_status/requirement.txt | 2 +- tools/azure-sdk-tools/ci_tools/versioning/requirements.txt | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/eng/ci_tools.txt b/eng/ci_tools.txt index 8d1a56c59417..7ef262cdcb4c 100644 --- a/eng/ci_tools.txt +++ b/eng/ci_tools.txt @@ -5,7 +5,7 @@ setuptools==67.6.0; python_version >= '3.5' virtualenv==20.13.2 wheel==0.37.0 Jinja2==2.11.2 -packaging==20.4 +packaging==23.1 tox==4.5.0 twine==3.1.1; python_version >= '3.6' pathlib2==2.3.5 diff --git a/eng/pipelines/templates/jobs/tests-nightly-python.yml b/eng/pipelines/templates/jobs/tests-nightly-python.yml index 516b71a4bed2..b3e5663c0b1a 100644 --- a/eng/pipelines/templates/jobs/tests-nightly-python.yml +++ b/eng/pipelines/templates/jobs/tests-nightly-python.yml @@ -22,7 +22,7 @@ jobs: - script: | python -m pip freeze python -m pip --version - python -m pip install setuptools==58.3.0 wheel==0.37.0 tox==4.5.0 packaging==21.0 requests + python -m pip install setuptools==58.3.0 wheel==0.37.0 tox==4.5.0 packaging==23.1 requests python -m pip install $(Build.SourcesDirectory)/tools/azure-sdk-tools[build] displayName: Install Dependencies @@ -67,7 +67,7 @@ jobs: sudo apt-get install build-essential -y python -m pip freeze python -m pip --version - python -m pip install setuptools==58.3.0 wheel==0.37.0 tox==4.5.0 packaging==21.0 requests + python -m pip install setuptools==58.3.0 wheel==0.37.0 tox==4.5.0 packaging==23.1 requests python -m pip install $(Build.SourcesDirectory)/tools/azure-sdk-tools[build] displayName: Install Dependencies diff --git a/eng/pipelines/templates/jobs/update_pr.yml b/eng/pipelines/templates/jobs/update_pr.yml index 6e459bdfc86a..7515af893551 100644 --- a/eng/pipelines/templates/jobs/update_pr.yml +++ b/eng/pipelines/templates/jobs/update_pr.yml @@ -23,7 +23,7 @@ steps: python3 -m pip install -e "git+https://github.com/Azure/azure-sdk-for-python#subdirectory=tools/azure-sdk-tools&egg=azure-sdk-tools" displayName: 'Install Azure SDK tools' -- script: python3 -m packaging_tools.update_pr -v --pr-number $(System.PullRequest.PullRequestNumber) --repo $(Build.Repository.Name) +- script: python3 -m packaging_tools.update_pr -v --pr-number $(System.PullRequest.PullRequestNumber) --repo $(Build.Repository.Name) displayName: 'Update packaging of PR' env: GH_TOKEN: $(azuresdk-github-pat) diff --git a/eng/pipelines/templates/steps/use-python-version.yml b/eng/pipelines/templates/steps/use-python-version.yml index 9520e4f1a8f0..1a2fe4130e0b 100644 --- a/eng/pipelines/templates/steps/use-python-version.yml +++ b/eng/pipelines/templates/steps/use-python-version.yml @@ -9,7 +9,7 @@ steps: versionSpec: 3.8 - pwsh: | - python -m pip install packaging==20.4 + python -m pip install packaging==23.1 displayName: Prep Environment # select the appropriate version from manifest if present diff --git a/eng/regression_test_tools.txt b/eng/regression_test_tools.txt index 4cf5407b65d7..5ce42fc2e005 100644 --- a/eng/regression_test_tools.txt +++ b/eng/regression_test_tools.txt @@ -19,7 +19,7 @@ json-delta==2.0 ConfigArgParse==1.2.3 six==1.14.0 pyyaml==5.3.1 -packaging==20.4 +packaging==23.1 wheel==0.34.2 Jinja2==2.11.2 markupsafe==2.0.1; python_version > '2.7' diff --git a/eng/regression_tools.txt b/eng/regression_tools.txt index 46b7b8c2632b..51b3bc0c6dc9 100644 --- a/eng/regression_tools.txt +++ b/eng/regression_tools.txt @@ -5,7 +5,7 @@ setuptools==67.6.0; python_version >= '3.5' virtualenv==20.0.23 wheel==0.34.2 Jinja2==2.11.2 -packaging==20.4 +packaging==23.1 tox==4.5.0 twine==1.15.0; python_version == '2.7' or python_version == '3.5' twine==3.1.1; python_version >= '3.6' diff --git a/eng/test_tools.txt b/eng/test_tools.txt index 0183a41989f0..d78a96a807c6 100644 --- a/eng/test_tools.txt +++ b/eng/test_tools.txt @@ -23,7 +23,7 @@ json-delta==2.0 ConfigArgParse==1.2.3 six==1.14.0 pyyaml==5.3.1 -packaging==20.4 +packaging==23.1 Jinja2==2.11.2 markupsafe==2.0.1; python_version > '2.7' markupsafe==1.1.1; python_version == '2.7' diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index 92d520c4a33a..8223785524b7 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -41,9 +41,9 @@ deps = [packaging] pkgs = - wheel==0.37.0 - packaging==20.4 - urllib3==1.26.12 + wheel==0.40.0 + packaging==23.1 + urllib3==1.26.15 tomli==2.0.1 [pytest] diff --git a/scripts/auto_release/requirement.txt b/scripts/auto_release/requirement.txt index 698652f950c2..9827e5f623c5 100644 --- a/scripts/auto_release/requirement.txt +++ b/scripts/auto_release/requirement.txt @@ -1,7 +1,7 @@ azure-identity python-dotenv==0.15.0 ghapi==0.1.19 -packaging==21.3 +packaging==23.1 pytest==6.2.5 azure-storage-blob==12.9.0 fastcore==1.3.25 \ No newline at end of file diff --git a/scripts/release_helper/requirement.txt b/scripts/release_helper/requirement.txt index 3f1b2e7723b9..fbb1ddc9882f 100644 --- a/scripts/release_helper/requirement.txt +++ b/scripts/release_helper/requirement.txt @@ -2,5 +2,5 @@ PyGithub==1.55 requests==2.28.0 azure-devops==6.0.0b4 msrest>=0.6.21 -packaging==23.0 +packaging==23.1 urllib3==1.26.15 \ No newline at end of file diff --git a/scripts/release_sdk_status/requirement.txt b/scripts/release_sdk_status/requirement.txt index d97bf73cb661..528e24a7962e 100644 --- a/scripts/release_sdk_status/requirement.txt +++ b/scripts/release_sdk_status/requirement.txt @@ -7,4 +7,4 @@ urllib3==1.26.6 pytest==6.2.5 pytest-cov==3.0.0 PyGithub==1.55 -packaging==21.3 \ No newline at end of file +packaging==23.1 \ No newline at end of file diff --git a/tools/azure-sdk-tools/ci_tools/versioning/requirements.txt b/tools/azure-sdk-tools/ci_tools/versioning/requirements.txt index a5b557a29095..15a167270360 100644 --- a/tools/azure-sdk-tools/ci_tools/versioning/requirements.txt +++ b/tools/azure-sdk-tools/ci_tools/versioning/requirements.txt @@ -1,4 +1,4 @@ -packaging==19.2 +packaging==23.1 pyparsing==2.4.5 six==1.13.0 setuptools==67.6.0 \ No newline at end of file From a18e2879350e364d28246b5f4a8b7e55dbc69003 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Mon, 1 May 2023 18:02:14 -0400 Subject: [PATCH 21/42] fix cspell --- .vscode/cspell.json | 6 ++++++ doc/dev/pylint_checking.md | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.vscode/cspell.json b/.vscode/cspell.json index d579a7e86e51..da07611bb847 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -416,6 +416,12 @@ "pytestmarkparametrize" ] }, + { + "filename": "doc/dev/pylint_checking.md", + "words": [ + "pylintrc" + ] + }, { "filename": "tools/azure-sdk-tools/devtools_testutils/proxy_startup.py", "words": [ diff --git a/doc/dev/pylint_checking.md b/doc/dev/pylint_checking.md index e087542323c8..bf230a1dcc6f 100644 --- a/doc/dev/pylint_checking.md +++ b/doc/dev/pylint_checking.md @@ -58,7 +58,7 @@ In addition to being a part of the CI, the custom pylint checkers are also integ There is now a new step on the CI pipeline called `Run Pylint Next`. This is merely a duplicate of the `Run Pylint` step with the exception that `Run Pylint Next` uses the latest version of pylint and the latest version of the custom pylint checkers. -This next-pylint enviornment can also be run locally through tox: +This next-pylint environment can also be run locally through tox: tox -e next-pylint -c ../../../eng/tox/tox.ini --root From 4efb01ea5d57380ee805e11c1f777d247ab84837 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Tue, 2 May 2023 15:08:51 -0400 Subject: [PATCH 22/42] docs: Use `tox run` syntax throughout documentation --- CONTRIBUTING.md | 20 ++++++++++---------- doc/dev/pylint_checking.md | 4 ++-- doc/dev/sample_guide.md | 4 ++-- doc/dev/static_type_checking.md | 6 +++--- doc/dev/tests.md | 18 +++++++++--------- doc/eng_sys_checks.md | 20 ++++++++++---------- scripts/breaking_changes_checker/README.md | 2 +- scripts/devops_tasks/tox_harness.py | 2 +- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6c195f7d7a4..4132bf40c7f7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,7 +72,7 @@ breaking -> Runs the breaking changes checker against a package Basic usage of `tox` within this monorepo is: 1. `pip install tox<5` -2. Run `tox -c path/to/tox.ini --root path/to/python_package` +2. Run `tox run -e ENV_NAME -c path/to/tox.ini --root path/to/python_package` * **Note**: You can use environment variables to provide defaults for tox config values * With `TOX_CONFIG_FILE` set to the absolute path of `tox.ini`, you can avoid needing `-c path/to/tox.ini` in your tox invocations * With `TOX_ROOT_DIR` set to the absolute path to your python package, you can avoid needing `--root path/to/python_package` @@ -83,11 +83,11 @@ If at any time you want to blow away the tox created virtual environments and st #### Example `azure-core` mypy -1. Run `tox -e mypy -c ../../../eng/tox/tox.ini --root sdk/core/azure-core` +1. Run `tox run -e mypy -c ../../../eng/tox/tox.ini --root sdk/core/azure-core` #### Example `azure-storage-blob` tests -2. Execute `tox -c ../../../eng/tox/tox.ini --root sdk/storage/azure-storage-blob` +2. Execute `tox run -c ../../../eng/tox/tox.ini --root sdk/storage/azure-storage-blob` Note that we didn't provide an `environment` argument for this example. Reason here is that the _default_ environment selected by our common `tox.ini` file is one that runs `pytest`. @@ -97,7 +97,7 @@ Used for test execution across the spectrum of all the platforms we want to supp * Installs the wheel, runs tests using the wheel ``` -\> tox -e whl -c --root +\> tox run -e whl -c --root ``` @@ -109,7 +109,7 @@ Used for the local dev loop. ``` -\> tox -e sdist -c --root +\> tox run -e sdist -c --root ``` @@ -117,7 +117,7 @@ Used for the local dev loop. Pylint install and run. ``` -\> tox -e pylint -c --root +\> tox run -e pylint -c --root ``` @@ -125,14 +125,14 @@ Pylint install and run. Mypy install and run. ``` -\> tox -e mypy -c --root +\> tox run -e mypy -c --root ``` #### `sphinx` environment Generate sphinx doc for this package. ``` -\> tox -e sphinx -c --root +\> tox run -e sphinx -c --root ``` ### Custom Pytest Arguments @@ -142,7 +142,7 @@ Generate sphinx doc for this package. [Tox Documentation on Positional Arguments](https://tox.wiki/en/latest/config.html#substitutions-for-positional-arguments-in-commands) **Example: Invoke tox, breaking into the debugger on failure** -`tox -e whl -c --root -- --pdb` +`tox run -e whl -c --root -- --pdb` ### Performance Testing @@ -172,7 +172,7 @@ a. cd to package root folder b. run tox environment devtest ``` -\> tox -e devtest -c --root +\> tox run -e devtest -c --root ``` This tox test( devtest) will fail if installed dependent packages are not dev build version. diff --git a/doc/dev/pylint_checking.md b/doc/dev/pylint_checking.md index bf230a1dcc6f..8fa389cfb904 100644 --- a/doc/dev/pylint_checking.md +++ b/doc/dev/pylint_checking.md @@ -24,7 +24,7 @@ In the Azure SDK for Python repository, in addition to the standard pylint libra One way to run pylint is to run at the package level with tox: - .../azure-sdk-for-python/sdk/eventgrid/azure-eventgrid>tox -e pylint -c ../../../eng/tox/tox.ini --root . + .../azure-sdk-for-python/sdk/eventgrid/azure-eventgrid>tox run -e pylint -c ../../../eng/tox/tox.ini --root . If you don't want to use tox, you can also install and run pylint on its own: @@ -60,7 +60,7 @@ There is now a new step on the CI pipeline called `Run Pylint Next`. This is mer This next-pylint environment can also be run locally through tox: - tox -e next-pylint -c ../../../eng/tox/tox.ini --root + tox run -e next-pylint -c ../../../eng/tox/tox.ini --root The errors generated by the `Run Pylint Next` step will not break your weekly test pipelines, but make sure to fix the warnings so that your client library is up to date for the next pylint release. diff --git a/doc/dev/sample_guide.md b/doc/dev/sample_guide.md index 7e8d2f905937..0f3dc138b602 100644 --- a/doc/dev/sample_guide.md +++ b/doc/dev/sample_guide.md @@ -52,13 +52,13 @@ The given `START`/`END` keywords can be used in a [sphinx literalinclude][sphinx [Literalinclude example][literalinclude] The rendered code snippets are sensitive to the indentation in the sample file. Adjust the `dedent` accordingly to ensure the sample is captured accurately and not accidentally trimmed. -You can preview how published reference documentation will look by running [tox][tox]: `tox -e sphinx -c ../../../eng/tox/tox.ini --root `. +You can preview how published reference documentation will look by running [tox][tox]: `tox run -e sphinx -c ../../../eng/tox/tox.ini --root `. ## Test run samples in CI live tests Per the [Python guidelines][snippet_guidelines], sample code and snippets should be test run in CI to ensure they remain functional. Samples should be run in the package's live test pipeline which is scheduled to run daily. To ensure samples do get tested as part of regular CI runs, add these [lines][live_tests] to the package's tests.yml. -You can test this CI step locally first, by utilizing [tox][tox] and running `tox -e samples -c ../../../eng/tox/tox.ini --root `. +You can test this CI step locally first, by utilizing [tox][tox] and running `tox run -e samples -c ../../../eng/tox/tox.ini --root `. The `Test Samples` step in CI will rely on the resources provisioned and environment variables used for running the package's tests. diff --git a/doc/dev/static_type_checking.md b/doc/dev/static_type_checking.md index bffd299a7446..db76343d996d 100644 --- a/doc/dev/static_type_checking.md +++ b/doc/dev/static_type_checking.md @@ -185,7 +185,7 @@ mypy is currently pinned to version [1.0.0](https://pypi.org/project/mypy/1.0.0/ To run mypy on your library, run the tox mypy env at the package level: -`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e mypy -c ../../../eng/tox/tox.ini --root .` +`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox run -e mypy -c ../../../eng/tox/tox.ini --root .` If you don't want to use `tox` you can also install and run mypy on its own: @@ -217,7 +217,7 @@ Note that pyright requires that node is installed. The command-line [wrapper pac To run pyright on your library, run the tox pyright env at the package level: -`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e pyright -c ../../../eng/tox/tox.ini --root .` +`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox run -e pyright -c ../../../eng/tox/tox.ini --root .` If you don't want to use `tox` you can also install and run pyright on its own: @@ -249,7 +249,7 @@ from the code in the PR vs. the latest release on PyPi. To run verifytypes on your library, run the tox verifytypes env at the package level: -`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox -e verifytypes -c ../../../eng/tox/tox.ini --root .` +`.../azure-sdk-for-python/sdk/textanalytics/azure-ai-textanalytics>tox run -e verifytypes -c ../../../eng/tox/tox.ini --root .` If you don't want to use `tox` you can also install and run pyright/verifytypes on its own: diff --git a/doc/dev/tests.md b/doc/dev/tests.md index 6aaeb721e44c..e3fd49ea03be 100644 --- a/doc/dev/tests.md +++ b/doc/dev/tests.md @@ -128,15 +128,15 @@ The Python SDK uses the [tox project](https://tox.wiki/en/latest/) to automate r To run a tox command from your directory use the following commands: ```cmd -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e sphinx -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e pylint -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e mypy -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e pyright -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e verifytypes -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e whl -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e sdist -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e samples -(env) azure-sdk-for-python\sdk\my-service\my-package> tox -c ../../../eng/tox/tox.ini --root . -e apistub +(env) azure-sdk-for-python\sdk\my-service\my-package> tox run -e sphinx -c ../../../eng/tox/tox.ini --root . +(env) azure-sdk-for-python\sdk\my-service\my-package> tox run -e pylint -c ../../../eng/tox/tox.ini --root . +(env) azure-sdk-for-python\sdk\my-service\my-package> tox run -e mypy -c ../../../eng/tox/tox.ini --root . +(env) azure-sdk-for-python\sdk\my-service\my-package> tox run -e pyright -c ../../../eng/tox/tox.ini --root . +(env) azure-sdk-for-python\sdk\my-service\my-package> tox run -e verifytypes -c ../../../eng/tox/tox.ini --root . +(env) azure-sdk-for-python\sdk\my-service\my-package> tox run -e whl -c ../../../eng/tox/tox.ini --root . +(env) azure-sdk-for-python\sdk\my-service\my-package> tox run -e sdist -c ../../../eng/tox/tox.ini --root . +(env) azure-sdk-for-python\sdk\my-service\my-package> tox run -e samples -c ../../../eng/tox/tox.ini --root . +(env) azure-sdk-for-python\sdk\my-service\my-package> tox run -e apistub -c ../../../eng/tox/tox.ini --root . ``` A quick description of the five commands above: * sphinx: documentation generation using the inline comments written in our code diff --git a/doc/eng_sys_checks.md b/doc/eng_sys_checks.md index 17ddb46fef7e..4959af1ae57f 100644 --- a/doc/eng_sys_checks.md +++ b/doc/eng_sys_checks.md @@ -169,14 +169,14 @@ Analyze job in both nightly CI and pull request validation pipeline runs a set o [`MyPy`](https://pypi.org/project/mypy/) is a static analysis tool that runs type checking of python package. Following are the steps to run `MyPy` locally for a specific package: 1. Go to root of the package -2. Execute following command: `tox -e mypy -c ../../../eng/tox/tox.ini --root .` +2. Execute following command: `tox run -e mypy -c ../../../eng/tox/tox.ini --root .` ### Pyright [`Pyright`](https://github.com/microsoft/pyright/) is a static analysis tool that runs type checking of python package. Following are the steps to run `pyright` locally for a specific package: 1. Go to root of the package -2. Execute following command: `tox -e pyright -c ../../../eng/tox/tox.ini --root .` +2. Execute following command: `tox run -e pyright -c ../../../eng/tox/tox.ini --root .` ### Verifytypes @@ -184,7 +184,7 @@ Analyze job in both nightly CI and pull request validation pipeline runs a set o [`Verifytypes`](https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#verifying-type-completeness) is a feature of pyright that checks the type completeness of a python package. Following are the steps to run `verifytypes` locally for a specific package: 1. Go to root of the package -2. Execute following command: `tox -e verifytypes -c ../../../eng/tox/tox.ini --root .` +2. Execute following command: `tox run -e verifytypes -c ../../../eng/tox/tox.ini --root .` ### Pylint @@ -192,14 +192,14 @@ Analyze job in both nightly CI and pull request validation pipeline runs a set o [`Pylint`](https://pypi.org/project/pylint/) is a static analysis tool to run lint checking, it is automatically run on all PRs. Following are the steps to run `pylint` locally for a specific package. 1. Go to root of the package. -2. Execute following command: `tox -e pylint -c ../../../eng/tox/tox.ini --root .` +2. Execute following command: `tox run -e pylint -c ../../../eng/tox/tox.ini --root .` ### Bandit `Bandit` is static security analysis tool. This check is triggered for all Azure SDK package as part of analyze job. Following are the steps to `Bandit` tool locally for a specific package. 1. Got to package root directory. -2. Execute command: `tox -e bandit -c ../../../eng/tox/tox.ini --root .` +2. Execute command: `tox run -e bandit -c ../../../eng/tox/tox.ini --root .` ### ApiStubGen @@ -255,7 +255,7 @@ This test installs wheel of the package being tested and runs all tests cases in 1. Go to package root folder on a command line 2. Run following command - `tox -e whl -c ../../../eng/tox/tox.ini --root .` + `tox run -e whl -c ../../../eng/tox/tox.ini --root .` #### sdist @@ -263,7 +263,7 @@ This test installs sdist of the package being tested and runs all tests cases in 1. Go to package root folder on a command line 2. Run following command - `tox -e sdist -c ../../../eng/tox/tox.ini --root .` + `tox run -e sdist -c ../../../eng/tox/tox.ini --root .` #### depends @@ -273,7 +273,7 @@ Following is the command to run this test environment locally. 1. Go to package root folder on a command line 2. Run following command - `tox -e sdist -c ../../../eng/tox/tox.ini --root .` + `tox run -e sdist -c ../../../eng/tox/tox.ini --root .` ## Nightly CI Checks @@ -321,7 +321,7 @@ Note: Any dependency mentioned only in dev_requirements are not considered to id Tox name of this test is `latestdependency` and steps to manually run this test locally is as follows. 1. Go to package root. For e.g azure-storage-blob or azure-identity -2. Run command `tox –e latestdependency –c ../../../tox/tox.ini --root .` +2. Run command `tox run –e latestdependency –c ../../../tox/tox.ini --root .` #### Minimum Dependency Test @@ -338,7 +338,7 @@ Tox name of this test is `mindependency` and steps to manually run this test loc 1. Go to package root. For e.g azure-storage-blob or azure-identity 2. Run following command -`tox –e mindependency –c ../../../tox/tox.ini --root .` +`tox run –e mindependency –c ../../../tox/tox.ini --root .` #### Regression Test diff --git a/scripts/breaking_changes_checker/README.md b/scripts/breaking_changes_checker/README.md index 943091874315..b3b69acb06aa 100644 --- a/scripts/breaking_changes_checker/README.md +++ b/scripts/breaking_changes_checker/README.md @@ -17,7 +17,7 @@ Add your package name to the `RUN_BREAKING_CHANGES_PACKAGES` found [here](https: Here we run the breaking changes tool against azure-storage-blob, for example: -`C:\azure-sdk-for-python\sdk\storage\azure-storage-blob>tox -c ../../../eng/tox/tox.ini --root . -e breaking` +`C:\azure-sdk-for-python\sdk\storage\azure-storage-blob>tox run -c ../../../eng/tox/tox.ini --root . -e breaking` ## Ignore a reported breaking change diff --git a/scripts/devops_tasks/tox_harness.py b/scripts/devops_tasks/tox_harness.py index 7c075d128b8f..9e9601b3b912 100644 --- a/scripts/devops_tasks/tox_harness.py +++ b/scripts/devops_tasks/tox_harness.py @@ -241,7 +241,7 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace, optio :param parsed_args: An argparse namespace object from setup_execute_tests.py. Not including it will effectively disable "customizations" of the tox invocation. :param options_array: When invoking tox, these additional options will be passed to the underlying tox invocations as arguments. - When invoking of "tox -e whl -c ../../../eng/tox/tox.ini -- --suppress-no-test-exit-code", "--suppress-no-test-exit-code" the "--" will be + When invoking of "tox run -e whl -c ../../../eng/tox/tox.ini -- --suppress-no-test-exit-code", "--suppress-no-test-exit-code" the "--" will be passed directly to the pytest invocation. """ if parsed_args.wheel_dir: From 4cbd85a7b7c3e0dc92700830a7b3b4f2114c5ac6 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Tue, 2 May 2023 15:10:00 -0400 Subject: [PATCH 23/42] engsys: Use `tox run` syntax in tox_harness.py --- scripts/devops_tasks/tox_harness.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/devops_tasks/tox_harness.py b/scripts/devops_tasks/tox_harness.py index 9e9601b3b912..4da7dcdcbeab 100644 --- a/scripts/devops_tasks/tox_harness.py +++ b/scripts/devops_tasks/tox_harness.py @@ -258,7 +258,7 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace, optio destination_tox_ini = os.path.join(package_dir, "tox.ini") destination_dev_req = os.path.join(package_dir, "dev_requirements.txt") - tox_execution_array = [sys.executable, "-m", "tox"] + tox_execution_array = [sys.executable, "-m", "tox", "run"] # Tox command is run in package root, make tox set package root as {toxinidir} tox_execution_array.append(["--root", "."]) local_options_array = options_array[:] From e958de7a78089203adf81e6f56eaeee5208a54f3 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Tue, 2 May 2023 15:12:55 -0400 Subject: [PATCH 24/42] =?UTF-8?q?docs:=20Replace=20=E2=80=93=20(U+2013=20:?= =?UTF-8?q?=20EN=20DASH)=20with=20-=20(ASCII=20code=2045)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/eng_sys_checks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/eng_sys_checks.md b/doc/eng_sys_checks.md index 4959af1ae57f..f2f892c65114 100644 --- a/doc/eng_sys_checks.md +++ b/doc/eng_sys_checks.md @@ -321,7 +321,7 @@ Note: Any dependency mentioned only in dev_requirements are not considered to id Tox name of this test is `latestdependency` and steps to manually run this test locally is as follows. 1. Go to package root. For e.g azure-storage-blob or azure-identity -2. Run command `tox run –e latestdependency –c ../../../tox/tox.ini --root .` +2. Run command `tox run -e latestdependency -c ../../../tox/tox.ini --root .` #### Minimum Dependency Test @@ -338,7 +338,7 @@ Tox name of this test is `mindependency` and steps to manually run this test loc 1. Go to package root. For e.g azure-storage-blob or azure-identity 2. Run following command -`tox run –e mindependency –c ../../../tox/tox.ini --root .` +`tox run -e mindependency -c ../../../tox/tox.ini --root .` #### Regression Test From 0ec907450bafbd4f10343a5d67944cf6b3b21cec Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 3 May 2023 16:15:30 -0700 Subject: [PATCH 25/42] update pytest requirements + coverage. --- eng/test_tools.txt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/eng/test_tools.txt b/eng/test_tools.txt index d78a96a807c6..b6703583ca52 100644 --- a/eng/test_tools.txt +++ b/eng/test_tools.txt @@ -1,15 +1,12 @@ cryptography<4 # requirements leveraged by ci for testing -pytest==4.6.9; python_version == '2.7' -pytest==5.4.2; python_version >= '3.5' and python_version <= '3.9' -pytest==6.2.4; python_version >= '3.10' -pytest-asyncio==0.12.0; python_version >= '3.5' -pytest-cov==2.8.1 +pytest==7.3.1 +pytest-asyncio==0.21.0; python_version >= '3.5' +pytest-cov==4.0.0 pytest-custom-exit-code==0.3.0 -pytest-xdist==1.32.0 -# we pin coverage to 4.5.4 because there is an bug with `pytest-cov`. the generated coverage files cannot be `coverage combine`ed -coverage==4.5.4 +pytest-xdist==3.2.1 +coverage==7.2.5 bandit==1.6.2 protobuf==3.17.3; python_version == '2.7' chardet>=2.0,<5.0 From 472ee626c91543c801bb4058c9bef4c3f9f0b88b Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 3 May 2023 16:23:42 -0700 Subject: [PATCH 26/42] update virtualenv --- eng/ci_tools.txt | 2 +- eng/regression_tools.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/ci_tools.txt b/eng/ci_tools.txt index 7ef262cdcb4c..4a83171e5bd8 100644 --- a/eng/ci_tools.txt +++ b/eng/ci_tools.txt @@ -2,7 +2,7 @@ cryptography<4 setuptools==44.1.0; python_version == '2.7' setuptools==67.6.0; python_version >= '3.5' -virtualenv==20.13.2 +virtualenv==20.23.0 wheel==0.37.0 Jinja2==2.11.2 packaging==23.1 diff --git a/eng/regression_tools.txt b/eng/regression_tools.txt index 51b3bc0c6dc9..2a47dd30c8cb 100644 --- a/eng/regression_tools.txt +++ b/eng/regression_tools.txt @@ -2,7 +2,7 @@ cryptography==3.3.2 setuptools==44.1.0; python_version == '2.7' setuptools==67.6.0; python_version >= '3.5' -virtualenv==20.0.23 +virtualenv==20.23.0 wheel==0.34.2 Jinja2==2.11.2 packaging==23.1 From deedaba6704b6dbd259afca50f1cfd9c9e0fcae3 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 3 May 2023 16:32:56 -0700 Subject: [PATCH 27/42] more conflicts resolved --- eng/ci_tools.txt | 6 ++---- eng/test_tools.txt | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/eng/ci_tools.txt b/eng/ci_tools.txt index 4a83171e5bd8..79be2d6cfefd 100644 --- a/eng/ci_tools.txt +++ b/eng/ci_tools.txt @@ -30,10 +30,8 @@ json-delta==2.0 ConfigArgParse==1.2.3 six==1.14.0 pyyaml==5.3.1 -pytest==4.6.9; python_version == '2.7' -pytest==5.4.2; python_version >= '3.5' and python_version <= '3.9' -pytest==6.2.4; python_version >= '3.10' -pytest-cov==2.8.1 +pytest==7.3.1 +pytest-cov==4.0.0 # local dev packages ./tools/azure-devtools diff --git a/eng/test_tools.txt b/eng/test_tools.txt index b6703583ca52..ab47e7beb313 100644 --- a/eng/test_tools.txt +++ b/eng/test_tools.txt @@ -2,7 +2,7 @@ cryptography<4 # requirements leveraged by ci for testing pytest==7.3.1 -pytest-asyncio==0.21.0; python_version >= '3.5' +pytest-asyncio==0.21.0 pytest-cov==4.0.0 pytest-custom-exit-code==0.3.0 pytest-xdist==3.2.1 From 535294dacdc5695cd5f1ee1e2230a56ba09c4bfb Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 3 May 2023 16:35:49 -0700 Subject: [PATCH 28/42] bringing in urllib3 restriction, aligning ci_tools.txt with test_tools.txt --- eng/ci_tools.txt | 3 +-- tools/azure-sdk-tools/setup.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/eng/ci_tools.txt b/eng/ci_tools.txt index 79be2d6cfefd..b43f9835f4d9 100644 --- a/eng/ci_tools.txt +++ b/eng/ci_tools.txt @@ -10,8 +10,6 @@ tox==4.5.0 twine==3.1.1; python_version >= '3.6' pathlib2==2.3.5 doc-warden==0.7.2 -# we pin coverage to 4.5.4 because there is an bug with `pytest-cov`. the generated coverage files cannot be `coverage combine`ed -coverage==4.5.4 beautifulsoup4==4.9.1 pkginfo==1.5.0.1 pip==20.3.3 @@ -32,6 +30,7 @@ six==1.14.0 pyyaml==5.3.1 pytest==7.3.1 pytest-cov==4.0.0 +coverage==7.2.5 # local dev packages ./tools/azure-devtools diff --git a/tools/azure-sdk-tools/setup.py b/tools/azure-sdk-tools/setup.py index c77015e24aa9..3a161b94c8ef 100644 --- a/tools/azure-sdk-tools/setup.py +++ b/tools/azure-sdk-tools/setup.py @@ -20,7 +20,7 @@ "pyopenssl", "python-dotenv", "PyYAML", - "urllib3", + "urllib3<2", "tomli" ] From 19f6523d7aedbc00a804b6971500bca1af57db26 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 3 May 2023 17:25:20 -0700 Subject: [PATCH 29/42] check_call requires a list of type string. if we append ['blah', 'blah'] we are actually inserting another array. just use regular array concatenation --- scripts/devops_tasks/tox_harness.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/devops_tasks/tox_harness.py b/scripts/devops_tasks/tox_harness.py index 4da7dcdcbeab..eae8884bb4a1 100644 --- a/scripts/devops_tasks/tox_harness.py +++ b/scripts/devops_tasks/tox_harness.py @@ -260,7 +260,7 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace, optio tox_execution_array = [sys.executable, "-m", "tox", "run"] # Tox command is run in package root, make tox set package root as {toxinidir} - tox_execution_array.append(["--root", "."]) + tox_execution_array += ["--root", "."] local_options_array = options_array[:] # Get code coverage params for current package From 1c72fffed0476f9ec0ac3ea27f9195fe0595ac41 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Wed, 3 May 2023 21:39:47 -0400 Subject: [PATCH 30/42] engsys: Tox uses `run` for serial execution and `run-parallel` for parallel` --- scripts/devops_tasks/tox_harness.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/devops_tasks/tox_harness.py b/scripts/devops_tasks/tox_harness.py index eae8884bb4a1..3827802a9059 100644 --- a/scripts/devops_tasks/tox_harness.py +++ b/scripts/devops_tasks/tox_harness.py @@ -258,7 +258,13 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace, optio destination_tox_ini = os.path.join(package_dir, "tox.ini") destination_dev_req = os.path.join(package_dir, "dev_requirements.txt") - tox_execution_array = [sys.executable, "-m", "tox", "run"] + tox_execution_array = [sys.executable, "-m", "tox"] + + if parsed_args.tenvparallel: + tox_execution_array.extend(["run-parallel", "-p", "all"]) + else: + tox_execution_array.append("run") + # Tox command is run in package root, make tox set package root as {toxinidir} tox_execution_array += ["--root", "."] local_options_array = options_array[:] @@ -325,8 +331,6 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace, optio tox_execution_array.extend(["-e", filtered_tox_environment_set]) - if parsed_args.tenvparallel: - tox_execution_array.extend(["-p", "all"]) if parsed_args.tox_env == "apistub": local_options_array = [] From 53e606867b160cb39a76d0268a5eac0345f05075 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Wed, 10 May 2023 15:37:38 -0400 Subject: [PATCH 31/42] azure-core: Use `@pytest_asyncio.fixture` to mark an asyncio fixture See https://pytest-asyncio.readthedocs.io/en/latest/concepts.html#strict-mode --- .../tests/async_tests/test_rest_asyncio_transport.py | 3 ++- .../async_tests/test_rest_response_backcompat_async.py | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sdk/core/azure-core/tests/async_tests/test_rest_asyncio_transport.py b/sdk/core/azure-core/tests/async_tests/test_rest_asyncio_transport.py index 194efb4a8dde..d8b6319d8396 100644 --- a/sdk/core/azure-core/tests/async_tests/test_rest_asyncio_transport.py +++ b/sdk/core/azure-core/tests/async_tests/test_rest_asyncio_transport.py @@ -9,10 +9,11 @@ from rest_client_async import AsyncTestRestClient import pytest +import pytest_asyncio from utils import readonly_checks -@pytest.fixture +@pytest_asyncio.fixture async def client(port): async with AsyncioRequestsTransport() as transport: async with AsyncTestRestClient(port, transport=transport) as client: diff --git a/sdk/core/azure-core/tests/async_tests/test_rest_response_backcompat_async.py b/sdk/core/azure-core/tests/async_tests/test_rest_response_backcompat_async.py index 20248b9848f2..b88708ff3a6e 100644 --- a/sdk/core/azure-core/tests/async_tests/test_rest_response_backcompat_async.py +++ b/sdk/core/azure-core/tests/async_tests/test_rest_response_backcompat_async.py @@ -5,6 +5,7 @@ # license information. # ------------------------------------------------------------------------- import pytest +import pytest_asyncio from azure.core.pipeline.transport import HttpRequest as PipelineTransportHttpRequest from azure.core.rest import HttpRequest as RestHttpRequest from azure.core.pipeline import Pipeline @@ -19,8 +20,7 @@ def old_request(port): return PipelineTransportHttpRequest("GET", "http://localhost:{}/streams/basic".format(port)) -@pytest.fixture -@pytest.mark.asyncio +@pytest_asyncio.fixture async def get_old_response(old_request): async def _callback(transport, **kwargs): async with transport() as sender: @@ -43,9 +43,7 @@ async def _callback(**kwargs): def new_request(port): return RestHttpRequest("GET", "http://localhost:{}/streams/basic".format(port)) - -@pytest.fixture -@pytest.mark.asyncio +@pytest_asyncio.fixture async def get_new_response(new_request): async def _callback(transport, **kwargs): async with transport() as sender: From 8edb70b61cc0b8f31c6deb1084f74e9788345f02 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 10 May 2023 13:22:49 -0700 Subject: [PATCH 32/42] pin coverage to newer version with no conflicts --- eng/pipelines/templates/steps/build-test.yml | 2 +- eng/regression_test_tools.txt | 2 +- eng/regression_tools.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/templates/steps/build-test.yml b/eng/pipelines/templates/steps/build-test.yml index 9cadcb2cbdc6..9195c6126771 100644 --- a/eng/pipelines/templates/steps/build-test.yml +++ b/eng/pipelines/templates/steps/build-test.yml @@ -89,7 +89,7 @@ steps: CustomCondition: '${{ parameters.RunCoverage }}' - pwsh: | - python -m pip install coverage==4.5.4 + python -m pip install coverage==7.2.5 python scripts/devops_tasks/create_coverage.py displayName: Create Coverage Report condition: and(succeeded(), ${{ parameters.RunCoverage }}) diff --git a/eng/regression_test_tools.txt b/eng/regression_test_tools.txt index 5ce42fc2e005..cf56b0b22031 100644 --- a/eng/regression_test_tools.txt +++ b/eng/regression_test_tools.txt @@ -8,7 +8,7 @@ pytest-cov==2.8.1 pytest-custom-exit-code==0.3.0 pytest-xdist==1.32.0 # we pin coverage to 4.5.4 because there is an bug with `pytest-cov`. the generated coverage files cannot be `coverage combine`ed -coverage==4.5.4 +coverage==7.2.5 bandit==1.6.2 # locking packages defined as deps from azure-sdk-tools or azure-devtools diff --git a/eng/regression_tools.txt b/eng/regression_tools.txt index 2a47dd30c8cb..13fbcecb380c 100644 --- a/eng/regression_tools.txt +++ b/eng/regression_tools.txt @@ -13,7 +13,7 @@ pathlib2==2.3.5 readme-renderer[md]==25.0 doc-warden==0.7.1 # we pin coverage to 4.5.4 because there is an bug with `pytest-cov`. the generated coverage files cannot be `coverage combine`ed -coverage==4.5.4 +coverage==7.2.5 beautifulsoup4==4.9.1 pkginfo==1.5.0.1 pip==20.2 From 32cdba95902afbff8acdf2214cdd49a7a70e8ff5 Mon Sep 17 00:00:00 2001 From: Scott Beddall <45376673+scbedd@users.noreply.github.com> Date: Wed, 10 May 2023 13:57:01 -0700 Subject: [PATCH 33/42] identify issue with missing code coverage being caused by wrongly named namespace (#30344) --- scripts/devops_tasks/common_tasks.py | 22 ++++++++------------- scripts/devops_tasks/setup_execute_tests.py | 2 +- scripts/devops_tasks/tox_harness.py | 2 +- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/scripts/devops_tasks/common_tasks.py b/scripts/devops_tasks/common_tasks.py index 805e26e4ea38..59cfd531a992 100644 --- a/scripts/devops_tasks/common_tasks.py +++ b/scripts/devops_tasks/common_tasks.py @@ -9,19 +9,14 @@ # package targeting during release. import glob -from subprocess import check_call, CalledProcessError, Popen import os import errno -import shutil import sys import logging -import ast -import textwrap -import io -import re -import fnmatch -import platform -from typing import Tuple, Iterable + +from subprocess import check_call, CalledProcessError, Popen +from argparse import Namespace +from typing import Iterable # Assumes the presence of setuptools from pkg_resources import parse_version, parse_requirements, Requirement, WorkingSet, working_set @@ -37,7 +32,6 @@ DEV_REQ_FILE = "dev_requirements.txt" NEW_DEV_REQ_FILE = "new_dev_requirements.txt" - logging.getLogger().setLevel(logging.INFO) @@ -105,18 +99,18 @@ def run_check_call( # This function generates code coverage parameters -def create_code_coverage_params(parsed_args, package_name): +def create_code_coverage_params(parsed_args: Namespace, package_path: str): coverage_args = [] if parsed_args.disablecov: logging.info("Code coverage disabled as per the flag(--disablecov)") coverage_args.append("--no-cov") else: - current_package_name = package_name.replace("-", ".") - coverage_args.append("--cov={}".format(current_package_name)) + namespace = ParsedSetup.from_path(package_path).namespace + coverage_args.append("--cov={}".format(namespace)) coverage_args.append("--cov-append") logging.info( "Code coverage is enabled for package {0}, pytest arguements: {1}".format( - current_package_name, coverage_args + namespace, coverage_args ) ) return coverage_args diff --git a/scripts/devops_tasks/setup_execute_tests.py b/scripts/devops_tasks/setup_execute_tests.py index de4fbc02f4b9..916f8c59412e 100644 --- a/scripts/devops_tasks/setup_execute_tests.py +++ b/scripts/devops_tasks/setup_execute_tests.py @@ -121,7 +121,7 @@ def run_tests(targeted_packages, test_output_location, test_res, parsed_args): local_command_array = command_array[:] # Get code coverage params for current package - coverage_commands = create_code_coverage_params(parsed_args, package_name) + coverage_commands = create_code_coverage_params(parsed_args, target_package) # Create local copy of params to pass to execute local_command_array.extend(coverage_commands) diff --git a/scripts/devops_tasks/tox_harness.py b/scripts/devops_tasks/tox_harness.py index 3827802a9059..9b63643988dc 100644 --- a/scripts/devops_tasks/tox_harness.py +++ b/scripts/devops_tasks/tox_harness.py @@ -271,7 +271,7 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace, optio # Get code coverage params for current package package_name = os.path.basename(package_dir) - coverage_commands = create_code_coverage_params(parsed_args, package_name) + coverage_commands = create_code_coverage_params(parsed_args, package_dir) local_options_array.extend(coverage_commands) pkg_egg_info_name = "{}.egg-info".format(package_name.replace("-", "_")) From f29800716bb05da899166bbae4e34392af74ae1e Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Thu, 11 May 2023 11:54:37 -0700 Subject: [PATCH 34/42] remove fix of dotfile! --- scripts/devops_tasks/create_coverage.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/scripts/devops_tasks/create_coverage.py b/scripts/devops_tasks/create_coverage.py index 79231f232d51..55a52646b2e8 100644 --- a/scripts/devops_tasks/create_coverage.py +++ b/scripts/devops_tasks/create_coverage.py @@ -32,7 +32,6 @@ def collect_tox_coverage_files(): for f in files: if re.match(".coverage_*", f): coverage_files.append(os.path.join(root, f)) - fix_dot_coverage_file(os.path.join(root, f)) logging.info(".coverage files: {}".format(coverage_files)) @@ -58,20 +57,6 @@ def generate_coverage_xml(): else: logging.error("Coverage file is not available in {} to generate coverage XML".format(coverage_dir)) - -def fix_dot_coverage_file(coverage_file): - print("running 'fix_dot_coverage_file' on {}".format(coverage_file)) - - out = None - with open(coverage_file) as cov_file: - line = cov_file.read() - out = re.sub("\/\.tox\/[\s\S]*?\/site-packages", "/", line) - - if out: - with open(coverage_file, 'w') as cov_file: - cov_file.write(out) - - if __name__ == "__main__": collect_tox_coverage_files() generate_coverage_xml() From a6ad5459ca780bfd9afe38183c24cc35f3d0ec93 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Thu, 11 May 2023 12:39:51 -0700 Subject: [PATCH 35/42] apply black formatting to resolve failing analyze step --- .../tests/async_tests/test_rest_response_backcompat_async.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/core/azure-core/tests/async_tests/test_rest_response_backcompat_async.py b/sdk/core/azure-core/tests/async_tests/test_rest_response_backcompat_async.py index b88708ff3a6e..564c698aabe7 100644 --- a/sdk/core/azure-core/tests/async_tests/test_rest_response_backcompat_async.py +++ b/sdk/core/azure-core/tests/async_tests/test_rest_response_backcompat_async.py @@ -43,6 +43,7 @@ async def _callback(**kwargs): def new_request(port): return RestHttpRequest("GET", "http://localhost:{}/streams/basic".format(port)) + @pytest_asyncio.fixture async def get_new_response(new_request): async def _callback(transport, **kwargs): From 2c2dd28bc23dd7199e4e06f8c4895c7f0dc49eab Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Thu, 11 May 2023 16:20:43 -0700 Subject: [PATCH 36/42] tox installing tox. probably not a good thing :) --- .../azure-media-videoanalyzer-edge/dev_requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/videoanalyzer/azure-media-videoanalyzer-edge/dev_requirements.txt b/sdk/videoanalyzer/azure-media-videoanalyzer-edge/dev_requirements.txt index 087574a22d2a..198cc317f2f3 100644 --- a/sdk/videoanalyzer/azure-media-videoanalyzer-edge/dev_requirements.txt +++ b/sdk/videoanalyzer/azure-media-videoanalyzer-edge/dev_requirements.txt @@ -4,4 +4,3 @@ -e ../../identity/azure-identity aiohttp>=3.0 aiodns>=2.0 -tox>=4.4.11 From c1ffbc9f790ab133013b19fa4b87791e451b2302 Mon Sep 17 00:00:00 2001 From: kdestin <101366538+kdestin@users.noreply.github.com> Date: Fri, 12 May 2023 12:56:58 -0400 Subject: [PATCH 37/42] engsys: Remove `tox` from `azure-media-analytics-edge` dev_requirements --- sdk/media/azure-media-analytics-edge/dev_requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/media/azure-media-analytics-edge/dev_requirements.txt b/sdk/media/azure-media-analytics-edge/dev_requirements.txt index 79416d013ec2..031c5086f3f6 100644 --- a/sdk/media/azure-media-analytics-edge/dev_requirements.txt +++ b/sdk/media/azure-media-analytics-edge/dev_requirements.txt @@ -4,4 +4,3 @@ -e ../../identity/azure-identity aiohttp>=3.0; python_version >= '3.5' aiodns>=2.0; python_version >= '3.5' -tox>=4.4.11 From 5d6243e4ef66e9e09c12901b9feef935cc47717a Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Fri, 12 May 2023 13:33:34 -0700 Subject: [PATCH 38/42] align regression version of ci/test_tools.txt --- eng/ci_tools.txt | 7 +------ eng/regression_test_tools.txt | 20 ++++++++++++-------- eng/regression_tools.txt | 25 ++++++++++--------------- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/eng/ci_tools.txt b/eng/ci_tools.txt index b43f9835f4d9..b3348ed08ff7 100644 --- a/eng/ci_tools.txt +++ b/eng/ci_tools.txt @@ -1,6 +1,5 @@ # requirements leveraged by ci tools cryptography<4 -setuptools==44.1.0; python_version == '2.7' setuptools==67.6.0; python_version >= '3.5' virtualenv==20.23.0 wheel==0.37.0 @@ -15,11 +14,7 @@ pkginfo==1.5.0.1 pip==20.3.3 wrapt==1.12.1; python_version <= '3.10' wrapt==1.14.1; python_version >= '3.11' -markupsafe==2.0.1; python_version > '2.7' -markupsafe==1.1.1; python_version == '2.7' - -# python 3.10 pinned packages -cffi==1.15.0rc2; python_version >= '3.10' +markupsafe==2.0.1 # locking packages defined as deps from azure-sdk-tools or azure-devtools pytoml==0.1.21 diff --git a/eng/regression_test_tools.txt b/eng/regression_test_tools.txt index cf56b0b22031..8a11aca7c7fa 100644 --- a/eng/regression_test_tools.txt +++ b/eng/regression_test_tools.txt @@ -1,15 +1,17 @@ pip==20.2 +cryptography<4 # requirements leveraged by ci for testing -pytest==4.6.9; python_version == '2.7' -pytest==5.4.2; python_version >= '3.5' -pytest-asyncio==0.12.0; python_version >= '3.5' -pytest-cov==2.8.1 +pytest==7.3.1 +pytest-asyncio==0.21.0 +pytest-cov==4.0.0 pytest-custom-exit-code==0.3.0 -pytest-xdist==1.32.0 -# we pin coverage to 4.5.4 because there is an bug with `pytest-cov`. the generated coverage files cannot be `coverage combine`ed +pytest-xdist==3.2.1 coverage==7.2.5 bandit==1.6.2 +protobuf==3.17.3; python_version == '2.7' +chardet>=2.0,<5.0 +cmarkgfm<0.7.0 # locking packages defined as deps from azure-sdk-tools or azure-devtools pytoml==0.1.21 @@ -20,14 +22,16 @@ ConfigArgParse==1.2.3 six==1.14.0 pyyaml==5.3.1 packaging==23.1 -wheel==0.34.2 Jinja2==2.11.2 markupsafe==2.0.1; python_version > '2.7' markupsafe==1.1.1; python_version == '2.7' +wrapt==1.12.1; python_version <= '3.10' +wrapt==1.14.1; python_version >= '3.11' # Locking pylint and required packages pylint==1.8.4; python_version < '3.4' -pylint==2.5.2; python_version >= '3.4' +pylint==2.9.3; python_version >= '3.6' and python_version <= '3.10' +pylint==2.14.5; python_version >= '3.11' # python-dotenv python-dotenv==0.15.0 \ No newline at end of file diff --git a/eng/regression_tools.txt b/eng/regression_tools.txt index 13fbcecb380c..c4d7965ea55e 100644 --- a/eng/regression_tools.txt +++ b/eng/regression_tools.txt @@ -1,25 +1,20 @@ # requirements leveraged by ci tools cryptography==3.3.2 -setuptools==44.1.0; python_version == '2.7' setuptools==67.6.0; python_version >= '3.5' virtualenv==20.23.0 -wheel==0.34.2 +wheel==0.37.0 Jinja2==2.11.2 packaging==23.1 tox==4.5.0 -twine==1.15.0; python_version == '2.7' or python_version == '3.5' twine==3.1.1; python_version >= '3.6' pathlib2==2.3.5 -readme-renderer[md]==25.0 -doc-warden==0.7.1 -# we pin coverage to 4.5.4 because there is an bug with `pytest-cov`. the generated coverage files cannot be `coverage combine`ed -coverage==7.2.5 +doc-warden==0.7.2 beautifulsoup4==4.9.1 pkginfo==1.5.0.1 -pip==20.2 -black==21.6b0; python_version >= '3.6' -markupsafe==2.0.1; python_version > '2.7' -markupsafe==1.1.1; python_version == '2.7' +pip==20.3.3 +wrapt==1.12.1; python_version <= '3.10' +wrapt==1.14.1; python_version >= '3.11' +markupsafe==2.0.1 # locking packages defined as deps from azure-sdk-tools or azure-devtools pytoml==0.1.21 @@ -28,10 +23,10 @@ json-delta==2.0 ConfigArgParse==1.2.3 six==1.14.0 pyyaml==5.3.1 -pytest==5.4.2; python_version >= '3.5' -pytest==4.6.9; python_version == '2.7' -pytest-cov==2.8.1 +pytest==7.3.1 +pytest-cov==4.0.0 +coverage==7.2.5 # local dev packages ./tools/azure-devtools -./tools/azure-sdk-tools +./tools/azure-sdk-tools[build] From 9f74919c7d267709550a90828845a2e218eebac0 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Tue, 16 May 2023 18:36:39 -0700 Subject: [PATCH 39/42] new coverage format requires that the package sources be present when combining .coverage files. amend our tox tree cleanup to exclude the whl directory when running coverage. --- scripts/devops_tasks/create_coverage.py | 16 +++++++++++++++- scripts/devops_tasks/tox_harness.py | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/scripts/devops_tasks/create_coverage.py b/scripts/devops_tasks/create_coverage.py index 55a52646b2e8..01f7f6417f48 100644 --- a/scripts/devops_tasks/create_coverage.py +++ b/scripts/devops_tasks/create_coverage.py @@ -57,7 +57,21 @@ def generate_coverage_xml(): else: logging.error("Coverage file is not available in {} to generate coverage XML".format(coverage_dir)) + +def fix_coverage_xml(coverage_file): + print("running 'fix_dot_coverage_file' on {}".format(coverage_file)) + + out = None + with open(coverage_file, encoding="utf-8") as cov_file: + line = cov_file.read() + out = re.sub("\/\.tox\/[\s\S]*?\/site-packages", "", line) + + if out: + with open(coverage_file, 'w') as cov_file: + cov_file.write(out) + if __name__ == "__main__": collect_tox_coverage_files() generate_coverage_xml() - create_coverage_report() \ No newline at end of file + create_coverage_report() + fix_coverage_xml(os.path.join(root_dir, 'coverage.xml')) \ No newline at end of file diff --git a/scripts/devops_tasks/tox_harness.py b/scripts/devops_tasks/tox_harness.py index 9b63643988dc..b039be181667 100644 --- a/scripts/devops_tasks/tox_harness.py +++ b/scripts/devops_tasks/tox_harness.py @@ -198,6 +198,18 @@ def collect_log_files(working_dir): for f in glob.glob(os.path.join(root_dir, "_tox_logs", "*")): logging.info("Log file: {}".format(f)) +def cleanup_tox_environments(tox_dir: str, command_array: str) -> None: + """The new .coverage formats are no longer readily amended in place. Because we can't amend them in place, + we can't amend the source location to remove the path ".tox//site-packages/". Because of this, we will + need the source where it was generated to stick around. We can do that by being a bit more circumspect about which + files we actually delete/clean up! + """ + if "--cov-append" in command_array: + folders = [folder for folder in os.listdir(tox_dir) if "whl" != folder] + for folder in folders: + shutil.rmtree(folder) + else: + shutil.rmtree(tox_dir) def execute_tox_serial(tox_command_tuples): return_code = 0 @@ -218,7 +230,8 @@ def execute_tox_serial(tox_command_tuples): if in_ci(): collect_log_files(cmd_tuple[1]) - shutil.rmtree(tox_dir) + + cleanup_tox_environments(tox_dir, cmd_tuple[0]) if os.path.exists(clone_dir): try: From c278ce59d0819e6512f86b955314670b9ada8d82 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 17 May 2023 11:03:00 -0700 Subject: [PATCH 40/42] ensure that missing hidden folder can't break cleanup operation --- scripts/devops_tasks/tox_harness.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/devops_tasks/tox_harness.py b/scripts/devops_tasks/tox_harness.py index b039be181667..39b37275a507 100644 --- a/scripts/devops_tasks/tox_harness.py +++ b/scripts/devops_tasks/tox_harness.py @@ -207,7 +207,14 @@ def cleanup_tox_environments(tox_dir: str, command_array: str) -> None: if "--cov-append" in command_array: folders = [folder for folder in os.listdir(tox_dir) if "whl" != folder] for folder in folders: - shutil.rmtree(folder) + try: + shutil.rmtree(folder) + except Exception as e: + # git has a permissions problem. one of the files it drops + # cannot be removed as no one has the permission to do so. + # lets log just in case, but this should really only affect windows machines. + logging.info(e) + pass else: shutil.rmtree(tox_dir) From c297c9da9507729ee1d9f9d0ad30433e6a7f8df5 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 17 May 2023 12:53:27 -0700 Subject: [PATCH 41/42] ensure coverage isn't generated on whl_no_aio --- eng/tox/tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/tox/tox.ini b/eng/tox/tox.ini index 8223785524b7..aa1b26718f2b 100644 --- a/eng/tox/tox.ini +++ b/eng/tox/tox.ini @@ -241,7 +241,7 @@ commands = python {repository_root}/eng/tox/create_package_and_install.py -d {envtmpdir} -p {tox_root} -w {envtmpdir} python {repository_root}/eng/tox/try_import.py aiohttp -p {tox_root} python -m pip freeze - pytest {[pytest]default_args} --ignore-glob='*async*.py' {posargs} {tox_root} + pytest {[pytest]default_args} --ignore-glob='*async*.py' {posargs} --no-cov {tox_root} [testenv:whl] From d506e99674fbf105c980146e7f346aa2004019d9 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 17 May 2023 17:52:38 -0700 Subject: [PATCH 42/42] ensure that coverage is generated without wonky package paths --- scripts/devops_tasks/create_coverage.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/devops_tasks/create_coverage.py b/scripts/devops_tasks/create_coverage.py index 01f7f6417f48..1cf679cee522 100644 --- a/scripts/devops_tasks/create_coverage.py +++ b/scripts/devops_tasks/create_coverage.py @@ -64,7 +64,12 @@ def fix_coverage_xml(coverage_file): out = None with open(coverage_file, encoding="utf-8") as cov_file: line = cov_file.read() - out = re.sub("\/\.tox\/[\s\S]*?\/site-packages", "", line) + + # replace relative paths in folder structure pattern + out = re.sub("\/\.tox\/[\s\S_]*?\/site-packages", "", line) + + # replace relative paths in python import pattern + out = re.sub("\.?\.tox[\s\S\.\d]*?\.site-packages", "", out) if out: with open(coverage_file, 'w') as cov_file: