From 4ccf5bb7f436368b90cc0ad85a0d7b512bd9fbc5 Mon Sep 17 00:00:00 2001 From: Markus Falb Date: Tue, 9 Jan 2024 01:57:48 +0100 Subject: [PATCH] move ansible lint logic from ci to tests/lint.sh --- .ansible-lint | 2 -- .ansible-lint-6.14.3 | 7 +++++++ .ansible-lint-6.8.1 | 7 +++++++ .github/workflows/CI.yml | 8 -------- roles/virtualenv/vars/main.yml | 6 +++--- tests/lint.sh | 19 +++++++++++++++---- 6 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 .ansible-lint-6.14.3 create mode 100644 .ansible-lint-6.8.1 diff --git a/.ansible-lint b/.ansible-lint index d7d8836..6a1725c 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,7 +1,5 @@ skip_list: - var-naming[no-role-prefix] - - schema[meta] - - sanity[cannot-ignore] exclude_paths: - tests/output warn_list: [] diff --git a/.ansible-lint-6.14.3 b/.ansible-lint-6.14.3 new file mode 100644 index 0000000..87ecf61 --- /dev/null +++ b/.ansible-lint-6.14.3 @@ -0,0 +1,7 @@ +skip_list: + - var-naming[no-role-prefix] + - sanity[cannot-ignore] + - schema[meta] +exclude_paths: + - tests/output +warn_list: [] diff --git a/.ansible-lint-6.8.1 b/.ansible-lint-6.8.1 new file mode 100644 index 0000000..d7d8836 --- /dev/null +++ b/.ansible-lint-6.8.1 @@ -0,0 +1,7 @@ +skip_list: + - var-naming[no-role-prefix] + - schema[meta] + - sanity[cannot-ignore] +exclude_paths: + - tests/output +warn_list: [] diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9f4f5e5..0b109c7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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 diff --git a/roles/virtualenv/vars/main.yml b/roles/virtualenv/vars/main.yml index 96e6604..08f1be2 100644 --- a/roles/virtualenv/vars/main.yml +++ b/roles/virtualenv/vars/main.yml @@ -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: diff --git a/tests/lint.sh b/tests/lint.sh index f6d9e86..d05346a 100644 --- a/tests/lint.sh +++ b/tests/lint.sh @@ -1,5 +1,7 @@ #!/bin/bash -eu +set -x + # Copyright (c) 2021 Markus Falb # GNU General Public License v3.0+ # see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt @@ -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