diff --git a/.packit.yaml b/.packit.yaml index 206b6b15c0..546b7fe49c 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -16,10 +16,10 @@ srpm_build_deps: - 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 --git a/src/ansiblelint/__main__.py b/src/ansiblelint/__main__.py index 7636882f4e..769b21d3d3 100755 --- a/src/ansiblelint/__main__.py +++ b/src/ansiblelint/__main__.py @@ -252,10 +252,12 @@ def main(argv: list[str] | None = None) -> int: 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 --git a/src/ansiblelint/app.py b/src/ansiblelint/app.py index 2222f61e89..4a7af6ced4 100644 --- a/src/ansiblelint/app.py +++ b/src/ansiblelint/app.py @@ -368,9 +368,10 @@ def _sanitize_list_options(tag_list: list[str]) -> list[str]: @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 --git a/src/ansiblelint/rules/__init__.py b/src/ansiblelint/rules/__init__.py index d7861329f6..f243e4672a 100644 --- a/src/ansiblelint/rules/__init__.py +++ b/src/ansiblelint/rules/__init__.py @@ -382,7 +382,7 @@ def __init__( """Initialize a RulesCollection instance.""" self.options = options self.profile = [] - self.app = app or get_app() + self.app = app or get_app(offline=True) if profile_name: self.profile = PROFILES[profile_name] diff --git a/test/test_profiles.py b/test/test_profiles.py index 17c66c28c2..e149d65067 100644 --- a/test/test_profiles.py +++ b/test/test_profiles.py @@ -43,5 +43,8 @@ def test_profile_listing(capfd: CaptureFixture[str]) -> None: # [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}"