Skip to content

Commit

Permalink
move ansible lint logic from ci to tests/lint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mafalb committed Jan 9, 2024
1 parent c6900ce commit 4ccf5bb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 17 deletions.
2 changes: 0 additions & 2 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
skip_list:
- var-naming[no-role-prefix]
- schema[meta]
- sanity[cannot-ignore]
exclude_paths:
- tests/output
warn_list: []
7 changes: 7 additions & 0 deletions .ansible-lint-6.14.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
skip_list:
- var-naming[no-role-prefix]
- sanity[cannot-ignore]
- schema[meta]
exclude_paths:
- tests/output
warn_list: []
7 changes: 7 additions & 0 deletions .ansible-lint-6.8.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
skip_list:
- var-naming[no-role-prefix]
- schema[meta]
- sanity[cannot-ignore]
exclude_paths:
- tests/output
warn_list: []
8 changes: 0 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ jobs:
- name: lint
run: |
source ~/.virtualenvs/ansible/bin/activate
if ansible-lint --version --nocolor|grep "^ansible-lint 6.8.6"
then
ANSIBLE_LINT_VERSION=686
ANSIBLE_COLLECTIONS_PATHS=../../..
elif ansible-lint --version|grep "^ansible-lint 4"
then
ANSIBLE_LINT_VERSION=4
fi
. tests/lint.sh requirements ${{ matrix.python_version }}
- name: sanity
Expand Down
6 changes: 3 additions & 3 deletions roles/virtualenv/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ virtualenv_implicit_packages:
# (~/.virtualenvs/molecule does not work) for
# setting TMPPATH environment variable for pip
#
___virtualenv: "{{ virtualenv | default('~/.virtualenvs/ansible') }}"
__virtualenv: "{{ ___virtualenv | regex_replace('^~', ansible_user_dir) }}"
___virtualenv: "{{ virtualenv | default('~/.virtualenvs/ansible') }}" # noqa: var-naming[no-role-prefix]
__virtualenv: "{{ ___virtualenv | regex_replace('^~', ansible_user_dir) }}" # noqa: var-naming[no-role-prefix]

# the path to the python interpreter
# relevant for virtualenvs that already exists
#
__virtualenv_interpreter: "{{ __virtualenv + '/bin/python' }}"
__virtualenv_interpreter: "{{ __virtualenv + '/bin/python' }}" # noqa: var-naming[no-role-prefix]

# keyed by openssl version
virtualenv_cryptography_specifier:
Expand Down
19 changes: 15 additions & 4 deletions tests/lint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -eu

set -x

# Copyright (c) 2021 Markus Falb <markus.falb@mafalb.at>
# GNU General Public License v3.0+
# see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt
Expand Down Expand Up @@ -41,14 +43,23 @@ grep -qr "no_log: false\s*$" . && exit 1
echo "yamllint..."
yamllint -s .

echo "ansible-lint..."
if test "$ANSIBLE_LINT_VERSION" == 4
ls -l .ansible-lint*

ANSIBLE_LINT_VERSION=$(NO_COLOR=1 ansible-lint --version | awk '/^ansible-lint / {print $2}')
if [[ "$ANSIBLE_LINT_VERSION" =~ ^4 ]]
then
echo "ansible-lint -c .ansible-lint-4 ${ANSIBLE_LINT_VERSION}..."
ansible-lint -v -c .ansible-lint-4
elif test "$ANSIBLE_LINT_VERSION" == 686
elif test "${ANSIBLE_LINT_VERSION}" == "6.8.6"
then
echo "ansible-lint ${ANSIBLE_LINT_VERSION}..."
ansible-lint -v --offline -c .ansible-lint-6.8.6
elif test -f .ansible-lint-${ANSIBLE_LINT_VERSION}
then
ansible-lint -v --offline
echo "ansible-lint -c .ansible-lint-${ANSIBLE_LINT_VERSION}..."
ansible-lint -v -c .ansible-lint-${ANSIBLE_LINT_VERSION}
else
echo "ansible-lint ${ANSIBLE_LINT_VERSION}..."
ansible-lint -v
fi

Expand Down

0 comments on commit 4ccf5bb

Please sign in to comment.