From 1ab069ca5149cc4d6261446a763656317dbdf74e Mon Sep 17 00:00:00 2001 From: Sebastian Yaghoubi Date: Sun, 29 Dec 2024 17:36:22 -0800 Subject: [PATCH 01/25] feat: add shell completions for molecule Signed-off-by: Sebastian Yaghoubi --- final/setup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/final/setup.sh b/final/setup.sh index a1948e5e..78b25f3c 100755 --- a/final/setup.sh +++ b/final/setup.sh @@ -116,6 +116,9 @@ activate-global-python-argcomplete # Install oh-my-zsh sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" +# Add completions to zsh +echo eval \"\$\(_MOLECULE_COMPLETE=zsh_source molecule\)\" > ~/.oh-my-zsh/custom/molecule-completions.zsh + # shellcheck disable=SC1091 source "$DIR/setup-image.sh" From 42c8cb47c3c4ad6105dca9e2d4883e6ca1364df1 Mon Sep 17 00:00:00 2001 From: Sebastian Yaghoubi Date: Thu, 9 Jan 2025 14:29:10 -0800 Subject: [PATCH 02/25] test(completions-molecule): add integration tests for zsh completions Signed-off-by: Sebastian Yaghoubi --- tests/integration/test_zsh_completions.py | 118 ++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 tests/integration/test_zsh_completions.py diff --git a/tests/integration/test_zsh_completions.py b/tests/integration/test_zsh_completions.py new file mode 100644 index 00000000..92f922bb --- /dev/null +++ b/tests/integration/test_zsh_completions.py @@ -0,0 +1,118 @@ +"""Test suite for shell completion functionality. + +This module provides pytest fixtures and tests to verify that ZSH shell +completions are active for various commands. +""" + +from __future__ import annotations + +import subprocess + +from pathlib import Path +from typing import TYPE_CHECKING + +import pytest + + +if TYPE_CHECKING: + from collections.abc import Callable + + +@pytest.fixture(scope="module") +def zsh_path() -> Path: + """Locate the ZSH executable. + + Returns: + Path to ZSH executable. + + Raises: + FileNotFoundError: If ZSH is not found in standard locations. + """ + path = next( + (Path(p) for p in ["/usr/bin/zsh", "/bin/zsh"] if Path(p).exists()), + None, + ) + if not path: + msg = "ZSH not found in standard locations" + raise FileNotFoundError(msg) + return path + + +@pytest.fixture(scope="module") +def completion_checker(zsh_path: Path) -> Callable[[str], tuple[bool, str]]: + """Provide a function to test ZSH completion status for commands. + + Args: + zsh_path: Path to the ZSH executable. + + Returns: + A callable that takes a command name and returns a tuple of + (is_active: bool, details: str) indicating whether completions + are active for that command. + """ + + def check(command: str) -> tuple[bool, str]: + """Test if ZSH completions are active for a command. + + Args: + command: The name of the command to check completions for. + + Returns: + A tuple of (is_active, details) where is_active is a boolean + indicating if completions are working, and details is a string + containing the test output or error message. + + Raises: + subprocess.TimeoutExpired: If the command times out. + OSError: If an OS-level error occurs. + """ + # Construct the test command + test_command = ( + "source ~/.zshrc && " + f"type _{command} &>/dev/null && " + 'echo "COMPLETIONS_ACTIVE=true" || ' + 'echo "COMPLETIONS_ACTIVE=false"' + ) + + try: + result = subprocess.run( # noqa: S603 + [zsh_path, "-c", test_command], + capture_output=True, + text=True, + check=False, + timeout=5, # Prevent hanging + ) + is_active = "COMPLETIONS_ACTIVE=true" in result.stdout + return is_active, result.stdout.strip() + + except subprocess.TimeoutExpired: + return False, "Command timed out after 5 seconds" + except OSError as e: + return False, f"OS error occurred: {e!s}" + + return check + + +class TestShellCompletions: + """Test suite for shell completion functionality.""" + + @pytest.mark.parametrize( + "command", + ( + "molecule_completion", + # Add more commands here as needed + ), + ) + def test_command_completions( + self, + completion_checker: Callable[[str], tuple[bool, str]], + command: str, + ) -> None: + """Verify that command completions are properly configured and active. + + Args: + completion_checker: Fixture providing the completion testing function. + command: The command to test completions for. + """ + is_active, details = completion_checker(command) + assert is_active, f"Completions for '{command}' are not active. Details:\n{details}" From 3f0eeabc41d3f1e4c25f82a6828bf65a96179f01 Mon Sep 17 00:00:00 2001 From: Sebastian Yaghoubi Date: Thu, 9 Jan 2025 15:34:24 -0800 Subject: [PATCH 03/25] style: fix linting error and warnings - pydoclint-DOC502: Remove the Raise section in the docstring since it wasn't an explicit raise condition -pylint-W0621: Don't rename scopes Signed-off-by: Sebastian Yaghoubi --- tests/integration/test_zsh_completions.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/integration/test_zsh_completions.py b/tests/integration/test_zsh_completions.py index 92f922bb..75e31773 100644 --- a/tests/integration/test_zsh_completions.py +++ b/tests/integration/test_zsh_completions.py @@ -39,11 +39,11 @@ def zsh_path() -> Path: @pytest.fixture(scope="module") -def completion_checker(zsh_path: Path) -> Callable[[str], tuple[bool, str]]: +def completion_checker(zsh: Path) -> Callable[[str], tuple[bool, str]]: """Provide a function to test ZSH completion status for commands. Args: - zsh_path: Path to the ZSH executable. + zsh: Path to the ZSH executable. Returns: A callable that takes a command name and returns a tuple of @@ -61,10 +61,6 @@ def check(command: str) -> tuple[bool, str]: A tuple of (is_active, details) where is_active is a boolean indicating if completions are working, and details is a string containing the test output or error message. - - Raises: - subprocess.TimeoutExpired: If the command times out. - OSError: If an OS-level error occurs. """ # Construct the test command test_command = ( @@ -76,7 +72,7 @@ def check(command: str) -> tuple[bool, str]: try: result = subprocess.run( # noqa: S603 - [zsh_path, "-c", test_command], + [zsh, "-c", test_command], capture_output=True, text=True, check=False, @@ -105,14 +101,14 @@ class TestShellCompletions: ) def test_command_completions( self, - completion_checker: Callable[[str], tuple[bool, str]], + check_completions: Callable[[str], tuple[bool, str]], command: str, ) -> None: """Verify that command completions are properly configured and active. Args: - completion_checker: Fixture providing the completion testing function. + check_completions: Fixture providing the completion testing function. command: The command to test completions for. """ - is_active, details = completion_checker(command) + is_active, details = check_completions(command) assert is_active, f"Completions for '{command}' are not active. Details:\n{details}" From 83f7a879e773bb6ee1ca6a7c1610e7f0ab59ec78 Mon Sep 17 00:00:00 2001 From: Ajinkya Udgirkar Date: Tue, 21 Jan 2025 20:27:13 +0530 Subject: [PATCH 04/25] Revert "Bump ansible-compat from 24.10.0 to 25.0.0 in /.config (#514)" (#517) This reverts commit a08224b22eaed94abe1787c5c4c0a0c8cfe445f1. --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index 6ac3f64c..a9571e31 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -1,7 +1,7 @@ # This file was autogenerated by uv via the following command: # tox run deps ansible-builder==3.1.0 -ansible-compat==25.0.0 +ansible-compat==24.10.0 ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==24.12.0 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 69c9e935..8ec7e3f6 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -1,7 +1,7 @@ # This file was autogenerated by uv via the following command: # tox run deps ansible-builder==3.1.0 -ansible-compat==25.0.0 +ansible-compat==24.10.0 ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==24.12.0 From 4430faade2a192e4dd321008807d967d2f5e219c Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 21 Jan 2025 15:15:13 +0000 Subject: [PATCH 05/25] Remove black and rely on ruff-format alone (#520) Needed: #519 --- .pre-commit-config.yaml | 7 +------ .vscode/extensions.json | 1 - .vscode/settings.json | 2 +- tests/integration/test_server_info.py | 6 +++--- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4dfdcb90..5b324c2b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -67,7 +67,7 @@ repos: - id: tox-ini-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.6 + rev: v0.9.2 hooks: - id: ruff args: @@ -77,11 +77,6 @@ repos: - id: ruff-format # must be after ruff types_or: [python, pyi] - - repo: https://github.com/psf/black # must be after ruff - rev: 24.10.0 - hooks: - - id: black - - repo: https://github.com/streetsidesoftware/cspell-cli rev: v8.17.0 hooks: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 24039735..dc0a49a8 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,7 +4,6 @@ "esbenp.prettier-vscode", "gruntfuggly.triggertaskonsave", "markis.code-coverage", - "ms-python.black-formatter", "ms-python.debugpy", "ms-python.mypy-type-checker", "ms-python.pylint", diff --git a/.vscode/settings.json b/.vscode/settings.json index 2ee1137a..23ecf650 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,7 +7,7 @@ "source.fixAll": "explicit", "source.organizeImports": "explicit" }, - "editor.defaultFormatter": "ms-python.black-formatter", + "editor.defaultFormatter": "charliermarsh.ruff", "editor.formatOnSave": true }, "ansible.ansible.useFullyQualifiedCollectionNames": true, diff --git a/tests/integration/test_server_info.py b/tests/integration/test_server_info.py index 6b389c5e..022a8b26 100644 --- a/tests/integration/test_server_info.py +++ b/tests/integration/test_server_info.py @@ -16,9 +16,9 @@ def test_metadata(server_url: str) -> None: response = requests.get(endpoint, timeout=10) expected_response_code = 200 - assert ( - response.status_code == expected_response_code - ), f"Expected status code 200 but got {response.status_code}" + assert response.status_code == expected_response_code, ( + f"Expected status code 200 but got {response.status_code}" + ) assert response.headers["Content-Type"] == "application/json" From ffba74491b43150ca6f76f756a521415f095557d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 20:51:25 +0530 Subject: [PATCH 06/25] Bump ansible-navigator from 24.12.0 to 25.1.0 in /.config (#518) Bumps [ansible-navigator](https://github.com/ansible/ansible-navigator) from 24.12.0 to 25.1.0. - [Release notes](https://github.com/ansible/ansible-navigator/releases) - [Changelog](https://github.com/ansible/ansible-navigator/blob/main/CHANGELOG.md) - [Commits](https://github.com/ansible/ansible-navigator/compare/v24.12.0...v25.1.0) --- updated-dependencies: - dependency-name: ansible-navigator dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index a9571e31..723925f5 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -6,7 +6,7 @@ ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==24.12.0 ansible-lint==25.1.0 -ansible-navigator==24.12.0 +ansible-navigator==25.1.0 ansible-runner==2.4.0 ansible-sign==0.1.1 asgiref==3.8.1 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 8ec7e3f6..ba9363cf 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -6,7 +6,7 @@ ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==24.12.0 ansible-lint==25.1.0 -ansible-navigator==24.12.0 +ansible-navigator==25.1.0 ansible-runner==2.4.0 ansible-sign==0.1.1 attrs==24.2.0 From ae1a536b3e20bf320ad24cd0c78bda4c735039e9 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 21 Jan 2025 15:26:53 +0000 Subject: [PATCH 07/25] Testing maintenance (#519) --- .config/constraints.txt | 12 ++++++------ .config/pydoclint-baseline.txt | 3 --- .pre-commit-config.yaml | 9 ++++++--- .taplo.toml | 6 ++++++ tests/conftest.py | 6 +++--- tests/integration/test_container.py | 2 +- tests/integration/test_server_creator_v1.py | 2 +- tests/integration/test_server_creator_v2.py | 2 +- tox.ini | 1 + 9 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 .taplo.toml diff --git a/.config/constraints.txt b/.config/constraints.txt index 723925f5..62b58d5a 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -49,7 +49,7 @@ griffe==1.5.4 gunicorn==23.0.0 hjson==3.1.0 htmlmin2==0.1.13 -identify==2.6.3 +identify==2.6.5 idna==3.10 importlib-metadata==8.5.0 iniconfig==2.0.0 @@ -87,7 +87,7 @@ mkdocstrings==0.27.0 mkdocstrings-python==1.13.0 molecule==24.12.0 more-itertools==10.5.0 -mypy==1.14.0 +mypy==1.14.1 mypy-extensions==1.0.0 nodeenv==1.9.1 onigurumacffi==1.3.0 @@ -102,7 +102,7 @@ pathable==0.4.3 pathspec==0.12.1 pbr==6.1.0 pexpect==4.9.0 -pillow==11.0.0 +pillow==11.1.0 platformdirs==4.3.6 pluggy==1.5.0 pre-commit==4.0.1 @@ -111,7 +111,7 @@ pycparser==2.22 pydoclint==0.5.14 pygments==2.18.0 pylint==3.3.3 -pymdown-extensions==10.13 +pymdown-extensions==10.14 pyproject-api==1.8.0 pytest==8.3.4 pytest-ansible==24.12.0 @@ -131,7 +131,7 @@ rich==13.9.4 rpds-py==0.22.3 ruamel-yaml==0.18.6 ruamel-yaml-clib==0.2.12 -ruff==0.8.4 +ruff==0.9.0 six==1.17.0 soupsieve==2.6 sqlparse==0.5.3 @@ -144,7 +144,7 @@ toml-sort==0.24.2 tomlkit==0.13.2 tox==4.23.2 tox-ansible==24.12.0 -types-pyyaml==6.0.12.20241221 +types-pyyaml==6.0.12.20241230 types-requests==2.32.0.20241016 tzdata==2024.2 urllib3==2.3.0 diff --git a/.config/pydoclint-baseline.txt b/.config/pydoclint-baseline.txt index 157652ab..e69de29b 100644 --- a/.config/pydoclint-baseline.txt +++ b/.config/pydoclint-baseline.txt @@ -1,3 +0,0 @@ -tests/conftest.py - DOC503: Method `Infrastructure.__post_init__` exceptions in the "Raises" section in the docstring do not match those in the function body Raises values in the docstring: ['ValueError', 'ValueError', 'ValueError']. Raised exceptions in the body: ['ValueError']. --------------------- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5b324c2b..fc928011 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,6 +17,9 @@ default_language_version: # lock extra will not be usable those. python: "3.11" repos: + - repo: meta + hooks: + - id: check-useless-excludes # - repo: https://github.com/rhysd/actionlint # rev: v1.7.3 # hooks: @@ -46,7 +49,7 @@ repos: hooks: - id: shellcheck - - repo: https://github.com/pycontribs/mirrors-prettier + - repo: https://github.com/rbubley/mirrors-prettier rev: v3.4.2 hooks: - id: prettier @@ -78,13 +81,13 @@ repos: types_or: [python, pyi] - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.17.0 + rev: v8.17.1 hooks: - id: cspell name: Spell check with cspell - repo: https://github.com/jsh9/pydoclint - rev: "0.5.14" + rev: "0.6.0" hooks: - id: pydoclint # This allows automatic reduction of the baseline file when needed. diff --git a/.taplo.toml b/.taplo.toml new file mode 100644 index 00000000..0d2e9863 --- /dev/null +++ b/.taplo.toml @@ -0,0 +1,6 @@ +[formatting] +# compatibility with toml-sort-fix pre-commit hook +array_trailing_comma = false +compact_arrays = true +compact_inline_tables = true +inline_table_expand = false diff --git a/tests/conftest.py b/tests/conftest.py index 2e41700f..e7c66792 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -83,9 +83,9 @@ def __post_init__(self) -> None: """Initialize the infrastructure. Raises: - ValueError: If the container engine is not found. - ValueError: If the container name is not set. - ValueError: If both only_container and include_container are set. + ValueError: If the container engine is not found, + If the container name is not set. + If both only_container and include_container are set. """ self.container_engine = self.session.config.getoption("--container-engine") self.container_name = self.session.config.getoption("--container-name", "") diff --git a/tests/integration/test_container.py b/tests/integration/test_container.py index a09a2a4a..fbb9c573 100644 --- a/tests/integration/test_container.py +++ b/tests/integration/test_container.py @@ -12,7 +12,7 @@ from ansible_dev_tools.version_builder import PKGS from .test_server_creator_v1 import test_collection_v1 as tst_collection_v1 -from .test_server_creator_v1 import test_error as tst_error +from .test_server_creator_v1 import test_error_v1 as tst_error from .test_server_creator_v1 import test_playbook_v1 as tst_playbook_v1 from .test_server_info import test_metadata as tst_get_metadata diff --git a/tests/integration/test_server_creator_v1.py b/tests/integration/test_server_creator_v1.py index 8dfe5b58..f003c9e6 100644 --- a/tests/integration/test_server_creator_v1.py +++ b/tests/integration/test_server_creator_v1.py @@ -15,7 +15,7 @@ @pytest.mark.parametrize("resource", ("playbook", "collection")) -def test_error(server_url: str, resource: str) -> None: +def test_error_v1(server_url: str, resource: str) -> None: """Test the error response. Args: diff --git a/tests/integration/test_server_creator_v2.py b/tests/integration/test_server_creator_v2.py index bcbc0385..4e544bfb 100644 --- a/tests/integration/test_server_creator_v2.py +++ b/tests/integration/test_server_creator_v2.py @@ -15,7 +15,7 @@ @pytest.mark.parametrize("resource", ("playbook", "collection")) -def test_error(server_url: str, resource: str) -> None: +def test_error_v2(server_url: str, resource: str) -> None: """Test the error response. Args: diff --git a/tox.ini b/tox.ini index 66d1548f..867dddc2 100644 --- a/tox.ini +++ b/tox.ini @@ -142,6 +142,7 @@ commands = ./tools/ee.sh allowlist_externals = ./tools/ee.sh +editable = true [testenv:devspaces] description = Build devspaces container image for current architecture From 6b7a6497dee0ee57d66032eb0e887275ca7fbd8c Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 21 Jan 2025 16:36:47 +0000 Subject: [PATCH 08/25] Use uv with tox and pre-commit (#521) --- .config/constraints.txt | 30 +++++++++++++++--------------- .config/requirements-lock.txt | 2 +- pyproject.toml | 2 +- tox.ini | 14 ++++++-------- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index 62b58d5a..33ecb489 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -1,5 +1,5 @@ # This file was autogenerated by uv via the following command: -# tox run deps +# tox run -e deps ansible-builder==3.1.0 ansible-compat==24.10.0 ansible-core==2.18.1 @@ -36,20 +36,20 @@ defusedxml==0.7.1 dill==0.3.9 distlib==0.3.9 distro==1.9.0 -django==5.1.4 -django-stubs==5.1.1 -django-stubs-ext==5.1.1 +django==5.1.5 +django-stubs==5.1.2 +django-stubs-ext==5.1.2 dnspython==2.7.0 -docstring-parser-fork==0.0.9 +docstring-parser-fork==0.0.12 enrich==1.2.7 execnet==2.1.1 filelock==3.16.1 ghp-import==2.1.0 -griffe==1.5.4 +griffe==1.5.5 gunicorn==23.0.0 hjson==3.1.0 htmlmin2==0.1.13 -identify==2.6.5 +identify==2.6.6 idna==3.10 importlib-metadata==8.5.0 iniconfig==2.0.0 @@ -74,41 +74,41 @@ mdurl==0.1.2 mergedeep==1.3.4 mkdocs==1.6.1 mkdocs-ansible==24.12.0 -mkdocs-autorefs==1.2.0 +mkdocs-autorefs==1.3.0 mkdocs-gen-files==0.5.0 mkdocs-get-deps==0.2.0 mkdocs-htmlproofer-plugin==1.3.0 mkdocs-macros-plugin==1.3.7 -mkdocs-material==9.5.49 +mkdocs-material==9.5.50 mkdocs-material-extensions==1.3.1 mkdocs-minify-plugin==0.8.0 mkdocs-monorepo-plugin==1.1.0 mkdocstrings==0.27.0 mkdocstrings-python==1.13.0 molecule==24.12.0 -more-itertools==10.5.0 +more-itertools==10.6.0 mypy==1.14.1 mypy-extensions==1.0.0 nodeenv==1.9.1 onigurumacffi==1.3.0 openapi-core==0.19.4 -openapi-schema-validator==0.6.2 +openapi-schema-validator==0.6.3 openapi-spec-validator==0.7.1 packaging==24.2 paginate==0.5.7 parse==1.20.2 parsley==1.3 -pathable==0.4.3 +pathable==0.4.4 pathspec==0.12.1 pbr==6.1.0 pexpect==4.9.0 pillow==11.1.0 platformdirs==4.3.6 pluggy==1.5.0 -pre-commit==4.0.1 +pre-commit==4.1.0 ptyprocess==0.7.0 pycparser==2.22 -pydoclint==0.5.14 +pydoclint==0.6.0 pygments==2.18.0 pylint==3.3.3 pymdown-extensions==10.14 @@ -131,7 +131,7 @@ rich==13.9.4 rpds-py==0.22.3 ruamel-yaml==0.18.6 ruamel-yaml-clib==0.2.12 -ruff==0.9.0 +ruff==0.9.2 six==1.17.0 soupsieve==2.6 sqlparse==0.5.3 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index ba9363cf..8661ad86 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -1,5 +1,5 @@ # This file was autogenerated by uv via the following command: -# tox run deps +# tox run -e deps ansible-builder==3.1.0 ansible-compat==24.10.0 ansible-core==2.18.1 diff --git a/pyproject.toml b/pyproject.toml index 8a865a34..672c7fca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -402,6 +402,6 @@ environments = ["platform_system != 'Windows'"] [tool.uv.pip] # annotation-style = "line" -custom-compile-command = "tox run deps" +custom-compile-command = "tox run -e deps" no-annotate = true no-emit-package = ["pip", "resolvelib", "typing_extensions", "uv", "pip", "distribute", "setuptools"] diff --git a/tox.ini b/tox.ini index 867dddc2..554bc1b2 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ requires = tox>=4.11.3 tox-extra>=2.0.2 + tox-uv>=1.19 env_list = py deps @@ -43,13 +44,16 @@ pass_env = USER XDG_RUNTIME_DIR set_env = - !milestone: PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt COVERAGE_COMBINED = {envdir}/.coverage COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}} COVERAGE_PROCESS_START = {toxinidir}/pyproject.toml FORCE_COLOR = 1 + PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt PRE_COMMIT_COLOR = always TERM = xterm-256color + UV_CONSTRAINT = {toxinidir}/.config/constraints.txt + deps, devel, lint, milestone, py310: PIP_CONSTRAINT = /dev/null + deps, devel, lint, milestone, py310: UV_CONSTRAINT = /dev/null commands_pre = sh -c "rm -f {envdir}/.coverage* 2>/dev/null || true" commands = @@ -72,8 +76,6 @@ skip_install = true deps = {[testenv:lint]deps} extras = -set_env = - PIP_CONSTRAINT = /dev/null commands_pre = commands = -pre-commit run --all-files --show-diff-on-failure --hook-stage manual deps @@ -99,8 +101,7 @@ description = Enforce quality standards under {basepython} skip_install = true deps = pre-commit -set_env = - PIP_CONSTRAINT = /dev/null + pre-commit-uv commands = pre-commit run --show-diff-on-failure --all-files @@ -110,9 +111,6 @@ description = deps = ansible-core@ https://github.com/ansible/ansible/archive/milestone.tar.gz ansible-creator<24.10.0 -set_env = - {[testenv]set_env} - PIP_CONSTRAINT = /dev/null [testenv:pkg] description = From 87a1617e1f6e1d6127f1ba9a3314f2331fde77e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 17:14:47 +0000 Subject: [PATCH 09/25] Bump pytest-ansible from 24.12.0 to 25.1.0 in /.config (#523) Bumps [pytest-ansible](https://github.com/ansible/pytest-ansible) from 24.12.0 to 25.1.0. - [Release notes](https://github.com/ansible/pytest-ansible/releases) - [Changelog](https://github.com/ansible/pytest-ansible/blob/main/HISTORY.md) - [Commits](https://github.com/ansible/pytest-ansible/compare/v24.12.0...v25.1.0) --- updated-dependencies: - dependency-name: pytest-ansible dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index 33ecb489..56e85889 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -114,7 +114,7 @@ pylint==3.3.3 pymdown-extensions==10.14 pyproject-api==1.8.0 pytest==8.3.4 -pytest-ansible==24.12.0 +pytest-ansible==25.1.0 pytest-instafail==0.5.0 pytest-xdist==3.6.1 python-daemon==3.1.2 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 8661ad86..b0a1b861 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -49,7 +49,7 @@ pycparser==2.22 pygments==2.18.0 pyproject-api==1.8.0 pytest==8.3.4 -pytest-ansible==24.12.0 +pytest-ansible==25.1.0 pytest-xdist==3.6.1 python-daemon==3.1.2 python-gnupg==0.5.3 From fe1f2337005e62932a5a765ecc74e5beb6094ffb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 17:55:19 +0000 Subject: [PATCH 10/25] Bump tox-ansible from 24.12.0 to 25.1.0 in /.config (#522) Bumps [tox-ansible](https://github.com/ansible/tox-ansible) from 24.12.0 to 25.1.0. - [Release notes](https://github.com/ansible/tox-ansible/releases) - [Commits](https://github.com/ansible/tox-ansible/compare/v24.12.0...v25.1.0) --- updated-dependencies: - dependency-name: tox-ansible dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index 56e85889..ad91195f 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -143,7 +143,7 @@ tinycss2==1.4.0 toml-sort==0.24.2 tomlkit==0.13.2 tox==4.23.2 -tox-ansible==24.12.0 +tox-ansible==25.1.0 types-pyyaml==6.0.12.20241230 types-requests==2.32.0.20241016 tzdata==2024.2 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index b0a1b861..3c339a96 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -61,7 +61,7 @@ ruamel-yaml==0.18.6 ruamel-yaml-clib==0.2.12 subprocess-tee==0.4.2 tox==4.23.2 -tox-ansible==24.12.0 +tox-ansible==25.1.0 tzdata==2024.2 virtualenv==20.28.0 wcmatch==10.0 From 59f20e64c2ec04adba4163c994a0e3b804747ca9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 18:20:19 +0000 Subject: [PATCH 11/25] Bump molecule from 24.12.0 to 25.1.0 in /.config (#524) Bumps [molecule](https://github.com/ansible-community/molecule) from 24.12.0 to 25.1.0. - [Release notes](https://github.com/ansible-community/molecule/releases) - [Commits](https://github.com/ansible-community/molecule/compare/v24.12.0...v25.1.0) --- updated-dependencies: - dependency-name: molecule dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index ad91195f..704da63f 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -85,7 +85,7 @@ mkdocs-minify-plugin==0.8.0 mkdocs-monorepo-plugin==1.1.0 mkdocstrings==0.27.0 mkdocstrings-python==1.13.0 -molecule==24.12.0 +molecule==25.1.0 more-itertools==10.6.0 mypy==1.14.1 mypy-extensions==1.0.0 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 3c339a96..2c005707 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -34,7 +34,7 @@ lockfile==0.12.2 markdown-it-py==3.0.0 markupsafe==3.0.2 mdurl==0.1.2 -molecule==24.12.0 +molecule==25.1.0 mypy-extensions==1.0.0 onigurumacffi==1.3.0 packaging==24.2 From 14fcd4e582ec8f3c532e26d30c2343242f5e25ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 18:44:18 +0000 Subject: [PATCH 12/25] Bump ansible-dev-environment from 24.12.0 to 25.1.0 in /.config (#525) Bumps [ansible-dev-environment](https://github.com/ansible/ansible-dev-environment) from 24.12.0 to 25.1.0. - [Release notes](https://github.com/ansible/ansible-dev-environment/releases) - [Commits](https://github.com/ansible/ansible-dev-environment/compare/v24.12.0...v25.1.0) --- updated-dependencies: - dependency-name: ansible-dev-environment dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index 704da63f..200715c8 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -4,7 +4,7 @@ ansible-builder==3.1.0 ansible-compat==24.10.0 ansible-core==2.18.1 ansible-creator==25.0.0 -ansible-dev-environment==24.12.0 +ansible-dev-environment==25.1.0 ansible-lint==25.1.0 ansible-navigator==25.1.0 ansible-runner==2.4.0 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 2c005707..68bfe1b9 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -4,7 +4,7 @@ ansible-builder==3.1.0 ansible-compat==24.10.0 ansible-core==2.18.1 ansible-creator==25.0.0 -ansible-dev-environment==24.12.0 +ansible-dev-environment==25.1.0 ansible-lint==25.1.0 ansible-navigator==25.1.0 ansible-runner==2.4.0 From 7c03ca097db69f1c92e64616498a08b00fd69106 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 21 Jan 2025 19:29:18 +0000 Subject: [PATCH 13/25] Silence sonarqube code duplication false positive (#526) --- .sonarcloud.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.sonarcloud.properties b/.sonarcloud.properties index ecd1a802..da4a17fa 100644 --- a/.sonarcloud.properties +++ b/.sonarcloud.properties @@ -1,3 +1,5 @@ sonar.python.version=3.10, 3.11, 3.12, 3.13 sonar.sources=src/ sonar.tests=tests/ +# exclude from code duplication checks +sonar.cpd.exclusions=**/src/ansible_dev_tools/resources/server/creator_*.py From 5f444019a8a4d30a3ecfd9f97fa22e715cf4bcda Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sun, 26 Jan 2025 21:19:55 +0000 Subject: [PATCH 14/25] Update dependency testing (#528) Fixes a problem that prevented their update because 'lock' dependency was included when the "deps" hook did run, preventing their update. --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- .pre-commit-config.yaml | 36 +++++++++-------------------------- tools/devspaces.sh | 16 +++++++--------- tox.ini | 12 +++++------- 5 files changed, 23 insertions(+), 45 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index 200715c8..af416de6 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -142,7 +142,7 @@ text-unidecode==1.3 tinycss2==1.4.0 toml-sort==0.24.2 tomlkit==0.13.2 -tox==4.23.2 +tox==4.24.1 tox-ansible==25.1.0 types-pyyaml==6.0.12.20241230 types-requests==2.32.0.20241016 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 68bfe1b9..23be9e0b 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -60,7 +60,7 @@ rpds-py==0.22.3 ruamel-yaml==0.18.6 ruamel-yaml-clib==0.2.12 subprocess-tee==0.4.2 -tox==4.23.2 +tox==4.24.1 tox-ansible==25.1.0 tzdata==2024.2 virtualenv==20.28.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc928011..0d50fc2a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,8 +7,6 @@ ci: skip: - shellcheck # no docker support on pre-commit.ci - deps - - constraints - - lock default_language_version: # minimal version we support officially as this will impact mypy, pylint and # pip-tools in undesirable ways. @@ -65,12 +63,12 @@ repos: - id: toml-sort-fix - repo: https://github.com/tox-dev/tox-ini-fmt - rev: 1.4.1 + rev: 1.5.0 hooks: - id: tox-ini-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.2 + rev: v0.9.3 hooks: - id: ruff args: @@ -137,30 +135,14 @@ repos: # files: ^(pyproject\.toml|requirements\.txt)$ language: python language_version: "3.11" # minimal required by latest ansible-core - entry: python3 -m uv pip compile -q --all-extras --output-file=.config/constraints.txt pyproject.toml --upgrade + # do not use --all-extra because it will include the lock extra which prevents upgrade + entry: > + bash -c + "python3 -m uv pip compile --upgrade -q --extra docs --extra server --extra test --output-file=.config/constraints.txt pyproject.toml; + python3 -m uv pip compile -q --upgrade --constraint=.config/constraints.txt --output-file=.config/requirements-lock.txt pyproject.toml --strip-extras + " pass_filenames: false stages: - manual additional_dependencies: - - uv>=0.4.3 - - id: constraints - name: Check constraints files and requirements - # files: ^(pyproject\.toml|requirements\.txt)$ - language: python - language_version: "3.11" # minimal required by latest ansible-core - entry: python3 -m uv pip compile -q --all-extras --output-file=.config/constraints.txt pyproject.toml - pass_filenames: false - additional_dependencies: - - uv>=0.4.3 - - id: lock - name: Update requirements-lock.txt - alias: lock - always_run: true - entry: python3 -m uv pip compile -q --upgrade --constraint=.config/constraints.txt --output-file=.config/requirements-lock.txt pyproject.toml --strip-extras - files: ^.config\/.*requirements.*$ - language: python - language_version: "3.11" # minimal required by latest ansible-core - pass_filenames: false - stages: [manual] - additional_dependencies: - - uv>=0.4.3 + - uv>=0.5.4 diff --git a/tools/devspaces.sh b/tools/devspaces.sh index b9bc3afd..fe71ffa1 100755 --- a/tools/devspaces.sh +++ b/tools/devspaces.sh @@ -7,19 +7,17 @@ IMAGE_NAME=ansible/ansible-workspace-env-reference:test mkdir -p out dist # Ensure that we packaged the code first # shellcheck disable=SC2207 +rm -f dist/*.* +tox -e pkg +# shellcheck disable=SC2207 WHEELS=($(find dist -name '*.whl' -maxdepth 1 -execdir echo '{}' ';')) if [ ${#WHEELS[@]} -ne 1 ]; then - tox -e pkg - # shellcheck disable=SC2207 - WHEELS=($(find dist -name '*.whl' -maxdepth 1 -execdir echo '{}' ';')) - if [ ${#WHEELS[@]} -ne 1 ]; then - echo "Unable to find a single wheel file in dist/ directory: ${WHEELS[*]}" - exit 2 - fi + echo "Unable to find a single wheel file in dist/ directory: ${WHEELS[*]}" + exit 2 fi rm -f devspaces/context/*.whl -cp dist/*.whl devspaces/context -cp tools/setup-image.sh devspaces/context +ln -f dist/*.whl devspaces/context +ln -f tools/setup-image.sh devspaces/context # we force use of linux/amd64 platform because source image supports only this # platform and without it, it will fail to cross-build when task runs on arm64. diff --git a/tox.ini b/tox.ini index 554bc1b2..c136a5db 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] requires = - tox>=4.11.3 - tox-extra>=2.0.2 - tox-uv>=1.19 + tox>=4.24.1 + tox-extra>=2.1 + tox-uv>=1.20.1 env_list = py deps @@ -79,9 +79,7 @@ extras = commands_pre = commands = -pre-commit run --all-files --show-diff-on-failure --hook-stage manual deps - -pre-commit run --all-files --show-diff-on-failure --hook-stage manual lock -pre-commit autoupdate - git diff --exit-code env_dir = {toxworkdir}/lint [testenv:docs] @@ -100,8 +98,8 @@ commands = description = Enforce quality standards under {basepython} skip_install = true deps = - pre-commit - pre-commit-uv + pre-commit>=4.1 + pre-commit-uv>=4.1.4 commands = pre-commit run --show-diff-on-failure --all-files From 501b55e7207909ccb7ea6ee211deeede709172a2 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sun, 26 Jan 2025 21:52:31 +0000 Subject: [PATCH 15/25] Update dependencies (#529) --- .config/constraints.txt | 20 ++++++++++---------- .config/requirements-lock.txt | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index af416de6..1bfce7f3 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -11,13 +11,13 @@ ansible-runner==2.4.0 ansible-sign==0.1.1 asgiref==3.8.1 astroid==3.3.8 -attrs==24.2.0 +attrs==25.1.0 babel==2.16.0 beautifulsoup4==4.12.3 -bindep==2.11.0 +bindep==2.12.0 black==24.10.0 bracex==2.5.post1 -cachetools==5.5.0 +cachetools==5.5.1 cairocffi==1.7.1 cairosvg==2.7.1 certifi==2024.12.14 @@ -25,7 +25,7 @@ cffi==1.17.1 cfgv==3.4.0 chardet==5.2.0 charset-normalizer==3.4.1 -click==8.1.7 +click==8.1.8 click-help-colors==0.9.4 colorama==0.4.6 coverage==7.6.10 @@ -109,17 +109,17 @@ pre-commit==4.1.0 ptyprocess==0.7.0 pycparser==2.22 pydoclint==0.6.0 -pygments==2.18.0 +pygments==2.19.1 pylint==3.3.3 -pymdown-extensions==10.14 -pyproject-api==1.8.0 +pymdown-extensions==10.14.1 +pyproject-api==1.9.0 pytest==8.3.4 pytest-ansible==25.1.0 pytest-instafail==0.5.0 pytest-xdist==3.6.1 python-daemon==3.1.2 python-dateutil==2.9.0.post0 -python-gnupg==0.5.3 +python-gnupg==0.5.4 python-slugify==8.0.4 pyyaml==6.0.2 pyyaml-env-tag==0.1 @@ -129,9 +129,9 @@ requests==2.32.3 rfc3339-validator==0.1.4 rich==13.9.4 rpds-py==0.22.3 -ruamel-yaml==0.18.6 +ruamel-yaml==0.18.10 ruamel-yaml-clib==0.2.12 -ruff==0.9.2 +ruff==0.9.3 six==1.17.0 soupsieve==2.6 sqlparse==0.5.3 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 23be9e0b..049fd3f4 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -9,14 +9,14 @@ ansible-lint==25.1.0 ansible-navigator==25.1.0 ansible-runner==2.4.0 ansible-sign==0.1.1 -attrs==24.2.0 -bindep==2.11.0 +attrs==25.1.0 +bindep==2.12.0 black==24.10.0 bracex==2.5.post1 -cachetools==5.5.0 +cachetools==5.5.1 cffi==1.17.1 chardet==5.2.0 -click==8.1.7 +click==8.1.8 click-help-colors==0.9.4 colorama==0.4.6 cryptography==44.0.0 @@ -46,18 +46,18 @@ platformdirs==4.3.6 pluggy==1.5.0 ptyprocess==0.7.0 pycparser==2.22 -pygments==2.18.0 -pyproject-api==1.8.0 +pygments==2.19.1 +pyproject-api==1.9.0 pytest==8.3.4 pytest-ansible==25.1.0 pytest-xdist==3.6.1 python-daemon==3.1.2 -python-gnupg==0.5.3 +python-gnupg==0.5.4 pyyaml==6.0.2 referencing==0.31.1 rich==13.9.4 rpds-py==0.22.3 -ruamel-yaml==0.18.6 +ruamel-yaml==0.18.10 ruamel-yaml-clib==0.2.12 subprocess-tee==0.4.2 tox==4.24.1 From aee9c46a9c6c0043b9a6f15a1bba8edeea14a4b8 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Mon, 27 Jan 2025 09:35:04 +0000 Subject: [PATCH 16/25] Ensure zsh and oh-my-zsh are installed on both images (#530) --- final/setup.sh | 3 --- tools/ee.sh | 2 +- tools/setup-image.sh | 8 ++++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/final/setup.sh b/final/setup.sh index 78b25f3c..27e25c49 100755 --- a/final/setup.sh +++ b/final/setup.sh @@ -113,9 +113,6 @@ chsh -s "$(which zsh)" root python3 -m pip install argcomplete activate-global-python-argcomplete -# Install oh-my-zsh -sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" - # Add completions to zsh echo eval \"\$\(_MOLECULE_COMPLETE=zsh_source molecule\)\" > ~/.oh-my-zsh/custom/molecule-completions.zsh diff --git a/tools/ee.sh b/tools/ee.sh index 91f31906..9a5225a0 100755 --- a/tools/ee.sh +++ b/tools/ee.sh @@ -63,7 +63,7 @@ fi python -m build --outdir "$REPO_DIR/final/dist/" --wheel "$REPO_DIR" ansible-builder create -f execution-environment.yml --output-filename Containerfile -v3 $BUILD_CMD -f context/Containerfile context/ --tag "${TAG_BASE}" -cp tools/setup-image.sh final/ +ln -f tools/setup-image.sh final/ $BUILD_CMD -f final/Containerfile final/ --tag "${IMAGE_NAME}" # We save local image in order to import it inside the container later for c-in-c testing diff --git a/tools/setup-image.sh b/tools/setup-image.sh index a99e7eb7..ee3565db 100755 --- a/tools/setup-image.sh +++ b/tools/setup-image.sh @@ -9,3 +9,11 @@ OC_VERSION=4.15 curl -s -L "https://mirror.openshift.com/pub/openshift-v4/$(arch)/clients/ocp/stable-${OC_VERSION}/openshift-client-linux.tar.gz" | tar -C /usr/local/bin -xz --no-same-owner chmod +x /usr/local/bin/oc oc version --client=true + +# Ensure that we have a ~/.zshrc file as otherwise zsh will start its first run +# wizard which will cause the container to hang. This was seen as happening on +# ubi9 image but not on fedora one. +touch ~/.zshrc + +# Install oh-my-zsh +sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended From 68dd49763456137bdff0a1e15746189aec3bdce0 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Mon, 27 Jan 2025 11:08:33 +0000 Subject: [PATCH 17/25] Document future test isolation behavior in all ansible-dev-tools (#527) Related: https://issues.redhat.com/browse/AAP-37861 Co-authored-by: Abhinav Anand --- docs/index.md | 2 + docs/user-guide/test-isolation.md | 69 +++++++++++++++++++++++++++++++ mise.toml | 2 + mkdocs.yml | 1 + 4 files changed, 74 insertions(+) create mode 100644 docs/user-guide/test-isolation.md create mode 100644 mise.toml diff --git a/docs/index.md b/docs/index.md index ad0f9ad0..d631bfa5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -22,6 +22,8 @@ When it comes to creating automation content using Ansible, there are several pa - Simplified Ansible Automation: ansible-dev-tools focuses on crafting your automation scenarios and workflows with speed by reducing boilerplate code without dealing with the intricacies of managing and integrating different Ansible libraries. +- Promote and provide [test isolation] from system and user environments. + For those looking for an IDE-based experience, we also recommend you get familiar with the [Ansible extension for VSCode](https://marketplace.visualstudio.com/items?itemName=redhat.ansible). ## Included Packages diff --git a/docs/user-guide/test-isolation.md b/docs/user-guide/test-isolation.md new file mode 100644 index 00000000..c0d86596 --- /dev/null +++ b/docs/user-guide/test-isolation.md @@ -0,0 +1,69 @@ +# Test Isolation + +!!! note + + The test isolation behaviors described below are expected to be fully implemented + by the end of **February 2025** and will affect [ansible-lint][ansible-lint], [molecule][molecule] and [ansible-dev-environment (ade)][ansible-dev-environment] in particular. + +One very common problem in software development is reproducibility of test +results across the various environments: + +- local development, aka "works on my machine" +- CI/CD testing pipelines +- staging and production environments + +A very common source of producing divergent results across these are the +dependencies, which can be: + +- used dependencies that are not declared but happen to be installed + on a developer's machine +- different versions of the same dependency +- conflicts between dependencies + +Historically, most of ansible-dev-tools tried to address these by installing +dependencies in a controlled way and trying to avoid installing them in the +default user home directory, as this might affect other projects in +an unpredictable way. + +Starting with early 2025, all ansible-dev-tools will aim to implement the +following predictable behaviors: + +- Prefer being run from within a python virtual environment, warning the user + if this not the case. +- Dynamically modify Ansible environment to prefer installation of dependencies + such as collections, roles and python packages inside the current virtual + environment. + +## Isolated mode (virtual environment) \[default\] + +This is the recommended way to run ansible-dev-tools. If a virtual environment +is not detected, a warning will be displayed, prompting the user to use one +for better isolation. + +It should be noted that our tools will look for a `.venv` directory inside +the current directory if a virtual environment is not already active and will +try to use it if found. + +When running ansible-dev-tools inside a virtual environment, the following +things will happen: + +- Few Ansible environment variables will be automatically defined in order to + make `ansible-galaxy` install commands to install content (collections and + roles) directly inside the virtual environment. Ansible-core itself is already able to find content from inside the virtual environment and this takes priority over the other paths. +- Dependencies will automatically be installed inside the virtual environment + +## Non-isolated mode (outside virtual environments) + +When running ansible-dev-tools outside a virtual environment, our tools will +display a warning message explaining the user that the isolation mode is +disabled. + +- No alteration of ansible environment variables will be made. This is different + from the previous behaviors of ansible-lint or molecule, which tried to define + these to point to a temporary directory. + +--- + +[moleclue]: https://ansible.readthedocs.io/projects/molecule/ +[ansible-lint]: https://ansible.readthedocs.io/projects/lint/ +[ansible-dev-environment]: https://ansible.readthedocs.io/projects/dev-environment/ diff --git a/mise.toml b/mise.toml new file mode 100644 index 00000000..f35d15ca --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +"npm:prettier" = "latest" diff --git a/mkdocs.yml b/mkdocs.yml index 39465c67..b7962850 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -92,6 +92,7 @@ nav: - DevSpaces: devspaces.md - User Guide: - user-guide/index.md + - Test Isolation: user-guide/test-isolation.md - Testing: user-guide/testing.md - Building a Collection: user-guide/building-collection.md - Content Best Practices: user-guide/content-best-practices.md From 55283920bff92d9a271dcda79189103c763ac2e4 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Mon, 27 Jan 2025 14:28:09 +0000 Subject: [PATCH 18/25] Minor dependency updates (#531) --- .config/constraints.txt | 8 ++++---- .config/requirements-lock.txt | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index 1bfce7f3..bf1b8b96 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -43,7 +43,7 @@ dnspython==2.7.0 docstring-parser-fork==0.0.12 enrich==1.2.7 execnet==2.1.1 -filelock==3.16.1 +filelock==3.17.0 ghp-import==2.1.0 griffe==1.5.5 gunicorn==23.0.0 @@ -51,7 +51,7 @@ hjson==3.1.0 htmlmin2==0.1.13 identify==2.6.6 idna==3.10 -importlib-metadata==8.5.0 +importlib-metadata==8.6.1 iniconfig==2.0.0 isodate==0.7.2 isort==5.13.2 @@ -146,9 +146,9 @@ tox==4.24.1 tox-ansible==25.1.0 types-pyyaml==6.0.12.20241230 types-requests==2.32.0.20241016 -tzdata==2024.2 +tzdata==2025.1 urllib3==2.3.0 -virtualenv==20.28.0 +virtualenv==20.29.1 watchdog==6.0.0 wcmatch==10.0 webencodings==0.5.1 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 049fd3f4..6ec1e1a9 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -24,8 +24,8 @@ distlib==0.3.9 distro==1.9.0 enrich==1.2.7 execnet==2.1.1 -filelock==3.16.1 -importlib-metadata==8.5.0 +filelock==3.17.0 +importlib-metadata==8.6.1 iniconfig==2.0.0 jinja2==3.1.5 jsonschema==4.23.0 @@ -62,12 +62,13 @@ ruamel-yaml-clib==0.2.12 subprocess-tee==0.4.2 tox==4.24.1 tox-ansible==25.1.0 -tzdata==2024.2 -virtualenv==20.28.0 +tzdata==2025.1 +virtualenv==20.29.1 wcmatch==10.0 yamllint==1.35.1 zipp==3.21.0 # The following packages were excluded from the output: # resolvelib +# typing-extensions # setuptools From 162e2363a93fea17edda0a40f67c8ae26dad67c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:49:09 +0000 Subject: [PATCH 19/25] Bump ansible-compat from 24.10.0 to 25.1.0 in /.config (#532) Bumps [ansible-compat](https://github.com/ansible/ansible-compat) from 24.10.0 to 25.1.0. - [Release notes](https://github.com/ansible/ansible-compat/releases) - [Commits](https://github.com/ansible/ansible-compat/compare/v24.10.0...v25.1.0) --- updated-dependencies: - dependency-name: ansible-compat dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index bf1b8b96..a453b06a 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -1,7 +1,7 @@ # This file was autogenerated by uv via the following command: # tox run -e deps ansible-builder==3.1.0 -ansible-compat==24.10.0 +ansible-compat==25.1.0 ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==25.1.0 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 6ec1e1a9..9fb04ff7 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -1,7 +1,7 @@ # This file was autogenerated by uv via the following command: # tox run -e deps ansible-builder==3.1.0 -ansible-compat==24.10.0 +ansible-compat==25.1.0 ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==25.1.0 From cdc1c342f68af43221602dc526ace7fc8dc877a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 22:30:04 +0000 Subject: [PATCH 20/25] Bump ansible-compat from 25.1.0 to 25.1.1 in /.config (#533) Bumps [ansible-compat](https://github.com/ansible/ansible-compat) from 25.1.0 to 25.1.1. - [Release notes](https://github.com/ansible/ansible-compat/releases) - [Commits](https://github.com/ansible/ansible-compat/compare/v25.1.0...v25.1.1) --- updated-dependencies: - dependency-name: ansible-compat dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index a453b06a..dc89c130 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -1,7 +1,7 @@ # This file was autogenerated by uv via the following command: # tox run -e deps ansible-builder==3.1.0 -ansible-compat==25.1.0 +ansible-compat==25.1.1 ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==25.1.0 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 9fb04ff7..0e28bc3b 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -1,7 +1,7 @@ # This file was autogenerated by uv via the following command: # tox run -e deps ansible-builder==3.1.0 -ansible-compat==25.1.0 +ansible-compat==25.1.1 ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==25.1.0 From c42122cd60012c3a0f930b0c1a5b5520f1df8733 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 22:54:29 +0000 Subject: [PATCH 21/25] Bump molecule from 25.1.0 to 25.2.0 in /.config (#535) Bumps [molecule](https://github.com/ansible-community/molecule) from 25.1.0 to 25.2.0. - [Release notes](https://github.com/ansible-community/molecule/releases) - [Commits](https://github.com/ansible-community/molecule/compare/v25.1.0...v25.2.0) --- updated-dependencies: - dependency-name: molecule dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index dc89c130..bc380b25 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -85,7 +85,7 @@ mkdocs-minify-plugin==0.8.0 mkdocs-monorepo-plugin==1.1.0 mkdocstrings==0.27.0 mkdocstrings-python==1.13.0 -molecule==25.1.0 +molecule==25.2.0 more-itertools==10.6.0 mypy==1.14.1 mypy-extensions==1.0.0 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 0e28bc3b..96f38ab2 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -34,7 +34,7 @@ lockfile==0.12.2 markdown-it-py==3.0.0 markupsafe==3.0.2 mdurl==0.1.2 -molecule==25.1.0 +molecule==25.2.0 mypy-extensions==1.0.0 onigurumacffi==1.3.0 packaging==24.2 From 0d072684875703df5e4451ae949acf90b977cebd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 23:17:02 +0000 Subject: [PATCH 22/25] Bump ansible-lint from 25.1.0 to 25.1.1 in /.config (#534) Bumps [ansible-lint](https://github.com/ansible/ansible-lint) from 25.1.0 to 25.1.1. - [Release notes](https://github.com/ansible/ansible-lint/releases) - [Commits](https://github.com/ansible/ansible-lint/compare/v25.1.0...v25.1.1) --- updated-dependencies: - dependency-name: ansible-lint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/constraints.txt | 2 +- .config/requirements-lock.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/constraints.txt b/.config/constraints.txt index bc380b25..9b020816 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -5,7 +5,7 @@ ansible-compat==25.1.1 ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==25.1.0 -ansible-lint==25.1.0 +ansible-lint==25.1.1 ansible-navigator==25.1.0 ansible-runner==2.4.0 ansible-sign==0.1.1 diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index 96f38ab2..e2c28bdd 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -5,7 +5,7 @@ ansible-compat==25.1.1 ansible-core==2.18.1 ansible-creator==25.0.0 ansible-dev-environment==25.1.0 -ansible-lint==25.1.0 +ansible-lint==25.1.1 ansible-navigator==25.1.0 ansible-runner==2.4.0 ansible-sign==0.1.1 From 7ee4352dead6a6bebf5db8be09cf771fbb4ab8ac Mon Sep 17 00:00:00 2001 From: Sebastian Yaghoubi Date: Sun, 29 Dec 2024 17:36:22 -0800 Subject: [PATCH 23/25] feat: add shell completions for molecule Signed-off-by: Sebastian Yaghoubi --- final/setup.sh | 107 ++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/final/setup.sh b/final/setup.sh index 27e25c49..5a499176 100755 --- a/final/setup.sh +++ b/final/setup.sh @@ -2,13 +2,13 @@ # cspell: ignore onigurumacffi,makecache,euxo,libssh,overlayfs,setcaps,minrate,openh264,additionalimage,mountopt,nodev,iname,chsh,PIND set -euxo pipefail -DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) # When building for multiple-architectures in parallel using emulation # it's really easy for one/more dnf processes to timeout or mis-count # the minimum download rates. Bump both to be extremely forgiving of # an overworked host. -echo -e "\n\n# Added during image build" >> /etc/dnf/dnf.conf -echo -e "minrate=100\ntimeout=60\n" >> /etc/dnf/dnf.conf +echo -e "\n\n# Added during image build" >>/etc/dnf/dnf.conf +echo -e "minrate=100\ntimeout=60\n" >>/etc/dnf/dnf.conf # might config-manager is not available # microdnf config-manager --disable fedora-cisco-openh264 rm -f /etc/yum.repos.d/fedora-cisco-openh264.repo @@ -23,32 +23,32 @@ microdnf remove -y subscription-manager dnf-plugin-subscription-manager # ncurses: for ansible-navigator # oniguruma-devel: onigurumacffi/arm64 (does not have binary) microdnf install -q -y \ -tar \ -echo \ -podman \ -fuse-overlayfs \ -openssh-clients \ -zsh \ -util-linux-user \ -which \ -git \ -nano \ -vim \ -dumb-init \ -gcc \ -git-core \ -libssh-devel \ -python3-markupsafe \ -ncurses \ -oniguruma-devel \ -python3-bcrypt \ -python3-cffi \ -python3-devel \ -python3-pip \ -python3-pyyaml \ -python3-ruamel-yaml \ -python3-wheel \ ---exclude container-selinux + tar \ + echo \ + podman \ + fuse-overlayfs \ + openssh-clients \ + zsh \ + util-linux-user \ + which \ + git \ + nano \ + vim \ + dumb-init \ + gcc \ + git-core \ + libssh-devel \ + python3-markupsafe \ + ncurses \ + oniguruma-devel \ + python3-bcrypt \ + python3-cffi \ + python3-devel \ + python3-pip \ + python3-pyyaml \ + python3-ruamel-yaml \ + python3-wheel \ + --exclude container-selinux microdnf -q clean all ln -s /usr/bin/vim /usr/bin/vi @@ -59,15 +59,15 @@ chmod 644 /etc/containers/containers.conf # Copy & modify the defaults to provide reference if runtime changes needed. # Changes here are required for running with fuse-overlay storage inside container. sed -e 's|^#mount_program|mount_program|g' \ - -e '/additionalimage.*/a "/var/lib/shared",' \ - -e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \ - /usr/share/containers/storage.conf \ - > /etc/containers/storage.conf + -e '/additionalimage.*/a "/var/lib/shared",' \ + -e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \ + /usr/share/containers/storage.conf \ + >/etc/containers/storage.conf # Apparently, PIND on MacOS fails to build containers when drive=overlayfs but works with vfs! sed -i -e 's|^driver =.*$|driver = "vfs"|g' /etc/containers/storage.conf -DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) mkdir -p /var/lib/shared/overlay-images /var/lib/shared/overlay-layers /var/lib/shared/vfs-images /var/lib/shared/vfs-layers touch /var/lib/shared/overlay-images/images.lock /var/lib/shared/overlay-layers/layers.lock /var/lib/shared/vfs-images/images.lock /var/lib/shared/vfs-layers/layers.lock @@ -75,29 +75,28 @@ touch /var/lib/shared/overlay-images/images.lock /var/lib/shared/overlay-layers/ # In OpenShift, container will run as a random uid number and gid 0. Make sure things # are writeable by the root group. for dir in \ - /tmp/dist \ - /home/runner \ - /home/runner/.ansible \ - /home/runner/.ansible/tmp \ - /runner \ - /home/runner \ - /runner/env \ - /runner/inventory \ - /runner/project \ - /runner/artifacts ; \ - do - # shellcheck disable=SC2174 - mkdir -m 0775 -p $dir - # do not use recursive (-R) because it will fail with read-only bind mounts - find $dir -type d -exec chmod g+rwx {} \; - find $dir -type f -exec chmod g+rw {} \; - find $dir -exec chgrp root {} \; + /tmp/dist \ + /home/runner \ + /home/runner/.ansible \ + /home/runner/.ansible/tmp \ + /runner \ + /home/runner \ + /runner/env \ + /runner/inventory \ + /runner/project \ + /runner/artifacts; do + # shellcheck disable=SC2174 + mkdir -m 0775 -p $dir + # do not use recursive (-R) because it will fail with read-only bind mounts + find $dir -type d -exec chmod g+rwx {} \; + find $dir -type f -exec chmod g+rw {} \; + find $dir -exec chgrp root {} \; done for file in /home/runner/.ansible/galaxy_token /etc/passwd /etc/group; do - touch $file - chmod g+rw $file - chgrp root $file; + touch $file + chmod g+rw $file + chgrp root $file done # this must run as user root From 35e61628c506fc4a481cfcc7be6e93d7f56fe0b7 Mon Sep 17 00:00:00 2001 From: Sebastian Yaghoubi Date: Sun, 2 Feb 2025 20:16:59 -0800 Subject: [PATCH 24/25] refactor(pytest): simplify pytest and fix pytest fixture call Signed-off-by: Sebastian Yaghoubi --- tests/integration/test_zsh_completions.py | 56 ++++++++--------------- 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/tests/integration/test_zsh_completions.py b/tests/integration/test_zsh_completions.py index 75e31773..c98cf3e7 100644 --- a/tests/integration/test_zsh_completions.py +++ b/tests/integration/test_zsh_completions.py @@ -6,9 +6,9 @@ from __future__ import annotations +import shutil import subprocess -from pathlib import Path from typing import TYPE_CHECKING import pytest @@ -19,49 +19,32 @@ @pytest.fixture(scope="module") -def zsh_path() -> Path: - """Locate the ZSH executable. - - Returns: - Path to ZSH executable. - - Raises: - FileNotFoundError: If ZSH is not found in standard locations. - """ - path = next( - (Path(p) for p in ["/usr/bin/zsh", "/bin/zsh"] if Path(p).exists()), - None, - ) - if not path: - msg = "ZSH not found in standard locations" - raise FileNotFoundError(msg) - return path - - -@pytest.fixture(scope="module") -def completion_checker(zsh: Path) -> Callable[[str], tuple[bool, str]]: +def completion_checker() -> Callable[[str], tuple[bool, str]]: """Provide a function to test ZSH completion status for commands. - Args: - zsh: Path to the ZSH executable. - Returns: - A callable that takes a command name and returns a tuple of - (is_active: bool, details: str) indicating whether completions + A tuple of (is_active, details) indicating whether completions are active for that command. """ def check(command: str) -> tuple[bool, str]: - """Test if ZSH completions are active for a command. + """Check if ZSH completions are active for a given command. Args: - command: The name of the command to check completions for. + command: The command to test completions for. Returns: - A tuple of (is_active, details) where is_active is a boolean - indicating if completions are working, and details is a string - containing the test output or error message. + A tuple of (is_active, details) indicating whether completions + are active for that command. + + Raises: + FileNotFoundError: If ZSH is not found in the system's PATH. """ + zsh_path = shutil.which("zsh") + if zsh_path is None: + msg = "ZSH not found in $PATH" + raise FileNotFoundError(msg) + # Construct the test command test_command = ( "source ~/.zshrc && " @@ -72,7 +55,7 @@ def check(command: str) -> tuple[bool, str]: try: result = subprocess.run( # noqa: S603 - [zsh, "-c", test_command], + [zsh_path, "-c", test_command], capture_output=True, text=True, check=False, @@ -101,14 +84,15 @@ class TestShellCompletions: ) def test_command_completions( self, - check_completions: Callable[[str], tuple[bool, str]], command: str, + completion_checker: Callable[[str], tuple[bool, str]], # pylint: disable=redefined-outer-name ) -> None: """Verify that command completions are properly configured and active. Args: - check_completions: Fixture providing the completion testing function. command: The command to test completions for. + completion_checker: Fixture that checks completion status + """ - is_active, details = check_completions(command) + is_active, details = completion_checker(command) assert is_active, f"Completions for '{command}' are not active. Details:\n{details}" From 3c0f7110b3de9e4627f770376c42e3f926324529 Mon Sep 17 00:00:00 2001 From: Sebastian Yaghoubi Date: Sat, 8 Feb 2025 11:34:08 -0800 Subject: [PATCH 25/25] fix: skip test if shell not found --- tests/integration/test_zsh_completions.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/integration/test_zsh_completions.py b/tests/integration/test_zsh_completions.py index c98cf3e7..7151164c 100644 --- a/tests/integration/test_zsh_completions.py +++ b/tests/integration/test_zsh_completions.py @@ -36,14 +36,11 @@ def check(command: str) -> tuple[bool, str]: Returns: A tuple of (is_active, details) indicating whether completions are active for that command. - - Raises: - FileNotFoundError: If ZSH is not found in the system's PATH. """ zsh_path = shutil.which("zsh") if zsh_path is None: - msg = "ZSH not found in $PATH" - raise FileNotFoundError(msg) + msg = "ZSH not found in $PATH, skipping completion tests." + pytest.skip(msg) # Construct the test command test_command = (