Skip to content

Commit

Permalink
feat(yamllint): use new yaml-files setting
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Sep 10, 2019
1 parent e25c1ef commit ea3fbf3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
17 changes: 10 additions & 7 deletions ssf/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 3 additions & 17 deletions ssf/files/default/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions ssf/files/default/.yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions ssf/formulas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ea3fbf3

Please sign in to comment.