Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ansible-lint for openSUSE:Factory checked in at 2023-06-14 16:29:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ansible-lint (Old) and /work/SRC/openSUSE:Factory/.ansible-lint.new.15902 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ansible-lint" Wed Jun 14 16:29:45 2023 rev:30 rq:1092971 version:6.17.1 Changes: -------- --- /work/SRC/openSUSE:Factory/ansible-lint/ansible-lint.changes 2023-06-04 16:41:56.325892736 +0200 +++ /work/SRC/openSUSE:Factory/.ansible-lint.new.15902/ansible-lint.changes 2023-06-14 16:31:12.087154953 +0200 @@ -1,0 +2,25 @@ +Tue Jun 13 16:51:19 UTC 2023 - Johannes Kastl <ka...@b1-systems.de> + +- update to 6.17.1: + * Bugfixes + - Update guess install method check (#3553) @ajinkyau + - Fix exclude logic bug that can cause cause partial linting + (#3552) @ssbarnea + - Make profile information on summary line more clear (#3545) + @ssbarnea + - Avoid adding pip related messages if installation method is + different (#3551) @ajinkyau + - Avoid false positive with var-naming[no-role-prefix] (#3550) + @ssbarnea + - Make refresh_schemas handle firewalls that cut the file + transfer midway (#3546) @sverrehu + - Rename marketplace action (#3548) @ssbarnea + - Fix action name (#3536) @coaxial + - Handling of exclude paths with trailing slashs (#3527) + @hille721 + - Ensure that rules collections use Runtime in offline mode + (#3526) @ssbarnea + - Avoid using get_app() from inside the rule (#3525) @ssbarnea + - Avoid dependency error from rich (#3517) @ssbarnea + +------------------------------------------------------------------- Old: ---- ansible-lint-6.17.0.tar.gz New: ---- ansible-lint-6.17.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ansible-lint.spec ++++++ --- /var/tmp/diff_new_pack.RO1jfv/_old 2023-06-14 16:31:12.695158690 +0200 +++ /var/tmp/diff_new_pack.RO1jfv/_new 2023-06-14 16:31:12.699158714 +0200 @@ -40,7 +40,7 @@ %global lib_name ansiblelint %{?python_enable_dependency_generator} Name: ansible-lint -Version: 6.17.0 +Version: 6.17.1 Release: 0%{?dist} Summary: Best practices checker for Ansible License: MIT ++++++ ansible-lint-6.17.0.tar.gz -> ansible-lint-6.17.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/.config/requirements-docs.txt new/ansible-lint-6.17.1/.config/requirements-docs.txt --- old/ansible-lint-6.17.0/.config/requirements-docs.txt 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/.config/requirements-docs.txt 2023-06-13 14:02:48.000000000 +0200 @@ -1,2 +1,2 @@ -mkdocs-ansible[lock]>=0.1.4 +mkdocs-ansible[lock]>=0.1.6 pipdeptree>=2.4.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/.config/requirements-lock.txt new/ansible-lint-6.17.1/.config/requirements-lock.txt --- old/ansible-lint-6.17.0/.config/requirements-lock.txt 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/.config/requirements-lock.txt 2023-06-13 14:02:48.000000000 +0200 @@ -4,34 +4,39 @@ # # pip-compile --no-annotate --output-file=.config/requirements-lock.txt --resolver=backtracking --strip-extras --unsafe-package=resolvelib --unsafe-package=ruamel-yaml-clib pyproject.toml # -ansible-compat==4.1.0 +ansible-compat==4.1.2 ansible-core==2.15.0 attrs==23.1.0 black==23.3.0 bracex==2.3.post1 +certifi==2023.5.7 cffi==1.15.1 +charset-normalizer==3.1.0 click==8.1.3 -cryptography==40.0.2 -filelock==3.12.0 +cryptography==41.0.1 +filelock==3.12.1 +idna==3.4 importlib-resources==5.0.7 jinja2==3.1.2 jsonschema==4.17.3 markdown-it-py==2.2.0 -markupsafe==2.1.2 +markupsafe==2.1.3 mdurl==0.1.2 mypy-extensions==1.0.0 packaging==23.1 pathspec==0.11.1 -platformdirs==3.5.1 +platformdirs==3.5.3 pycparser==2.21 pygments==2.15.1 pyrsistent==0.19.3 pyyaml==6.0 -rich==13.3.5 +requests==2.31.0 +rich==13.4.1 ruamel-yaml==0.17.31 subprocess-tee==0.4.1 tomli==2.0.1 -typing-extensions==4.6.2 +typing-extensions==4.6.3 +urllib3==2.0.3 wcmatch==8.4.1 yamllint==1.32.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/.config/requirements.in new/ansible-lint-6.17.1/.config/requirements.in --- old/ansible-lint-6.17.0/.config/requirements.in 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/.config/requirements.in 2023-06-13 14:02:48.000000000 +0200 @@ -7,10 +7,11 @@ filelock>=3.3.0 # The Unlicense jsonschema>=4.10.0 # MIT, version needed for improved errors packaging>=21.3 # Apache-2.0,BSD-2-Clause -pathspec>=0.9.0 # Mozilla Public License 2.0 (MPL 2.0) +pathspec>=0.10.3 # Mozilla Public License 2.0 (MPL 2.0) pyyaml>=5.4.1 # MIT (centos 9 has 5.3.1) rich>=12.0.0 # MIT ruamel.yaml>=0.17.0,<0.18,!=0.17.29,!=0.17.30 # MIT, next version is planned to have breaking changes +requests>=2.31.0 # Apache-2.0 (indirect, but we want newer version for security reasons) subprocess-tee>=0.4.1 # MIT, used by ansible-compat yamllint >= 1.30.0 # GPLv3 wcmatch>=8.1.2 # MIT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/.config/requirements.txt new/ansible-lint-6.17.1/.config/requirements.txt --- old/ansible-lint-6.17.0/.config/requirements.txt 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/.config/requirements.txt 2023-06-13 14:02:48.000000000 +0200 @@ -4,7 +4,7 @@ # # pip-compile --extra=docs --extra=test --no-annotate --output-file=.config/requirements.txt --resolver=backtracking --strip-extras --unsafe-package=resolvelib --unsafe-package=ruamel-yaml-clib pyproject.toml # -ansible-compat==4.1.0 +ansible-compat==4.1.2 ansible-core==2.15.0 astroid==2.15.5 attrs==23.1.0 @@ -18,18 +18,18 @@ charset-normalizer==3.1.0 click==8.1.3 colorama==0.4.6 -coverage==7.2.6 +coverage==7.2.7 coverage-enable-subprocess==1.0 -cryptography==40.0.2 +cryptography==41.0.1 csscompressor==0.9.5 cssselect2==0.7.0 defusedxml==0.7.1 dill==0.3.6 exceptiongroup==1.1.1 execnet==1.9.0 -filelock==3.12.0 +filelock==3.12.1 ghp-import==2.1.0 -griffe==0.28.0 +griffe==0.29.0 htmlmin2==0.1.13 idna==3.4 importlib-metadata==6.6.0 @@ -51,16 +51,16 @@ mdurl==0.1.2 mergedeep==1.3.4 mkdocs==1.4.3 -mkdocs-ansible==0.1.5 +mkdocs-ansible==0.1.6 mkdocs-autorefs==0.4.1 mkdocs-gen-files==0.5.0 mkdocs-htmlproofer-plugin==0.13.1 -mkdocs-material==9.1.14 +mkdocs-material==9.1.15 mkdocs-material-extensions==1.1.1 mkdocs-minify-plugin==0.6.4 mkdocs-monorepo-plugin==1.0.5 -mkdocstrings==0.21.2 -mkdocstrings-python==1.0.0 +mkdocstrings==0.22.0 +mkdocstrings-python==1.1.0 mypy==1.3.0 mypy-extensions==1.0.0 netaddr==0.8.0 @@ -68,7 +68,7 @@ pathspec==0.11.1 pillow==9.5.0 pipdeptree==2.7.1 -platformdirs==3.5.1 +platformdirs==3.5.3 pluggy==1.0.0 ply==3.11 psutil==5.9.5 @@ -78,7 +78,7 @@ pymdown-extensions==10.0.1 pyparsing==3.0.9 pyrsistent==0.19.3 -pytest==7.3.1 +pytest==7.3.2 pytest-mock==3.10.0 pytest-plus==0.4.0 pytest-xdist==3.3.1 @@ -88,8 +88,8 @@ pyyaml-env-tag==0.1 rdflib==6.3.2 regex==2023.5.5 -requests==2.30.0 -rich==13.3.5 +requests==2.31.0 +rich==13.4.1 ruamel-yaml==0.17.31 six==1.16.0 soupsieve==2.4.1 @@ -101,7 +101,7 @@ tomlkit==0.11.8 types-jsonschema==4.17.0.8 types-pyyaml==6.0.12.10 -typing-extensions==4.5.0 +typing-extensions==4.6.2 uritools==4.0.1 urllib3==2.0.2 watchdog==3.0.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/.git_archival.txt new/ansible-lint-6.17.1/.git_archival.txt --- old/ansible-lint-6.17.0/.git_archival.txt 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/.git_archival.txt 2023-06-13 14:02:48.000000000 +0200 @@ -1,4 +1,4 @@ -node: 05aad9683d922b7d62aae12b01c739d1cfef76e8 -node-date: 2023-05-31T13:48:32+01:00 -describe-name: v6.17.0 -ref-names: tag: v6.17.0 +node: ac528c0368f94d77270828765f5131d893de5b4f +node-date: 2023-06-13T13:02:48+01:00 +describe-name: v6.17.1 +ref-names: tag: v6.17.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/.github/workflows/release.yml new/ansible-lint-6.17.1/.github/workflows/release.yml --- old/ansible-lint-6.17.0/.github/workflows/release.yml 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/.github/workflows/release.yml 2023-06-13 14:02:48.000000000 +0200 @@ -13,6 +13,8 @@ runs-on: windows-latest steps: - uses: Actions-R-Us/actions-tagger@latest + env: + GITHUB_TOKEN: "${{ github.token }}" pypi: name: Publish to PyPI registry environment: release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/.github/workflows/tox.yml new/ansible-lint-6.17.1/.github/workflows/tox.yml --- old/ansible-lint-6.17.0/.github/workflows/tox.yml 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/.github/workflows/tox.yml 2023-06-13 14:02:48.000000000 +0200 @@ -59,7 +59,7 @@ WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:GITHUB_STEP_SUMMARY # Number of expected test passes, safety measure for accidental skip of # tests. Update value if you add/remove tests. - PYTEST_REQPASS: 803 + PYTEST_REQPASS: 804 steps: - name: Activate WSL1 if: "contains(matrix.shell, 'wsl')" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/.packit.yaml new/ansible-lint-6.17.1/.packit.yaml --- old/ansible-lint-6.17.0/.packit.yaml 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/.packit.yaml 2023-06-13 14:02:48.000000000 +0200 @@ -16,10 +16,10 @@ - python3-build - python3-setuptools_scm jobs: - - job: copr_build - targets: - - fedora-rawhide-aarch64 # one on PR should be enough - trigger: pull_request + # - job: copr_build + # targets: + # - fedora-rawhide-aarch64 # one on PR should be enough + # trigger: pull_request - job: copr_build trigger: commit branch: main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/.pre-commit-config.yaml new/ansible-lint-6.17.1/.pre-commit-config.yaml --- old/ansible-lint-6.17.0/.pre-commit-config.yaml 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/.pre-commit-config.yaml 2023-06-13 14:02:48.000000000 +0200 @@ -70,7 +70,7 @@ args: [--relative, --no-progress, --no-summary] name: Spell check with cspell - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.23.0 + rev: 0.23.1 hooks: - id: check-github-workflows - repo: https://github.com/pre-commit/pre-commit-hooks.git @@ -130,7 +130,7 @@ types: [file, yaml] entry: yamllint --strict - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.0.270" + rev: "v0.0.272" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -146,7 +146,7 @@ # empty args needed in order to match mypy cli behavior args: [--strict] additional_dependencies: - - ansible-compat>=4.1.0 + - ansible-compat>=4.1.2 - black>=22.10.0 - cryptography>=39.0.1 - filelock @@ -175,7 +175,7 @@ args: - --output-format=colorized additional_dependencies: - - ansible-compat>=4.0.1 + - ansible-compat>=4.1.2 - ansible-core>=2.14.0 - black>=22.10.0 - docutils diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/README.md new/ansible-lint-6.17.1/README.md --- old/ansible-lint-6.17.0/README.md 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/README.md 2023-06-13 14:02:48.000000000 +0200 @@ -29,7 +29,7 @@ runs-on: ubuntu-latest steps: - name: Run ansible-lint - uses: ansible/ansible-lint@v6 + uses: ansible/ansible-lint-action@v6 ``` For more details, see [ansible-lint-action]. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/action.yml new/ansible-lint-6.17.1/action.yml --- old/ansible-lint-6.17.0/action.yml 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/action.yml 2023-06-13 14:02:48.000000000 +0200 @@ -1,5 +1,5 @@ --- -name: ansible-lint +name: ansible-lint-action description: Run Ansible Lint author: Ansible by Red Hat <i...@ansible.com> branding: @@ -34,6 +34,11 @@ uses: actions/setup-python@v4 with: cache: pip + # As setting cache to pip fails if there is no requirements.txt, we + # trick it to also load /dev/null to avoid failure for no requirements. + cache-dependency-path: | + **/requirements*.txt + /dev/null python-version: "3.11" - name: Install ansible-lint diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/examples/test_collection/roles/my_role/tasks/main.yml new/ansible-lint-6.17.1/examples/test_collection/roles/my_role/tasks/main.yml --- old/ansible-lint-6.17.0/examples/test_collection/roles/my_role/tasks/main.yml 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/examples/test_collection/roles/my_role/tasks/main.yml 2023-06-13 14:02:48.000000000 +0200 @@ -4,3 +4,10 @@ name: example.test_collection.my_role2 vars: my_role2_foo: something + +- name: Task 2 + # this task should NOT trigger var-naming[no-role-prefix] + vars: + foo: bar + ansible.builtin.debug: + msg: "{{ foo }}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/pyproject.toml new/ansible-lint-6.17.1/pyproject.toml --- old/ansible-lint-6.17.0/pyproject.toml 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/pyproject.toml 2023-06-13 14:02:48.000000000 +0200 @@ -223,7 +223,7 @@ xfail_strict = true [tool.ruff] -required-version = "0.0.270" +required-version = "0.0.272" ignore = [ "E501", # we use black "ERA001", # auto-removal of commented out code affects development and vscode integration diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/__main__.py new/ansible-lint-6.17.1/src/ansiblelint/__main__.py --- old/ansible-lint-6.17.0/src/ansiblelint/__main__.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/__main__.py 2023-06-13 14:02:48.000000000 +0200 @@ -134,7 +134,7 @@ if not options.offline: # pragma: no cover options.cache_dir_lock = FileLock(f"{options.cache_dir}/.lock") try: - options.cache_dir_lock.acquire(timeout=180) + options.cache_dir_lock.acquire(timeout=180) # type: ignore[attr-defined] except Timeout: # pragma: no cover _logger.error( "Timeout waiting for another instance of ansible-lint to release the lock.", @@ -252,10 +252,12 @@ console.print(profiles_as_rich()) return 0 + app = get_app(offline=None) # to be sure we use the offline value from settings + rules = RulesCollection(options.rulesdirs, profile_name=options.profile, app=app) + if options.list_rules or options.list_tags: return _do_list(rules) - app = get_app() if isinstance(options.tags, str): options.tags = options.tags.split(",") # pragma: no cover result = _get_matches(rules, options) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/app.py new/ansible-lint-6.17.1/src/ansiblelint/app.py --- old/ansible-lint-6.17.0/src/ansiblelint/app.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/app.py 2023-06-13 14:02:48.000000000 +0200 @@ -245,7 +245,7 @@ return RC.SUCCESS return RC.VIOLATIONS_FOUND - def report_summary( # pylint: disable=too-many-locals + def report_summary( # pylint: disable=too-many-locals # noqa: C901 self, summary: SummarizedResults, changed_files_count: int, @@ -311,26 +311,31 @@ # rate stars for the top 5 profiles (min would not get rating = 5 - (len(PROFILES.keys()) - passed_profile_count) if 0 < rating < 6: - stars = f", {rating}/5 star rating" + stars = f" Rating: {rating}/5 star" console_stderr.print(table) console_stderr.print() - if is_success: - msg = "[green]Passed[/] with " - else: - msg = "[red][bold]Failed[/][/] after " - - if summary.passed_profile: - msg += f"[bold]{summary.passed_profile}[/] profile" - if stars: - msg += stars + msg = "[green]Passed[/]" if is_success else "[red][bold]Failed[/][/]" msg += f": {summary.failures} failure(s), {summary.warnings} warning(s)" if summary.fixed: msg += f", and fixed {summary.fixed} issue(s)" msg += f" on {files_count} files." + # Now we add some information about required and passed profile + if self.options.profile: + msg += f" Profile '{self.options.profile}' was required" + if summary.passed_profile: + msg += f", but only '{summary.passed_profile}' profile passed." + else: + msg += "." + elif summary.passed_profile: + msg += f" Last profile that met the validation criteria was '{summary.passed_profile}'." + + if stars: + msg += stars + # on offline mode and when run under pre-commit we do not want to # check for updates. if not self.options.offline and os.environ.get("PRE_COMMIT", "0") != "1": @@ -368,9 +373,10 @@ @lru_cache -def get_app() -> App: +def get_app(*, offline: bool | None = None) -> App: """Return the application instance, caching the return value.""" - offline = default_options.offline + if offline is None: + offline = default_options.offline app = App(options=default_options) # Make linter use the cache dir from compat default_options.cache_dir = app.runtime.cache_dir diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/config.py new/ansible-lint-6.17.1/src/ansiblelint/config.py --- old/ansible-lint-6.17.0/src/ansiblelint/config.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/config.py 2023-06-13 14:02:48.000000000 +0200 @@ -10,7 +10,7 @@ import warnings from dataclasses import dataclass, field from functools import lru_cache -from importlib.metadata import PackageNotFoundError, version +from importlib.metadata import PackageNotFoundError, distribution, version from pathlib import Path from typing import TYPE_CHECKING, Any from urllib.error import HTTPError, URLError @@ -152,7 +152,7 @@ config_file: str | None = None generate_ignore: bool = False rulesdir: list[Path] = field(default_factory=list) - cache_dir_lock: FileLock | None = None + cache_dir_lock: FileLock | None = None # type: ignore[valid-type] use_default_rules: bool = False version: bool = False # display version command list_profiles: bool = False # display profiles command @@ -205,6 +205,14 @@ def guess_install_method() -> str: """Guess if pip upgrade command should be used.""" package_name = "ansible-lint" + + try: + if (distribution(package_name).read_text("INSTALLER") or "").strip() != "pip": + return "" + except PackageNotFoundError as exc: + logging.debug(exc) + return "" + pip = "" if in_venv(): _logger.debug("Found virtualenv, assuming `pip3 install` will work.") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/file_utils.py new/ansible-lint-6.17.1/src/ansiblelint/file_utils.py --- old/ansible-lint-6.17.0/src/ansiblelint/file_utils.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/file_utils.py 2023-06-13 14:02:48.000000000 +0200 @@ -538,7 +538,10 @@ def is_excluded(path_to_check: Path) -> bool: """Check if a file is exclude by current specs.""" - return any(spec.match_file(str(path_to_check)) for spec in pathspecs) + return any( + spec.match_file(pathspec.util.append_dir_sep(path_to_check)) + for spec in pathspecs + ) for path in paths: pathspecs = [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/rules/__init__.py new/ansible-lint-6.17.1/src/ansiblelint/rules/__init__.py --- old/ansible-lint-6.17.0/src/ansiblelint/rules/__init__.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/rules/__init__.py 2023-06-13 14:02:48.000000000 +0200 @@ -22,6 +22,7 @@ RuntimeErrorRule, WarningRule, ) +from ansiblelint.app import App, get_app from ansiblelint.config import PROFILES, Options, get_rule_config from ansiblelint.config import options as default_options from ansiblelint.constants import LINE_NUMBER_KEY, RULE_DOC_URL, SKIPPED_RULES_KEY @@ -376,10 +377,13 @@ profile_name: str | None = None, *, conditional: bool = True, + app: App | None = None, ) -> None: """Initialize a RulesCollection instance.""" self.options = options self.profile = [] + self.app = app or get_app(offline=True) + if profile_name: self.profile = PROFILES[profile_name] rulesdirs_str = [] if rulesdirs is None else [str(r) for r in rulesdirs] @@ -408,6 +412,7 @@ """Register a rule.""" # We skip opt-in rules which were not manually enabled. # But we do include opt-in rules when listing all rules or tags + obj._collection = self # pylint: disable=protected-access # noqa: SLF001 if any( [ not conditional, @@ -418,7 +423,6 @@ self.options.list_tags, ], ): - obj._collection = self # pylint: disable=protected-access # noqa: SLF001 self.rules.append(obj) def __iter__(self) -> Iterator[BaseRule]: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/rules/fqcn.py new/ansible-lint-6.17.1/src/ansiblelint/rules/fqcn.py --- old/ansible-lint-6.17.0/src/ansiblelint/rules/fqcn.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/rules/fqcn.py 2023-06-13 14:02:48.000000000 +0200 @@ -157,7 +157,7 @@ tag="fqcn[action]", ), ) - # TODO(ssbarnea): Remove the c.g. and c.n. exceptions from here once + # TODO(ssbarnea): Remove the c.g. and c.n. exceptions from here once # noqa: FIX002 # community team is flattening these. # https://github.com/ansible-community/community-topics/issues/147 elif not module.startswith("community.general.") or module.startswith( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/rules/schema.py new/ansible-lint-6.17.1/src/ansiblelint/rules/schema.py --- old/ansible-lint-6.17.0/src/ansiblelint/rules/schema.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/rules/schema.py 2023-06-13 14:02:48.000000000 +0200 @@ -5,7 +5,6 @@ import sys from typing import TYPE_CHECKING, Any -from ansiblelint.app import get_app from ansiblelint.errors import MatchError from ansiblelint.file_utils import Lintable from ansiblelint.rules import AnsibleLintRule @@ -49,10 +48,6 @@ }, } -FIELD_CHECKS = { - "become_method": get_app().runtime.plugins.become.keys(), # pylint: disable=no-member -} - class ValidateSchemaRule(AnsibleLintRule): """Perform JSON Schema Validation for known lintable kinds.""" @@ -80,8 +75,21 @@ "schema[tasks]": "", "schema[vars]": "", } + _field_checks: dict[str, list[str]] = {} - become_method_msg = f"'become_method' must be one of the currently installed plugins: {', '.join(FIELD_CHECKS['become_method'])}" + @property + def field_checks(self) -> dict[str, list[str]]: + """Lazy property for returning field checks.""" + if not self._collection: + msg = "Rule was not registered to a RuleCollection." + raise RuntimeError(msg) + if not self._field_checks: + self._field_checks = { + "become_method": sorted( + self._collection.app.runtime.plugins.become.keys(), + ), + } + return self._field_checks def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]: """Return matches found for a specific playbook.""" @@ -89,20 +97,31 @@ if not data or file.kind not in ("tasks", "handlers", "playbook"): return results # check at play level - for key, value in FIELD_CHECKS.items(): + results.extend(self._get_field_matches(file=file, data=data)) + return results + + def _get_field_matches( + self, + file: Lintable, + data: dict[str, Any], + ) -> list[MatchError]: + """Retrieve all matches related to fields for the given data block.""" + results = [] + for key, values in self.field_checks.items(): if key in data: - plugin_value = data.get(key, None) - if not has_jinja(plugin_value) and plugin_value not in value: + plugin_value = data[key] + if not has_jinja(plugin_value) and plugin_value not in values: + msg = f"'{key}' must be one of the currently available values: {', '.join(values)}" results.append( MatchError( - message=self.become_method_msg, - lintable=file or Lintable(""), + message=msg, + lineno=data.get("__line__", 1), + lintable=file, rule=ValidateSchemaRule(), details=ValidateSchemaRule.description, tag=f"schema[{file.kind}]", ), ) - return results def matchtask( @@ -110,34 +129,24 @@ task: Task, file: Lintable | None = None, ) -> bool | str | MatchError | list[MatchError]: - result = [] - for key, value in FIELD_CHECKS.items(): - if key in task.raw_task: - plugin_value = task.raw_task.get(key, None) - if not has_jinja(plugin_value) and plugin_value not in value: - result.append( - MatchError( - message=self.become_method_msg, - lintable=file or Lintable(""), - rule=ValidateSchemaRule(), - details=ValidateSchemaRule.description, - tag=f"schema[{file.kind}]", # type: ignore[union-attr] - ), - ) + results = [] + if not file: + file = Lintable("", kind="tasks") + results.extend(self._get_field_matches(file=file, data=task.raw_task)) for key in pre_checks["task"]: if key in task.raw_task: msg = pre_checks["task"][key]["msg"] tag = pre_checks["task"][key]["tag"] - result.append( + results.append( MatchError( message=msg, - lintable=file or Lintable(""), + lintable=file, rule=ValidateSchemaRule(), details=ValidateSchemaRule.description, tag=f"schema[{tag}]", ), ) - return result + return results def matchyaml(self, file: Lintable) -> list[MatchError]: """Return JSON validation errors found as a list of MatchError(s).""" @@ -308,8 +317,8 @@ "examples/playbooks/rule-schema-become-method-fail.yml", "playbook", [ - "'become_method' must be one of the currently installed plugins", - "'become_method' must be one of the currently installed plugins", + "'become_method' must be one of the currently available values", + "'become_method' must be one of the currently available values", ], id="playbook2", ), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/rules/var_naming.py new/ansible-lint-6.17.1/src/ansiblelint/rules/var_naming.py --- old/ansible-lint-6.17.0/src/ansiblelint/rules/var_naming.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/rules/var_naming.py 2023-06-13 14:02:48.000000000 +0200 @@ -219,6 +219,8 @@ if isinstance(action, dict): role_fqcn = action.get("name", "") prefix = role_fqcn.split("/" if "/" in role_fqcn else ".")[-1] + else: + prefix = "" for key in our_vars: match_error = self.get_var_naming_matcherror(key, prefix=prefix) if match_error: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/runner.py new/ansible-lint-6.17.1/src/ansiblelint/runner.py --- old/ansible-lint-6.17.0/src/ansiblelint/runner.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/runner.py 2023-06-13 14:02:48.000000000 +0200 @@ -229,6 +229,7 @@ for data in return_list: matches.extend(data) + matches = self._filter_excluded_matches(matches) # -- phase 2 --- if not matches: # do our processing only when ansible syntax check passed in order @@ -256,17 +257,18 @@ self.checked_files.update(self.lintables) # remove any matches made inside excluded files - matches = list( - filter( - lambda match: not self.is_excluded(match.lintable) - and hasattr(match, "lintable") - and match.tag not in match.lintable.line_skips[match.lineno], - matches, - ), - ) + matches = self._filter_excluded_matches(matches) return sorted(set(matches)) + def _filter_excluded_matches(self, matches: list[MatchError]) -> list[MatchError]: + return [ + match + for match in matches + if not self.is_excluded(match.lintable) + and match.tag not in match.lintable.line_skips[match.lineno] + ] + def _emit_matches(self, files: list[Lintable]) -> Generator[MatchError, None, None]: visited: set[Lintable] = set() while visited != self.lintables: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/schemas/__main__.py new/ansible-lint-6.17.1/src/ansiblelint/schemas/__main__.py --- old/ansible-lint-6.17.0/src/ansiblelint/schemas/__main__.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/schemas/__main__.py 2023-06-13 14:02:48.000000000 +0200 @@ -7,6 +7,7 @@ import urllib.request from collections import defaultdict from functools import cache +from http.client import HTTPException from pathlib import Path from typing import Any from urllib.request import Request @@ -88,7 +89,7 @@ # unload possibly loaded schema if kind in _schema_cache: # pragma: no cover del _schema_cache[kind] - except (ConnectionError, OSError) as exc: + except (ConnectionError, OSError, HTTPException) as exc: if ( isinstance(exc, urllib.error.HTTPError) and getattr(exc, "code", None) == 304 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/schemas/__store__.json new/ansible-lint-6.17.1/src/ansiblelint/schemas/__store__.json --- old/ansible-lint-6.17.0/src/ansiblelint/schemas/__store__.json 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/schemas/__store__.json 2023-06-13 14:02:48.000000000 +0200 @@ -48,7 +48,7 @@ "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/role-arg-spec.json" }, "rulebook": { - "etag": "d71f098603772f31faf00d8a63620d3bb3932959b77721579cbc9bf1e3e1919e", + "etag": "f0bbd0ecd656b2298febccc6da0ecf4a7bd239cc112b9de8292c1f50bad612e0", "url": "https://raw.githubusercontent.com/ansible/ansible-rulebook/main/ansible_rulebook/schema/ruleset_schema.json" }, "tasks": { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/schemas/rulebook.json new/ansible-lint-6.17.1/src/ansiblelint/schemas/rulebook.json --- old/ansible-lint-6.17.0/src/ansiblelint/schemas/rulebook.json 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/schemas/rulebook.json 2023-06-13 14:02:48.000000000 +0200 @@ -28,6 +28,11 @@ "name": { "type": "string" }, + "execution_strategy": { + "type": "string", + "enum": ["sequential", "parallel"], + "default": "sequential" + }, "sources": { "type": "array", "items": { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/src/ansiblelint/utils.py new/ansible-lint-6.17.1/src/ansiblelint/utils.py --- old/ansible-lint-6.17.0/src/ansiblelint/utils.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/src/ansiblelint/utils.py 2023-06-13 14:02:48.000000000 +0200 @@ -318,7 +318,7 @@ variables, **dict(kwargs, fail_on_undefined=fail_on_undefined), ) - # Hack to skip the following exception when using to_json filter on a variable. + # Hack to skip the following exception when using to_json filter on a variable. # noqa: FIX004 # I guess the filter doesn't like empty vars... except (AnsibleError, ValueError, RepresenterError): # templating failed, so just keep value as is. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/test/schemas/package-lock.json new/ansible-lint-6.17.1/test/schemas/package-lock.json --- old/ansible-lint-6.17.0/test/schemas/package-lock.json 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/test/schemas/package-lock.json 2023-06-13 14:02:48.000000000 +0200 @@ -16,11 +16,11 @@ "@types/js-yaml": "^4.0.5", "@types/minimatch": "^5.1.2", "@types/mocha": "^10.0.1", - "@types/node": "^20.2.4", + "@types/node": "^20.3.0", "chai": "^4.3.7", "minimatch": "^9.0.1", "mocha": "^10.2.0", - "typescript": "^5.0.4" + "typescript": "^5.1.3" } }, "node_modules/@cspotcode/source-map-support": { @@ -101,9 +101,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.4.tgz", - "integrity": "sha512-ni5f8Xlf4PwnT/Z3f0HURc3ZSw8UyrqMqmM3L5ysa7VjHu8c3FOmIo1nKCcLrV/OAmtf3N4kFna/aJqxsfEtnA==" + "version": "20.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.0.tgz", + "integrity": "sha512-cumHmIAf6On83X7yP+LrsEyUOf/YlociZelmpRYaGFydoaPdxdt80MAbu6vWerQT2COCp2nPvHdsbD7tHn/YlQ==" }, "node_modules/@vscode/l10n": { "version": "0.0.13", @@ -1179,15 +1179,15 @@ } }, "node_modules/typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", + "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=12.20" + "node": ">=14.17" } }, "node_modules/uri-js": { @@ -1404,9 +1404,9 @@ "dev": true }, "@types/node": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.4.tgz", - "integrity": "sha512-ni5f8Xlf4PwnT/Z3f0HURc3ZSw8UyrqMqmM3L5ysa7VjHu8c3FOmIo1nKCcLrV/OAmtf3N4kFna/aJqxsfEtnA==" + "version": "20.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.0.tgz", + "integrity": "sha512-cumHmIAf6On83X7yP+LrsEyUOf/YlociZelmpRYaGFydoaPdxdt80MAbu6vWerQT2COCp2nPvHdsbD7tHn/YlQ==" }, "@vscode/l10n": { "version": "0.0.13", @@ -2169,9 +2169,9 @@ "dev": true }, "typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==" + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", + "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==" }, "uri-js": { "version": "4.4.1", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/test/schemas/package.json new/ansible-lint-6.17.1/test/schemas/package.json --- old/ansible-lint-6.17.0/test/schemas/package.json 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/test/schemas/package.json 2023-06-13 14:02:48.000000000 +0200 @@ -16,11 +16,11 @@ "@types/js-yaml": "^4.0.5", "@types/minimatch": "^5.1.2", "@types/mocha": "^10.0.1", - "@types/node": "^20.2.4", + "@types/node": "^20.3.0", "chai": "^4.3.7", "minimatch": "^9.0.1", "mocha": "^10.2.0", - "typescript": "^5.0.4" + "typescript": "^5.1.3" }, "directories": { "test": "./src" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/test/test_profiles.py new/ansible-lint-6.17.1/test/test_profiles.py --- old/ansible-lint-6.17.0/test/test_profiles.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/test/test_profiles.py 2023-06-13 14:02:48.000000000 +0200 @@ -43,5 +43,8 @@ # [WARNING]: Ansible is being run in a world writable directory # WSL2 has "WSL2" in platform name but WSL1 has "microsoft": platform_name = platform.platform().lower() - if all(word not in platform_name for word in ["wsl", "microsoft"]): - assert not err, platform_name + err_lines = [line for line in err.splitlines() if "SyntaxWarning:" not in line] + if all(word not in platform_name for word in ["wsl", "microsoft"]) and err_lines: + assert ( + not err_lines + ), f"Unexpected stderr output found while running on {platform_name} platform:\n{err_lines}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-lint-6.17.0/test/test_utils.py new/ansible-lint-6.17.1/test/test_utils.py --- old/ansible-lint-6.17.0/test/test_utils.py 2023-05-31 14:48:32.000000000 +0200 +++ new/ansible-lint-6.17.1/test/test_utils.py 2023-06-13 14:02:48.000000000 +0200 @@ -320,7 +320,11 @@ assert utils.is_playbook("examples/playbooks/always-run-success.yml") -def test_auto_detect_exclude(tmp_path: Path) -> None: +@pytest.mark.parametrize( + "exclude", + (pytest.param("foo", id="1"), pytest.param("foo/", id="2")), +) +def test_auto_detect_exclude(tmp_path: Path, exclude: str) -> None: """Verify that exclude option can be used to narrow down detection.""" with cwd(tmp_path): subprocess.check_output( @@ -334,9 +338,16 @@ (tmp_path / "bar").mkdir() (tmp_path / "foo" / "playbook.yml").touch() (tmp_path / "bar" / "playbook.yml").touch() - options = cli.get_config(["--exclude", "foo"]) + + options = cli.get_config(["--exclude", exclude]) options.cwd = tmp_path + result = utils.get_lintables(options) + assert result == [Lintable("bar/playbook.yml", kind="playbook")] + # now we also test with .gitignore exclude approach + (tmp_path / ".gitignore").write_text(f".gitignore\n{exclude}\n") + options = cli.get_config([]) + options.cwd = tmp_path result = utils.get_lintables(options) assert result == [Lintable("bar/playbook.yml", kind="playbook")]