From 3d48b1b6bb3341391f334e0eaac306adec58800d Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 10 Sep 2019 05:57:00 +0100 Subject: [PATCH] ci(yamllint): add rule `empty-values` & use new `yaml-files` setting * Semi-automated using https://github.com/myii/ssf-formula/pull/27 * Fix errors shown below: ```bash nginx-formula$ yamllint -s . ./pillar.example 146:56 error empty value in block mapping (empty-values) 147:76 error empty value in block mapping (empty-values) 148:59 error empty value in block mapping (empty-values) 150:22 error empty value in block mapping (empty-values) 151:39 error empty value in block mapping (empty-values) 152:39 error empty value in block mapping (empty-values) 153:39 error empty value in block mapping (empty-values) ``` --- .travis.yml | 6 +++--- .yamllint | 14 ++++++++++++++ pillar.example | 14 +++++++------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef2a868..1934f02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,9 +56,9 @@ jobs: before_install: skip script: # Install and run `yamllint` - - pip install --user yamllint - # yamllint disable-line rule:line-length - - yamllint -s . .yamllint pillar.example test/salt/default/pillar/nginx.sls + # Need at least `v1.17.0` for the `yaml-files` setting + - pip install --user yamllint>=1.17.0 + - yamllint -s . # Install and run `commitlint` - npm install @commitlint/config-conventional -D - npm install @commitlint/travis-cli -D diff --git a/.yamllint b/.yamllint index 3a90f57..a8509bc 100644 --- a/.yamllint +++ b/.yamllint @@ -6,10 +6,24 @@ extends: default # Files to ignore completely # 1. All YAML files under directory `node_modules/`, introduced during the Travis run +# 2. Any SLS files under directory `test/`, which are actually state files ignore: | node_modules/ + test/**/states/**/*.sls + +yaml-files: + # Default settings + - '*.yaml' + - '*.yml' + - .yamllint + # SaltStack Formulas additional settings + - '*.example' + - test/**/*.sls rules: + empty-values: + forbid-in-block-mappings: true + forbid-in-flow-mappings: true line-length: # Increase from default of `80` # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) diff --git a/pillar.example b/pillar.example index 33db1aa..7f97230 100644 --- a/pillar.example +++ b/pillar.example @@ -143,14 +143,14 @@ nginx: - hostname2.example.com:1000 upstream stream_backend: least_conn: '' - 'server backend1.example.com:12345 weight=5': - 'server backend2.example.com:12345 max_fails=2 fail_timeout=30s': - 'server backend3.example.com:12345 max_conns=3': + 'server backend1.example.com:12345 weight=5': ~ + 'server backend2.example.com:12345 max_fails=2 fail_timeout=30s': ~ + 'server backend3.example.com:12345 max_conns=3': ~ upstream dns_servers: - least_conn: - 'server 192.168.136.130:53': - 'server 192.168.136.131:53': - 'server 192.168.136.132:53': + least_conn: '' + 'server 192.168.136.130:53': ~ + 'server 192.168.136.131:53': ~ + 'server 192.168.136.132:53': ~ server: listen: 1000 proxy_pass: lb-1000