Harden yaml linting on modified files

Allows us to slowly adopt yamllint by having to fix only the files
we would be touching. Once we lower the amount of differences we
can switch it to run on all files.

In addition to having a more consistent code-style this solves
*recurring* bugs like duplicate dictionary keys, like the one
fixes in this change. Only few weeks ago we had to fix a similar bug.

Change-Id: I2ef275700b420a0f700613568e43576079cd4d03
This commit is contained in:
Sorin Sbarnea 2018-11-14 16:56:01 +00:00
parent a554bed7e0
commit baf8392455
7 changed files with 45 additions and 10 deletions

View File

@ -1,5 +1,25 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.4.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.12.1
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
# uncommend once a new yamllint release is made:
# entry: yamllint --strict
- repo: https://github.com/openstack-dev/bashate.git
rev: 0.6.0
hooks:

6
.yamllint Normal file
View File

@ -0,0 +1,6 @@
---
extends: default
rules:
line-length:
max: 180

View File

@ -1,3 +1,4 @@
---
os_username: "{{ lookup('env','OS_USERNAME') }}"
os_password: "{{ lookup('env','OS_PASSWORD') }}"
os_tenant_name: "{{ lookup('env','OS_TENANT_NAME') }}"
@ -39,9 +40,8 @@ mtu_interface:
undercloud_local_mtu: "{{ mtu }}"
overcloud_neutron_global_physnet_mtu: "{{ mtu }}"
run_tripleo_validations: True
run_tripleo_validations: true
# Browbeat settings
cloud_name: rdocloud
elastic_host: browbeat.test.com
grafana_host: browbeat.test.com

View File

@ -1,3 +1,4 @@
---
# note the EC2MetadataIp: value should match the value in
# /home/stack/undercloud.conf for key local_ip
# # EC2MetadataIp: "local_ip"
@ -19,4 +20,4 @@ parameter_defaults:
ControlPlaneSubnetCidr: "24"
ControlPlaneDefaultRoute: 192.0.2.1
EC2MetadataIp: 192.0.2.1
DnsServers: ["192.168.23.1", "8.8.8.8",]
DnsServers: ["192.168.23.1", "8.8.8.8"]

View File

@ -4,7 +4,6 @@ floating_ip_cidr: "{{ undercloud_network_cidr }}"
public_net_pool_start: "{{ floating_ip_cidr|nthhost(100) }}"
public_net_pool_end: "{{ floating_ip_cidr|nthhost(120) }}"
public_net_gateway: "{{ floating_ip_cidr|nthhost(1) }}"
tempest_log_file: 'tempest_output.log'
test_white_regex: "{{ test_regex|default('smoke') }}"
test_black_regex: []
check_tempest_bugs: false
@ -22,7 +21,7 @@ tempest_config: true
tempest_overcloud: true
run_tempest: false
post_tempest: true
tempest_format: packages # venv or packages or container
tempest_format: packages # venv or packages or container
tempest_container_registry: >-
{% if (undercloud_enable_tempest is defined) and undercloud_enable_tempest|bool -%}
{{ local_docker_registry_host }}:8787/{{ docker_registry_namespace }}
@ -60,14 +59,20 @@ tempest_plugins: >-
[ "python-keystone-tests", "python-neutron-tests" ]
{%- endif -%}
tempest_extra_config: {}# A dict containing values which needs to be overridden in tempest.conf
tempest_extra_config: {} # A dict containing values which needs to be overridden in tempest.conf
skip_file_src: "skip_file.j2"
skip_file: skip_file
tempest_until_failure: false
tempest_exit_on_failure: true
# Set tempest_version for different release
# For forked-tempest, we have branched name in synced with releases.
tempest_version_dict: { 'newton': 'newton', 'ocata': '16.1.0', 'pike': '17.1.0', 'queens': '17.2.0', 'rocky': '19.0.0', 'master': 'master'}
tempest_version_dict:
newton: 'newton'
ocata: '16.1.0'
pike: '17.1.0'
queens: '17.2.0'
rocky: '19.0.0'
master: 'master'
tempest_version: "{{ tempest_version_dict[release] }}"
tempest_conf_version_dict: {'ocata': '1.1.3', 'pike': '1.1.3', 'queens': '1.1.4', 'rocky': 'master', 'master': 'master'}
tempest_conf_version: "{{ tempest_conf_version_dict[release] }}"

View File

@ -9,7 +9,7 @@ sudo: false
addons:
apt:
packages:
- python-pip
- python-pip
install:
# Install ansible
@ -26,4 +26,4 @@ script:
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@ -50,7 +50,10 @@ commands = bash -c ci-scripts/releasenotes_tox.sh
[testenv:linters]
commands =
{[testenv:bashate]commands}
# check only modified files:
python -m pre_commit run --source HEAD^ --origin HEAD
# in the future we may want to check entire repository:
# python -m pre_commit run yamllint --all-files
{[testenv:pep8]commands}
{[testenv:ansible-lint]commands}
{[testenv:validate-jinja]commands}