cisagov / skeleton-generic

A generic skeleton project for quickly getting a new cisagov project started.
Creative Commons Zero v1.0 Universal
13 stars 11 forks source link

Update the `ansible-lint` hook for `pre-commit` #96

Closed mcdonnnj closed 2 years ago

mcdonnnj commented 2 years ago

πŸ—£ Description

This pull request updates the version of ansible-lint used in our pre-commit configuration to the latest release.

πŸ’­ Motivation and context

This change is necessary because ansible-lint has loosely pinned the rich package, and in the v11 release a breaking change was introduced. This was reported in https://github.com/ansible-community/ansible-lint/issues/1795, and the 5.3.2 release included updates for compatibility with rich v11.

The breaking change resulted in workflows that didn't have cached pre-commit environments failing linting at the ansible-lint hook:

Ansible-lint.............................................................Failed
- hook id: ansible-lint
- exit code: 1

Traceback (most recent call last):
  File "/home/runner/.cache/pre-commit/repo40qn8w4j/py_env-python3/bin/ansible-lint", line 8, in <module>
    sys.exit(_run_cli_entrypoint())
  File "/home/runner/.cache/pre-commit/repo40qn8w4j/py_env-python3/lib/python3.9/site-packages/ansiblelint/__main__.py", line 299, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
  File "/home/runner/.cache/pre-commit/repo40qn8w4j/py_env-python3/lib/python3.9/site-packages/ansiblelint/__main__.py", line 211, in main
    from ansiblelint.generate_docs import rules_as_rich, rules_as_rst, rules_as_str
  File "/home/runner/.cache/pre-commit/repo40qn8w4j/py_env-python3/lib/python3.9/site-packages/ansiblelint/generate_docs.py", line 6, in <module>
    from rich.console import render_group
ImportError: cannot import name 'render_group' from 'rich.console' (/home/runner/.cache/pre-commit/repo40qn8w4j/py_env-python3/lib/python3.9/site-packages/rich/console.py)

πŸ§ͺ Testing

Automated tests pass. I tested it locally and the freshly built ansible-lint environment ran without issue.

βœ… Pre-approval checklist

mcdonnnj commented 2 years ago

Closing this in favor of #97 which includes this change.

felddy commented 2 years ago

I'm late. But still appreciate the quick fix. πŸ’ͺ