From 3534fcdce7e7caac3a347170d05574243b5d900f Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Thu, 20 Jul 2023 19:14:04 -0300 Subject: [PATCH] ansible-lint: Use the same command line as galaxy-importer Currently, there is a hard coded timeout in galaxy-importer that prevents larger collections to execute the ansible-lint step [1]. This patch modifies the calls to ansible-lint on development tools and upstream CI to use the same arguments as galaxy-importer and disables the execution of the ansible-lint step for the Ansible's sanity test. Requested ansible-lint version for tools is also updated, as a more recent one is required. This change will not allow development using an environment using Python 2.7, due to newer ansible-lint requirements. Roles and modules tests against target nodes using Python 2.7 is still possible. [1]: https://github.com/ansible/galaxy-importer/pull/231 --- .github/workflows/lint.yml | 2 +- .pre-commit-config.yaml | 16 +++++++++++++--- requirements-dev.txt | 2 +- tests/sanity/galaxy-importer.cfg | 2 +- utils/lint_check.sh | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d5f2261a49..a669ddecef 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,7 @@ jobs: pip install "ansible-core >=2.15,<2.16" ansible-lint utils/build-galaxy-release.sh -ki cd .galaxy-build - ansible-lint + ansible-lint --profile production --exclude tests/integration/ --exclude tests/unit/ --parseable --nocolor yamllint: name: Verify yamllint diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3c1417ae9f..00d5b2fadc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,25 @@ --- repos: - repo: https://github.com/ansible/ansible-lint.git - rev: v6.6.1 + rev: v6.17.2 hooks: - id: ansible-lint always_run: false pass_filenames: true files: \.(yaml|yml)$ exclude: /env[^/]*.(yaml|yml)$ - entry: | - env ANSIBLE_LIBRARY=./plugins/modules ANSIBLE_MODULE_UTILS=./plugins/module_utils ANSIBLE_DOC_FRAGMENT_PLUGINS=./plugins/doc_fragments ansible-lint + entry: >- + env + ANSIBLE_LIBRARY=./plugins/modules + ANSIBLE_MODULE_UTILS=./plugins/module_utils + ANSIBLE_DOC_FRAGMENT_PLUGINS=./plugins/doc_fragments + ansible-lint + --offline + --profile production + --exclude tests/integration/ + --exclude tests/unit/ + --parseable + --nocolor - repo: https://github.com/adrienverge/yamllint.git rev: v1.28.0 hooks: diff --git a/requirements-dev.txt b/requirements-dev.txt index f7fa4419e0..750f7f0497 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,4 +7,4 @@ pylint==2.14.4 wrapt == 1.14.0 pydocstyle==6.0.0 yamllint==1.28.0 -ansible-lint==6.6.1 +ansible-lint diff --git a/tests/sanity/galaxy-importer.cfg b/tests/sanity/galaxy-importer.cfg index fae700c20b..772aa56aac 100644 --- a/tests/sanity/galaxy-importer.cfg +++ b/tests/sanity/galaxy-importer.cfg @@ -1,5 +1,5 @@ [galaxy-importer] RUN_ANSIBLE_TEST = True -RUN_ANSIBLE_LINT = True +RUN_ANSIBLE_LINT = False ANSIBLE_TEST_LOCAL_IMAGE = True LOCAL_IMAGE_DOCKER = True diff --git a/utils/lint_check.sh b/utils/lint_check.sh index 61c3b0b91e..25d4f8878c 100755 --- a/utils/lint_check.sh +++ b/utils/lint_check.sh @@ -26,7 +26,7 @@ playbook_dirs=( "tests" "playbooks" ) -ansible-lint --force-color "${playbook_dirs[@]}" +ansible-lint --offline --profile production --exclude tests/integration/ --exclude tests/unit/ --parseable --force-color "${playbook_dirs[@]}" echo -e "${INFO}Running 'ansible-doc-test'...${RST}" python "${topdir}/ansible-doc-test" -v roles plugins