Skip to content

Commit

Permalink
Merge branch 'main' into exlude-paths-trailing-slash-ansible#3524
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Jun 1, 2023
2 parents 71720a9 + 584b850 commit 86431d3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/ansiblelint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/ansiblelint/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 5 additions & 2 deletions test/test_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 86431d3

Please sign in to comment.