diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7cf56cf8c9d4..d52ea63f244c 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 @@ -1039,56 +1049,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 - - --build-isolation - - --py-version=3.7 - - --no-emit-index-url - - 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 - - --build-isolation - - --py-version=3.8 - - --no-emit-index-url - - 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 - - --build-isolation - - --py-version=3.9 - - --no-emit-index-url - - 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 - - --build-isolation - - --py-version=3.10 - - --no-emit-index-url - - requirements/static/ci/invoke.in - # <---- Invoke ----------------------------------------------------------------------------------------------------- - # ----- Tools ----------------------------------------------------------------------------------------------------> - id: pip-tools-compile alias: compile-ci-tools-3.9-requirements @@ -1242,50 +1202,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.1 - - distro==1.7.0 - - jinja2==3.0.3 - - msgpack==1.0.3 - - packaging - - looseversion - - - repo: https://github.com/saltstack/invoke-pre-commit - rev: v1.9.0 - hooks: - - id: invoke - alias: check-known-missing-docstrings - name: Check Known Missing Docstrings - stages: [manual] - files: salt/.*\.py$ - exclude: > - (?x)^( - templates/.*| - salt/ext/.*| - )$ - args: - - docstrings.check - - --error-on-known-failures - additional_dependencies: - - blessings==1.7 - - pyyaml==6.0.1 - - 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 fddcf357f3ef..c44ab3543814 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1536,7 +1536,7 @@ def lint_salt(session): paths = session.posargs else: # TBD replace paths entries when implement pyproject.toml - paths = ["setup.py", "noxfile.py", "salt/", "tasks/"] + paths = ["setup.py", "noxfile.py", "salt/"] _lint(session, ".pylintrc", flags, paths) @@ -1648,37 +1648,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) - 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 4b9248923866..000000000000 --- a/requirements/static/ci/invoke.in +++ /dev/null @@ -1,5 +0,0 @@ ---constraint=./py{py_version}/{platform}.txt - -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 fbeaead2dd48..000000000000 --- a/requirements/static/ci/py3.10/invoke.txt +++ /dev/null @@ -1,18 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.10/invoke.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==6.0.1 - # via - # -c requirements/static/ci/py3.10/linux.txt - # -r requirements/static/ci/invoke.in -six==1.16.0 - # via - # -c requirements/static/ci/py3.10/linux.txt - # blessings diff --git a/requirements/static/ci/py3.7/invoke.txt b/requirements/static/ci/py3.7/invoke.txt deleted file mode 100644 index dfc00dd752fd..000000000000 --- a/requirements/static/ci/py3.7/invoke.txt +++ /dev/null @@ -1,18 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.7/invoke.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==6.0.1 - # via - # -c requirements/static/ci/py3.7/linux.txt - # -r requirements/static/ci/invoke.in -six==1.16.0 - # via - # -c requirements/static/ci/py3.7/linux.txt - # blessings diff --git a/requirements/static/ci/py3.8/invoke.txt b/requirements/static/ci/py3.8/invoke.txt deleted file mode 100644 index 11ecca4806f0..000000000000 --- a/requirements/static/ci/py3.8/invoke.txt +++ /dev/null @@ -1,18 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.8/invoke.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==6.0.1 - # via - # -c requirements/static/ci/py3.8/linux.txt - # -r requirements/static/ci/invoke.in -six==1.16.0 - # via - # -c requirements/static/ci/py3.8/linux.txt - # blessings diff --git a/requirements/static/ci/py3.9/invoke.txt b/requirements/static/ci/py3.9/invoke.txt deleted file mode 100644 index aeb0bdab1c58..000000000000 --- a/requirements/static/ci/py3.9/invoke.txt +++ /dev/null @@ -1,18 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.9/invoke.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==6.0.1 - # via - # -c requirements/static/ci/py3.9/linux.txt - # -r requirements/static/ci/invoke.in -six==1.16.0 - # via - # -c requirements/static/ci/py3.9/linux.txt - # 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()