Skip to content

Commit

Permalink
Increasing ansible-lint to ansible-lint 6.22.1
Browse files Browse the repository at this point in the history
Issue: AAH-2805
  • Loading branch information
traytorous committed Feb 20, 2024
1 parent d2fba33 commit d7f45a0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGES/2805.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Increasing ansible-lint to ansible-lint 6.22.1
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ packages = find:
install_requires =
ansible-core
ansible-builder>=1.2.0,<4.0
ansible-lint>=6.2.2,<=6.14.3
ansible-lint>=6.2.2,<=6.22.1
attrs>=21.4.0,<23
bleach>=3.3.0,<4
bleach-allowlist>=1.0.3,<2
Expand Down
40 changes: 16 additions & 24 deletions tests/unit/test_loader_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def test_manifest_success(_build_docs_blob, populated_collection_root):
cfg=SimpleNamespace(
run_ansible_doc=True,
run_ansible_lint=False,
check_changelog=False,
ansible_local_tmp=populated_collection_root,
check_changelog=True,
),
).load()
assert data.metadata.namespace == "my_namespace"
Expand Down Expand Up @@ -383,8 +383,8 @@ def test_filename_empty_value(_build_docs_blob, populated_collection_root):
cfg=SimpleNamespace(
run_ansible_doc=True,
run_ansible_lint=False,
check_changelog=False,
ansible_local_tmp=populated_collection_root,
check_changelog=True,
),
).load()
assert data.metadata.namespace == "my_namespace"
Expand All @@ -402,9 +402,9 @@ def test_filename_none(_build_docs_blob, populated_collection_root):
filename,
cfg=SimpleNamespace(
run_ansible_doc=True,
check_changelog=False,
run_ansible_lint=False,
ansible_local_tmp=populated_collection_root,
check_changelog=True,
),
).load()
assert data.metadata.namespace == "my_namespace"
Expand All @@ -431,8 +431,8 @@ def test_license_file(populated_collection_root):
cfg=SimpleNamespace(
run_ansible_doc=True,
run_ansible_lint=False,
check_changelog=False,
ansible_local_tmp=populated_collection_root,
check_changelog=True,
),
).load()
assert data.metadata.license_file == "LICENSE"
Expand All @@ -450,14 +450,7 @@ def test_missing_readme(populated_collection_root):


@pytest.mark.parametrize(
"changelog_path",
[
"CHANGELOG.rst",
"docs/CHANGELOG.rst",
"docs/CHANGELOG.md",
"CHANGELOG.md",
"changelogs/changelog.yaml",
],
"changelog_path", ["CHANGELOG.rst", "CHANGELOG.md", "changelogs/changelog.yaml"]
)
def test_changelog(changelog_path, tmpdir, caplog):
dirname = os.path.dirname(changelog_path)
Expand All @@ -483,14 +476,16 @@ def test_changelog_fail(_build_docs_blob, populated_collection_root, caplog):
cfg=SimpleNamespace(
run_ansible_doc=True,
run_ansible_lint=False,
check_changelog=True,
ansible_local_tmp=populated_collection_root,
check_changelog=True,
),
).load()
log.debug("TRAY: %s", str(caplog.records[0]))
print("TRAY: %s", str(caplog.records[0]))
assert (
"No changelog found. "
"Add a CHANGELOG.rst or CHANGELOG.md file in the collection root or docs/ dir, or a "
"changelogs/changelog.yaml file." in str(caplog.records[0])
"Add a CHANGELOG.rst, CHANGELOG.md, or changelogs/changelog.yaml file."
in str(caplog.records[0])
)


Expand Down Expand Up @@ -566,15 +561,13 @@ def test_ansiblelint_playbook_errors(populated_collection_root, tmp_collection_r
cfg=SimpleNamespace(
run_ansible_doc=False,
run_ansible_lint=True,
check_changelog=False,
offline_ansible_lint=True,
ansible_local_tmp=tmp_collection_root,
),
)
collection_loader._lint_collection()
shutil.rmtree(playbook_dir)

assert "All names should start with an uppercase letter" in str(caplog.records[0])
assert "All names should start with an uppercase letter" in str(caplog.records[1])


def test_ansiblelint_collection_pass(populated_collection_root, tmp_collection_root, caplog):
Expand All @@ -590,7 +583,7 @@ def test_ansiblelint_collection_pass(populated_collection_root, tmp_collection_r
)
collection_loader._lint_collection()

assert len(caplog.records) == 0
assert len(caplog.records) == 1


def test_ansiblelint_true_loader(populated_collection_root, tmp_collection_root, caplog):
Expand All @@ -600,14 +593,14 @@ def test_ansiblelint_true_loader(populated_collection_root, tmp_collection_root,
cfg=SimpleNamespace(
run_ansible_doc=False,
run_ansible_lint=True,
check_changelog=False,
offline_ansible_lint=True,
ansible_local_tmp=tmp_collection_root,
check_changelog=True,
),
)
collection_loader.load()

assert len(caplog.records) == 0
assert len(caplog.records) == 2 # Changelog error expected


def test_ansiblelint_collection_role_errors(populated_collection_root, tmp_collection_root, caplog):
Expand All @@ -629,11 +622,10 @@ def test_ansiblelint_collection_role_errors(populated_collection_root, tmp_colle
)
collection_loader._lint_collection()
shutil.rmtree(task_dir)

assert "name[casing]: All names should start with an uppercase letter." in str(
caplog.records[0]
caplog.records[1]
)
assert "jinja[spacing]: Jinja2 spacing could be improved:" in str(caplog.records[1])
assert "jinja[spacing]: Jinja2 spacing could be improved:" in str(caplog.records[2])


def test_ansiblelint_collection_meta_runtime_errors(
Expand Down

0 comments on commit d7f45a0

Please sign in to comment.