Skip to content

Commit

Permalink
Fix ansible-lint pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Aug 16, 2022
1 parent 603bf4d commit 1cb86cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- TOXENV: docs
- TOXENV: eco
- TOXENV: packaging
- TOXENV: validate-hook

steps:
- name: Check out src from Git
Expand Down
11 changes: 6 additions & 5 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
- id: ansible-lint
name: Ansible-lint
description: This hook runs ansible-lint.
entry: ansible-lint --force-color
entry: python3 -m ansiblelint -vv --force-color
language: python
# do not pass files to ansible-lint, see:
# https://github.com/ansible-community/ansible-lint/issues/611
pass_filenames: false
always_run: true
additional_dependencies:
# https://github.com/pre-commit/pre-commit/issues/1526
# if you want to use only the base ansible version for linting,
# replace 'community' extra with 'core' or just mention the exact
# version of Ansible you want to install as a dependency.
- .[community]
# If you want to use specific version of ansible-core or ansible, feel
# free to override `additional_dependencies` in your own hook config
# file.
- .
- ansible-core>=2.13.3
4 changes: 4 additions & 0 deletions examples/playbooks/valid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: Minimal test play
hosts: localhost
tasks: []
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ setenv =
# avoid messing pre-commit with out own constraints
PIP_CONSTRAINT=

[testenv:validate-hook]
description = Validate pre-commit hook definition
deps = pre-commit
changedir = {toxworkdir}/x
commands =
git init
git status
python3 -m pre_commit try-repo -v {toxinidir} ansible-lint

[testenv:deps]
description = Bump all test dependencies
# we reuse the lint environment
Expand Down

0 comments on commit 1cb86cf

Please sign in to comment.