From 70d244349192858a5743c9ff413072e7a54d6e34 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 1 Jun 2023 14:17:58 +0100 Subject: [PATCH 1/3] Ensure that rules collections use Runtime in offline mode (#3526) --- src/ansiblelint/__main__.py | 4 +++- src/ansiblelint/app.py | 5 +++-- src/ansiblelint/rules/__init__.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) 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] From 6e300583640d55d2567cf43d9c0f8bae0ba54e75 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 1 Jun 2023 14:53:37 +0100 Subject: [PATCH 2/3] Temporary disable rpm building on pull-requests (#3528) --- .packit.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 From 584b8501bb02eecc4905dfecdef4369c1d045f57 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 1 Jun 2023 15:13:02 +0100 Subject: [PATCH 3/3] Avoid failing test on SyntaxWarning (#3529) --- test/test_profiles.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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}"