Optimize linters executions from tox and pre-commit

This patch merges all the tox linters testenv into one. It also installs
the required Ansible collections with ansible-galaxy before executing
ansible-lint.

Morever, the 'end-of-file-fixer' pre-commit hook is working again and
this patch is fixing all the related issues.

Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
Change-Id: Ib823c6c65b4853e951cb001a6eed354ba2127965
(cherry picked from commit abe513cc90)
This commit is contained in:
Gael Chamoulaud (Strider) 2021-11-24 11:22:32 +01:00
parent 9def8eafbc
commit 3cb81f4300
No known key found for this signature in database
GPG Key ID: 4119D0305C651D66
61 changed files with 10 additions and 101 deletions

View File

@ -11,8 +11,6 @@ repos:
- id: check-merge-conflict - id: check-merge-conflict
- id: check-symlinks - id: check-symlinks
- id: debug-statements - id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://gitlab.com/pycqa/flake8 - repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3 rev: 3.8.3

View File

@ -173,4 +173,3 @@
defend, and hold each Contributor harmless for any liability defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability. of your accepting any such warranty or additional liability.

View File

@ -20,4 +20,3 @@ or by Ansible directly.
* Release notes: https://docs.openstack.org/releasenotes/tripleo-validations/ * Release notes: https://docs.openstack.org/releasenotes/tripleo-validations/
* Source: https://opendev.org/openstack/tripleo-validations * Source: https://opendev.org/openstack/tripleo-validations
* Bugs: https://storyboard.openstack.org/#!/project/openstack/tripleo-validations * Bugs: https://storyboard.openstack.org/#!/project/openstack/tripleo-validations

View File

@ -1,2 +1 @@
[python: **.py] [python: **.py]

View File

@ -7,4 +7,3 @@ Contents:
:glob: :glob:
modules/* modules/*

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/ceph_pools_pg_protection.py :module: library/ceph_pools_pg_protection.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/check_cpus_aligned_with_dpdk_nics.py :module: library/check_cpus_aligned_with_dpdk_nics.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/check_flavors.py :module: library/check_flavors.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/check_ironic_boot_config.py :module: library/check_ironic_boot_config.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/check_other_processes_pmd_usage.py :module: library/check_other_processes_pmd_usage.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/convert_range_to_numbers_list.py :module: library/convert_range_to_numbers_list.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/get_dpdk_nics_numa_info.py :module: library/get_dpdk_nics_numa_info.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/icmp_ping.py :module: library/icmp_ping.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/ip_range.py :module: library/ip_range.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/network_environment.py :module: library/network_environment.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/node_disks.py :module: library/node_disks.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/overcloudrc.py :module: library/overcloudrc.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/ovs_dpdk_pmd_cpus_check.py :module: library/ovs_dpdk_pmd_cpus_check.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/pacemaker.py :module: library/pacemaker.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/pmd_threads_siblings_check.py :module: library/pmd_threads_siblings_check.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/switch_vlans.py :module: library/switch_vlans.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -12,4 +12,3 @@ This module provides for the following ansible plugin:
:module: library/verify_profiles.py :module: library/verify_profiles.py
:documentation: true :documentation: true
:examples: true :examples: true

View File

@ -7,4 +7,3 @@ Contents:
:glob: :glob:
roles/* roles/*

View File

@ -4,4 +4,3 @@ ceilometerdb_size
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/ceilometerdb_size :role: roles/ceilometerdb_size

View File

@ -4,4 +4,3 @@ ceph
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/ceph :role: roles/ceph

View File

@ -4,4 +4,3 @@ check_network_gateway
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/check_network_gateway :role: roles/check_network_gateway

View File

@ -4,4 +4,3 @@ collect_flavors_and_verify_profiles
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/collect_flavors_and_verify_profiles :role: roles/collect_flavors_and_verify_profiles

View File

@ -6,4 +6,3 @@ compute_tsx
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/compute_tsx :role: roles/compute_tsx

View File

@ -4,4 +4,3 @@ controller_token
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/controller_token :role: roles/controller_token

View File

@ -4,4 +4,3 @@ controller_ulimits
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/controller_ulimits :role: roles/controller_ulimits

View File

@ -4,4 +4,3 @@ ctlplane_ip_range
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/ctlplane_ip_range :role: roles/ctlplane_ip_range

View File

@ -4,4 +4,3 @@ default_node_count
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/default_node_count :role: roles/default_node_count

View File

@ -4,4 +4,3 @@ dhcp_validations
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/dhcp_validations :role: roles/dhcp_validations

View File

@ -4,4 +4,3 @@ image_serve
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/image_serve :role: roles/image_serve

View File

@ -4,4 +4,3 @@ ironic_boot_configuration
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/ironic_boot_configuration :role: roles/ironic_boot_configuration

View File

@ -4,4 +4,3 @@ mysql_open_files_limit
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/mysql_open_files_limit :role: roles/mysql_open_files_limit

View File

@ -4,4 +4,3 @@ network_environment
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/network_environment :role: roles/network_environment

View File

@ -4,4 +4,3 @@ neutron_sanity_check
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/neutron_sanity_check :role: roles/neutron_sanity_check

View File

@ -4,4 +4,3 @@ node_disks
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/node_disks :role: roles/node_disks

View File

@ -4,4 +4,3 @@ node_health
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/node_health :role: roles/node_health

View File

@ -46,4 +46,3 @@ Full Description
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/nova_event_callback :role: roles/nova_event_callback

View File

@ -4,4 +4,3 @@ nova_status
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/nova_status :role: roles/nova_status

View File

@ -4,4 +4,3 @@ openshift_on_openstack
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/openshift_on_openstack :role: roles/openshift_on_openstack

View File

@ -4,4 +4,3 @@ openstack_endpoints
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/openstack_endpoints :role: roles/openstack_endpoints

View File

@ -4,4 +4,3 @@ overcloud_service_status
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/overcloud_service_status :role: roles/overcloud_service_status

View File

@ -4,4 +4,3 @@ ovs_dpdk_pmd
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/ovs_dpdk_pmd :role: roles/ovs_dpdk_pmd

View File

@ -4,4 +4,3 @@ pacemaker_status
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/pacemaker_status :role: roles/pacemaker_status

View File

@ -4,4 +4,3 @@ rabbitmq_limits
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/rabbitmq_limits :role: roles/rabbitmq_limits

View File

@ -4,4 +4,3 @@ repos
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/repos :role: roles/repos

View File

@ -4,4 +4,3 @@ stack_health
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/stack_health :role: roles/stack_health

View File

@ -4,4 +4,3 @@ stonith_exists
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/stonith_exists :role: roles/stonith_exists

View File

@ -4,4 +4,3 @@ switch_vlans
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/switch_vlans :role: roles/switch_vlans

View File

@ -4,4 +4,3 @@ tls_everywhere
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/tls_everywhere :role: roles/tls_everywhere

View File

@ -4,4 +4,3 @@ undercloud_debug
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/undercloud_debug :role: roles/undercloud_debug

View File

@ -4,4 +4,3 @@ undercloud_disk_space
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/undercloud_disk_space :role: roles/undercloud_disk_space

View File

@ -4,4 +4,3 @@ undercloud_heat_purge_deleted
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/undercloud_heat_purge_deleted :role: roles/undercloud_heat_purge_deleted

View File

@ -4,4 +4,3 @@ undercloud_process_count
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/undercloud_process_count :role: roles/undercloud_process_count

View File

@ -4,4 +4,3 @@ undercloud_service_status
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/undercloud_service_status :role: roles/undercloud_service_status

View File

@ -2,4 +2,4 @@
features: features:
- | - |
Adds a ceph-health check which prints a warning message if Ceph cluster Adds a ceph-health check which prints a warning message if Ceph cluster
is in HEALTH_WARN state at the end of the Overcloud deployment is in HEALTH_WARN state at the end of the Overcloud deployment

View File

@ -1 +1 @@
test ansible_connection=local ansible_host=localhost test ansible_connection=local ansible_host=localhost

48
tox.ini
View File

@ -32,7 +32,9 @@ deps =
-r {toxinidir}/requirements.txt -r {toxinidir}/requirements.txt
-r {toxinidir}/test-requirements.txt -r {toxinidir}/test-requirements.txt
-r {toxinidir}/molecule-requirements.txt -r {toxinidir}/molecule-requirements.txt
whitelist_externals = bash whitelist_externals =
bash
ansible-galaxy
[testenv:bindep] [testenv:bindep]
# Do not install any requirements. We want this to be fast and work even if # Do not install any requirements. We want this to be fast and work even if
@ -46,55 +48,21 @@ commands = bindep test
commands = oslo_debug_helper {posargs} commands = oslo_debug_helper {posargs}
[testenv:pep8] [testenv:pep8]
envdir = {toxworkdir}/linters deps =
-r {toxinidir}/requirements.txt
-r {toxinidir}/test-requirements.txt
commands = commands =
python -m pre_commit run flake8 -a python -m pre_commit run flake8 -a
[testenv:ansible-lint]
envdir = {toxworkdir}/linters
deps =
{[testenv:linters]deps}
commands =
bash -c "ANSIBLE_ROLES_PATH='{toxinidir}/roles'"
bash -c "ANSIBLE_LIBRARY='{toxinidir}/library'"
python -m pre_commit run ansible-lint -a
[testenv:yamllint]
envdir = {toxworkdir}/linters
deps = {[testenv:linters]deps}
commands =
python -m pre_commit run yamllint -a
[testenv:bashate]
envdir = {toxworkdir}/linters
deps = {[testenv:linters]deps}
commands =
python -m pre_commit run bashate -a
[testenv:whitespace]
envdir = {toxworkdir}/linters
deps = {[testenv:linters]deps}
commands =
python -m pre_commit run trailing-whitespace -a
[testenv:shebangs]
envdir = {toxworkdir}/linters
deps = {[testenv:linters]deps}
commands =
python -m pre_commit run check-executables-have-shebangs -a
[testenv:linters] [testenv:linters]
deps = deps =
-r {toxinidir}/requirements.txt -r {toxinidir}/requirements.txt
-r {toxinidir}/test-requirements.txt -r {toxinidir}/test-requirements.txt
-r {toxinidir}/molecule-requirements.txt -r {toxinidir}/molecule-requirements.txt
commands = commands =
ansible-galaxy install -fr {toxinidir}/ansible-collections-requirements.yml
python '{toxinidir}/tools/validate-files.py' . python '{toxinidir}/tools/validate-files.py' .
{[testenv:ansible-lint]commands} python -m pre_commit run -a
{[testenv:yamllint]commands}
{[testenv:bashate]commands}
{[testenv:whitespace]commands}
{[testenv:shebangs]commands}
[testenv:releasenotes] [testenv:releasenotes]
deps = -r{toxinidir}/doc/requirements.txt deps = -r{toxinidir}/doc/requirements.txt