From ea3fbf332c08d8accc8b8efc467f1e4cdf981fab Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 10 Sep 2019 00:48:53 +0100 Subject: [PATCH] feat(yamllint): use new `yaml-files` setting * https://github.com/adrienverge/yamllint/releases/tag/v1.17.0 * https://yamllint.readthedocs.io/en/stable/configuration.html#yaml-files-extensions --- ssf/defaults.yaml | 17 ++++++++++------- ssf/files/default/.travis.yml | 20 +++----------------- ssf/files/default/.yamllint | 13 +++++++++++++ ssf/formulas.yaml | 4 ---- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/ssf/defaults.yaml b/ssf/defaults.yaml index 58a33be9..46fed992 100644 --- a/ssf/defaults.yaml +++ b/ssf/defaults.yaml @@ -15,7 +15,7 @@ ssf_node_anchors: # An alternative method could be to use: # `git describe --abbrev=0 --tags` # yamllint disable-line rule:line-length - title: 'ci(yamllint): add rule `empty-values`' + title: 'ci(yamllint): add rule `empty-values` & use new `yaml-files` setting' body: '* Automated using https://github.com/myii/ssf-formula/pull/27' github: owner: saltstack-formulas @@ -115,14 +115,17 @@ ssf_node_anchors: use_cirrus_ci: false use_tofs: false yamllint: - check_files: - default: - - . - - .yamllint - - pillar.example - additional: [] extends: default ignore: [] + yaml-files: + default: + - '*.yaml' + - '*.yml' + - '.yamllint' + additional_ssf: + - '*.example' + - 'test/**/*.sls' + additional: [] rules: # yamllint disable rule:comments-indentation # Commenting out all of the rules that haven't been implemented yet diff --git a/ssf/files/default/.travis.yml b/ssf/files/default/.travis.yml index 7243eb3d..8dde02db 100644 --- a/ssf/files/default/.travis.yml +++ b/ssf/files/default/.travis.yml @@ -58,20 +58,6 @@ script: {%- endfor %} {%- endif %} -{%- set yamllint_files = yamllint.check_files.default + yamllint.check_files.additional %} -{#- Don't need to do this in index order but maintaining consistency with `kitchen.yml` #} -{%- for index in range(0, inspec_suites_kitchen | length) %} -{%- set suite = inspec_suites_kitchen[index] %} -{%- set pillars_from_files = suite.provisioner.pillars_from_files %} -{%- for pff in pillars_from_files %} -{%- for k, v in pff.items() %} -{%- if v not in yamllint_files %} -{%- do yamllint_files.append(v) %} -{%- endif %} -{%- endfor %} -{%- endfor %} -{%- endfor %} - jobs: include: # Define the `lint` stage (runs `yamllint` and `commitlint`) @@ -81,9 +67,9 @@ jobs: before_install: skip script: # Install and run `yamllint` - - pip install --user yamllint - # yamllint disable-line rule:line-length - - yamllint -s {{ yamllint_files | join(' ') }} + # 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/ssf/files/default/.yamllint b/ssf/files/default/.yamllint index 5435ccdf..961d9a4f 100644 --- a/ssf/files/default/.yamllint +++ b/ssf/files/default/.yamllint @@ -29,6 +29,19 @@ extends: {{ yamllint.extends }} {%- endif %} {{- format_ignore(yamllint, first_ignores=['node_modules/'], width=0) }} +yaml-files: +{%- set yl_yf = yamllint.get('yaml-files') %} +{%- filter indent(2) %} +# Default settings +{{ yl_yf.default | yaml(False) }} +# SaltStack Formulas additional settings +{{ yl_yf.additional_ssf | yaml(False) }} +{%- if yl_yf.additional %} +# Formula-specific additional settings +{{ yl_yf.additional | yaml(False) }} +{%- endif %} +{%- endfilter %} + rules: {%- if yamllint.rules.get('commas') %} commas: diff --git a/ssf/formulas.yaml b/ssf/formulas.yaml index 47119a51..64be8639 100644 --- a/ssf/formulas.yaml +++ b/ssf/formulas.yaml @@ -1048,10 +1048,6 @@ ssf: - [debian , 9 , 2018.3, 2, default] # - [ubuntu , 16.04, 2017.7, 2, default] use_cirrus_ci: true - yamllint: - check_files: - additional: - - pillar.debian.example semrel_files: <<: *semrel_files_default inspec/inspec.yml: