From 44d7c99f8d2bab87a1a0acefa4bb2b5616772994 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 27 May 2023 19:36:12 +0100 Subject: [PATCH] Removed all remaining `invoke` support Fixes #64374 Signed-off-by: Pedro Algarvio --- .pre-commit-config.yaml | 75 ++++-------------------- changelog/64374.fixed.md | 2 +- noxfile.py | 31 ---------- requirements/static/ci/invoke.in | 3 - requirements/static/ci/py3.10/invoke.txt | 14 ----- requirements/static/ci/py3.7/invoke.txt | 14 ----- requirements/static/ci/py3.8/invoke.txt | 14 ----- requirements/static/ci/py3.9/invoke.txt | 14 ----- tasks/README.md | 28 --------- tasks/__init__.py | 11 ---- tasks/utils.py | 64 -------------------- 11 files changed, 11 insertions(+), 259 deletions(-) delete mode 100644 requirements/static/ci/invoke.in delete mode 100644 requirements/static/ci/py3.10/invoke.txt delete mode 100644 requirements/static/ci/py3.7/invoke.txt delete mode 100644 requirements/static/ci/py3.8/invoke.txt delete mode 100644 requirements/static/ci/py3.9/invoke.txt delete mode 100644 tasks/README.md delete mode 100644 tasks/__init__.py delete mode 100644 tasks/utils.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0394e53c9f52..c84c3ad6331f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -129,6 +129,16 @@ repos: - salt-loaders - check-virtual + - id: tools + alias: check-filemap + name: Check Filename Map Change Matching + files: ^tests/(filename_map\.yml|.*\.py)$ + pass_filenames: false + args: + - pre-commit + - filemap + - check + # ----- Packaging Requirements ------------------------------------------------------------------------------------> - repo: https://github.com/saltstack/pip-tools-compile-impersonate @@ -964,52 +974,6 @@ repos: - requirements/static/ci/changelog.in # <---- Changelog -------------------------------------------------------------------------------------------------- - # ----- Invoke ----------------------------------------------------------------------------------------------------> - - id: pip-tools-compile - alias: compile-ci-invoke-3.7-requirements - name: Linux CI Py3.7 Invoke Requirements - files: ^requirements/static/ci/(invoke\.in|py3.7/(invoke|linux)\.txt)$ - pass_filenames: false - args: - - -v - - --py-version=3.7 - - --pip-args=--constraint=requirements/static/ci/py{py_version}/linux.txt - - requirements/static/ci/invoke.in - - - id: pip-tools-compile - alias: compile-ci-invoke-3.8-requirements - name: Linux CI Py3.8 Invoke Requirements - files: ^requirements/static/ci/(invoke\.in|py3.8/(invoke|linux)\.txt)$ - pass_filenames: false - args: - - -v - - --py-version=3.8 - - --pip-args=--constraint=requirements/static/ci/py{py_version}/linux.txt - - requirements/static/ci/invoke.in - - - id: pip-tools-compile - alias: compile-ci-invoke-3.9-requirements - name: Linux CI Py3.9 Invoke Requirements - files: ^requirements/static/ci/(invoke\.in|py3.9/(invoke|linux)\.txt)$ - pass_filenames: false - args: - - -v - - --py-version=3.9 - - --pip-args=--constraint=requirements/static/ci/py{py_version}/linux.txt - - requirements/static/ci/invoke.in - - - id: pip-tools-compile - alias: compile-ci-invoke-3.10-requirements - name: Linux CI Py3.10 Invoke Requirements - files: ^requirements/static/ci/(invoke\.in|py3.10/(invoke|linux)\.txt)$ - pass_filenames: false - args: - - -v - - --py-version=3.10 - - --pip-args=--constraint=requirements/static/ci/py{py_version}/linux.txt - - requirements/static/ci/invoke.in - # <---- Invoke ----------------------------------------------------------------------------------------------------- - # <---- PKG ci requirements----------------------------------------------------------------------------------------- - id: pip-tools-compile alias: compile-ci-pkg-3.10-requirements @@ -1219,25 +1183,6 @@ repos: # <---- Security --------------------------------------------------------------------------------------------------- # ----- Pre-Commit ------------------------------------------------------------------------------------------------> - - repo: https://github.com/saltstack/invoke-pre-commit - rev: v1.9.0 - hooks: - - id: invoke - alias: check-filemap - name: Check Filename Map Change Matching - files: ^tests/(filename_map\.yml|.*\.py)$ - pass_filenames: false - args: - - filemap.check - additional_dependencies: - - blessings==1.7 - - pyyaml==6.0 - - distro==1.7.0 - - jinja2==3.0.3 - - msgpack==1.0.3 - - packaging - - looseversion - - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.3.0 hooks: diff --git a/changelog/64374.fixed.md b/changelog/64374.fixed.md index e56ef8030360..31dfc9b1b1dd 100644 --- a/changelog/64374.fixed.md +++ b/changelog/64374.fixed.md @@ -1,4 +1,4 @@ -Migrated some [`invoke`](https://www.pyinvoke.org/) tasks to [`python-tools-scripts`](https://github.com/s0undt3ch/python-tools-scripts). +Migrated all [`invoke`](https://www.pyinvoke.org/) tasks to [`python-tools-scripts`](https://github.com/s0undt3ch/python-tools-scripts). * `tasks/docs.py` -> `tools/precommit/docs.py` * `tasks/docstrings.py` -> `tools/precommit/docstrings.py` diff --git a/noxfile.py b/noxfile.py index 9a7afa93bdc3..35d9c91dcf4d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1559,37 +1559,6 @@ def docs_man(session, compress, update, clean): os.chdir("..") -@nox.session(name="invoke", python="3") -def invoke(session): - """ - Run invoke tasks - """ - if _upgrade_pip_setuptools_and_wheel(session): - _install_requirements(session, "zeromq") - requirements_file = os.path.join( - "requirements", "static", "ci", _get_pydir(session), "invoke.txt" - ) - install_command = ["--progress-bar=off", "-r", requirements_file] - session.install(*install_command, silent=PIP_INSTALL_SILENT) - - cmd = ["inv"] - files = [] - - # Unfortunately, invoke doesn't support the nargs functionality like argpase does. - # Let's make it behave properly - for idx, posarg in enumerate(session.posargs): - if idx == 0: - cmd.append(posarg) - continue - if posarg.startswith("--"): - cmd.append(posarg) - continue - files.append(posarg) - if files: - cmd.append("--files={}".format(" ".join(files))) - session.run(*cmd) - - @nox.session(name="changelog", python="3") @nox.parametrize("draft", [False, True]) @nox.parametrize("force", [False, True]) diff --git a/requirements/static/ci/invoke.in b/requirements/static/ci/invoke.in deleted file mode 100644 index 87633def6566..000000000000 --- a/requirements/static/ci/invoke.in +++ /dev/null @@ -1,3 +0,0 @@ -invoke -blessings -pyyaml diff --git a/requirements/static/ci/py3.10/invoke.txt b/requirements/static/ci/py3.10/invoke.txt deleted file mode 100644 index 591666c84684..000000000000 --- a/requirements/static/ci/py3.10/invoke.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --output-file=requirements/static/ci/py3.10/invoke.txt --pip-args='--constraint=requirements/static/ci/py3.10/linux.txt' requirements/static/ci/invoke.in -# -blessings==1.7 - # via -r requirements/static/ci/invoke.in -invoke==1.4.1 - # via -r requirements/static/ci/invoke.in -pyyaml==5.4.1 - # via -r requirements/static/ci/invoke.in -six==1.16.0 - # via blessings diff --git a/requirements/static/ci/py3.7/invoke.txt b/requirements/static/ci/py3.7/invoke.txt deleted file mode 100644 index e2cad5c72e0d..000000000000 --- a/requirements/static/ci/py3.7/invoke.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --output-file=requirements/static/ci/py3.7/invoke.txt --pip-args='--constraint=requirements/static/ci/py3.7/linux.txt' requirements/static/ci/invoke.in -# -blessings==1.7 - # via -r requirements/static/ci/invoke.in -invoke==1.4.1 - # via -r requirements/static/ci/invoke.in -pyyaml==5.4.1 - # via -r requirements/static/ci/invoke.in -six==1.16.0 - # via blessings diff --git a/requirements/static/ci/py3.8/invoke.txt b/requirements/static/ci/py3.8/invoke.txt deleted file mode 100644 index 356dd4213081..000000000000 --- a/requirements/static/ci/py3.8/invoke.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --output-file=requirements/static/ci/py3.8/invoke.txt --pip-args='--constraint=requirements/static/ci/py3.8/linux.txt' requirements/static/ci/invoke.in -# -blessings==1.7 - # via -r requirements/static/ci/invoke.in -invoke==1.4.1 - # via -r requirements/static/ci/invoke.in -pyyaml==5.4.1 - # via -r requirements/static/ci/invoke.in -six==1.16.0 - # via blessings diff --git a/requirements/static/ci/py3.9/invoke.txt b/requirements/static/ci/py3.9/invoke.txt deleted file mode 100644 index 3e1879c97e12..000000000000 --- a/requirements/static/ci/py3.9/invoke.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --output-file=requirements/static/ci/py3.9/invoke.txt --pip-args='--constraint=requirements/static/ci/py3.9/linux.txt' requirements/static/ci/invoke.in -# -blessings==1.7 - # via -r requirements/static/ci/invoke.in -invoke==1.4.1 - # via -r requirements/static/ci/invoke.in -pyyaml==5.4.1 - # via -r requirements/static/ci/invoke.in -six==1.16.0 - # via blessings diff --git a/tasks/README.md b/tasks/README.md deleted file mode 100644 index 6ff3fb10a7df..000000000000 --- a/tasks/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# What is this directory? - -This directory contains python scripts which should be called by [invoke](https://pypi.org/project/invoke). - -Instead of having several multi-purpose python scripts scatered through multiple paths in the salt code base, -we will now concentrate them under an invoke task. - -## Calling Invoke - -Invoke can be called in the following ways. - -### Installed system-wide - -If invoke is installed system-wide, be sure you also have `blessings` installed if you want coloured output, although -it's not a hard requirement. - -``` -inv docs.check -``` - -### Using Nox - -Since salt already uses nox, and nox manages virtual environments and respective requirements, calling invoke is as -simple as: - -``` -nox -e invoke -- docs.check -``` diff --git a/tasks/__init__.py b/tasks/__init__.py deleted file mode 100644 index 5f5aac88cb86..000000000000 --- a/tasks/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from invoke import Collection # pylint: disable=3rd-party-module-not-gated - -from . import docs, docstrings, filemap, loader - -ns = Collection() -ns.add_collection(Collection.from_module(docs, name="docs"), name="docs") -ns.add_collection( - Collection.from_module(docstrings, name="docstrings"), name="docstrings" -) -ns.add_collection(Collection.from_module(loader, name="loader"), name="loader") -ns.add_collection(Collection.from_module(filemap, name="filemap"), name="filemap") diff --git a/tasks/utils.py b/tasks/utils.py deleted file mode 100644 index e082508a5a32..000000000000 --- a/tasks/utils.py +++ /dev/null @@ -1,64 +0,0 @@ -""" - tasks.utils - ~~~~~~~~~~~ - - Invoke utilities -""" - -import sys - -try: - from blessings import Terminal - - try: - terminal = Terminal() - HAS_BLESSINGS = True - except Exception: # pylint: disable=broad-except - terminal = None - HAS_BLESSINGS = False -except ImportError: - terminal = None - HAS_BLESSINGS = False - - -def exit_invoke(exitcode, message=None, *args, **kwargs): - if message is not None: - if exitcode > 0: - warn(message, *args, **kwargs) - else: - info(message, *args, **kwargs) - sys.exit(exitcode) - - -def info(message, *args, **kwargs): - if not isinstance(message, str): - message = str(message) - message = message.format(*args, **kwargs) - if terminal: - message = terminal.bold(terminal.green(message)) - write_message(message) - - -def warn(message, *args, **kwargs): - if not isinstance(message, str): - message = str(message) - message = message.format(*args, **kwargs) - if terminal: - message = terminal.bold(terminal.yellow(message)) - write_message(message) - - -def error(message, *args, **kwargs): - if not isinstance(message, str): - message = str(message) - message = message.format(*args, **kwargs) - if terminal: - message = terminal.bold(terminal.red(message)) - write_message(message) - - -def write_message(message): - sys.stderr.write(message) - if not message.endswith("\n"): - sys.stderr.write("\n") - sys.stderr.flush()