Skip to content

Commit af33fba

Browse files
committed
Use yamllint configuration file to define the file names to check
Because there are multiple popular file types that use YAML markup, but not the standardized file extension, I previously was using `find` to discover all the files to check with yamllint. However, it turns out that this can be defined in the yamllint configuration file. In addition to being less prone to breakage and providing a more minimal workflow, this also means that contributors who run yamllint locally will get the same results as the CI.
1 parent b8a1304 commit af33fba

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

.github/workflows/check-yaml.yml

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,42 +59,20 @@ jobs:
5959
# yamllint's "github" output type produces annotated diffs, but is not useful to humans reading the log.
6060
format: github
6161
# The other matrix job is used to set the result, so this job is configured to always pass.
62-
fail-command: "true"
62+
continue-on-error: true
6363
- name: Check formatting
6464
# yamllint's "colored" output type is most suitable for humans reading the log.
6565
format: colored
66-
fail-command: "false"
66+
continue-on-error: false
6767

6868
steps:
6969
- name: Checkout repository
7070
uses: actions/checkout@v2
7171

7272
- name: Check YAML
7373
# yamllint's "colored" output type is useful for humans reading the log.
74+
continue-on-error: ${{ matrix.configuration.continue-on-error }}
7475
run: |
75-
find . \
76-
-path './.git' -prune -or \
77-
\( \
78-
\( \
79-
-name '.clang-format' -or \
80-
-name '.clang-tidy' -or \
81-
-name '.gemrc' -or \
82-
-name '*.yml' -or \
83-
-name '*.mir' -or \
84-
-name '*.reek' -or \
85-
-name '*.rviz' -or \
86-
-name '*.sublime-syntax' -or \
87-
-name '*.syntax' -or \
88-
-name '*.yaml' -or \
89-
-name '*.yaml-tmlanguage' -or \
90-
-name '*.yaml.sed' -or \
91-
-name '*.yaml.mysql' \
92-
\) \
93-
-and -type f \
94-
\) \
95-
-exec \
96-
yamllint \
97-
--format ${{ matrix.configuration.format }} \
98-
'{}' + \
99-
|| \
100-
${{ matrix.configuration.fail-command }}
76+
yamllint \
77+
--format ${{ matrix.configuration.format }} \
78+
.

.yamllint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,24 @@ rules:
5050
- "false"
5151
- "on" # Used by GitHub Actions as a workflow key.
5252
check-keys: true
53+
54+
yaml-files:
55+
# Source: https://github.com/ikatyang/linguist-languages/blob/master/data/YAML.json (used by Prettier)
56+
- ".clang-format"
57+
- ".clang-tidy"
58+
- ".gemrc"
59+
- ".yamllint"
60+
- "glide.lock"
61+
- "*.yml"
62+
- "*.mir"
63+
- "*.reek"
64+
- "*.rviz"
65+
- "*.sublime-syntax"
66+
- "*.syntax"
67+
- "*.yaml"
68+
- "*.yaml-tmlanguage"
69+
- "*.yaml.sed"
70+
- "*.yml.mysql"
71+
72+
ignore: |
73+
/.git/

0 commit comments

Comments
 (0)