Skip to content

Commit be66375

Browse files
committed
test(pre-commit): switch to using pre-commit's built-in file filtering
* only run `yamllint` when relevant files have changed * avoids having to exclude files/dirs not tracked by Git e.g. .kitchen/, .bundle/ etc. * avoids a `yamllint` bug whereby pillar files under `test/` were not checked due to a conflicting `ignore` entry
1 parent 1ca9120 commit be66375

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

.pre-commit-config.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,33 @@ repos:
4545
hooks:
4646
- id: yamllint
4747
name: Check YAML syntax with yamllint
48-
args: [--strict, '.']
49-
always_run: true
50-
pass_filenames: false
48+
args: [--strict]
49+
types: [file]
50+
# Files to include
51+
# 1. Obvious YAML files
52+
# 2. `pillar.example` and similar files
53+
# 3. SLS files under directory `test/` which are pillar files
54+
# Files to exclude
55+
# 1. SLS files under directory `test/` which are state files
56+
# 2. `kitchen.vagrant.yml`, which contains Embedded Ruby (ERB) template syntax
57+
# 3. YAML files heavily reliant on Jinja
58+
files: |
59+
(?x)^(
60+
.*\.yaml|
61+
.*\.yml|
62+
\.salt-lint|
63+
\.yamllint|
64+
.*\.example|
65+
test/.*\.sls
66+
)$
67+
exclude: |
68+
(?x)^(
69+
kitchen.vagrant.yml|
70+
test/.*/states/.*\.sls|
71+
salt/osfamilymap.yaml|
72+
salt/osmap.yaml|
73+
salt/osfingermap.yaml
74+
)$
5175
- repo: https://github.com/warpnet/salt-lint
5276
rev: v0.9.2
5377
hooks:

.yamllint

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,6 @@
44
# Extend the `default` configuration provided by `yamllint`
55
extends: 'default'
66

7-
# Files to ignore completely
8-
# 1. All YAML files under directory `.bundle/`, introduced if gems are installed locally
9-
# 2. All YAML files under directory `.cache/`, introduced during the CI run
10-
# 3. All YAML files under directory `.git/`
11-
# 4. All YAML files under directory `node_modules/`, introduced during the CI run
12-
# 5. Any SLS files under directory `test/`, which are actually state files
13-
# 6. Any YAML files under directory `.kitchen/`, introduced during local testing
14-
# 7. `kitchen.vagrant.yml`, which contains Embedded Ruby (ERB) template syntax
15-
# 8. All YAML files heavily reliant on Jinja; these can be tackled in a subsequent PR
16-
ignore: |
17-
.bundle/
18-
.cache/
19-
.git/
20-
node_modules/
21-
test/**/states/**/*.sls
22-
.kitchen/
23-
kitchen.vagrant.yml
24-
salt/osfamilymap.yaml
25-
salt/osmap.yaml
26-
salt/osfingermap.yaml
27-
28-
yaml-files:
29-
# Default settings
30-
- '*.yaml'
31-
- '*.yml'
32-
- .salt-lint
33-
- .yamllint
34-
# SaltStack Formulas additional settings
35-
- '*.example'
36-
- test/**/*.sls
37-
387
rules:
398
empty-values:
409
forbid-in-block-mappings: true

0 commit comments

Comments
 (0)