Skip to content

Commit 30aeffc

Browse files
committed
Add CI workflow to lint YAML files
On every push and pull request that affects relevant files, and periodically, run yamllint to check the YAML files of the repository for issues. The .yamllint.yml file is used to configure yamllint: https://yamllint.readthedocs.io/en/stable/configuration.html
1 parent 834af54 commit 30aeffc

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

.github/.yamllint.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# See: https://yamllint.readthedocs.io/en/stable/configuration.html
2+
# The code style defined in this file is the official standardized style to be used in all Arduino projects and should
3+
# not be modified.
4+
# Note: Rules disabled solely because they are redundant to Prettier are marked with a "Prettier" comment.
5+
6+
rules:
7+
braces:
8+
level: error
9+
forbid: non-empty
10+
min-spaces-inside: -1 # Prettier
11+
max-spaces-inside: -1 # Prettier
12+
min-spaces-inside-empty: -1 # Prettier
13+
max-spaces-inside-empty: -1 # Prettier
14+
brackets:
15+
level: error
16+
forbid: non-empty
17+
min-spaces-inside: -1 # Prettier
18+
max-spaces-inside: -1 # Prettier
19+
min-spaces-inside-empty: -1 # Prettier
20+
max-spaces-inside-empty: -1 # Prettier
21+
colons: disable # Prettier
22+
commas: disable # Prettier
23+
comments: disable # Prettier
24+
comments-indentation: disable # Prettier
25+
document-end: disable # Prettier
26+
document-start: disable
27+
empty-lines: disable # Prettier
28+
empty-values: disable
29+
hyphens: disable # Prettier
30+
indentation: disable # Prettier
31+
key-duplicates: disable # Prettier
32+
key-ordering: disable
33+
line-length:
34+
level: warning
35+
max: 120
36+
allow-non-breakable-words: true
37+
allow-non-breakable-inline-mappings: true
38+
new-line-at-end-of-file: disable # Prettier
39+
new-lines: disable # Prettier
40+
octal-values:
41+
level: warning
42+
forbid-implicit-octal: true
43+
forbid-explicit-octal: false
44+
quoted-strings: disable
45+
trailing-spaces: disable # Prettier
46+
truthy:
47+
level: error
48+
allowed-values:
49+
- "true"
50+
- "false"
51+
- "on" # Used by GitHub Actions as a workflow key.
52+
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/

.github/workflows/check-yaml.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Check YAML
2+
3+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/check-yaml.yml"
8+
- ".yamllint*"
9+
# Source: https://github.com/ikatyang/linguist-languages/blob/master/data/YAML.json (used by Prettier)
10+
- "**/.clang-format"
11+
- "**/.clang-tidy"
12+
- "**/.gemrc"
13+
- "**/glide.lock"
14+
- "**.yml"
15+
- "**.mir"
16+
- "**.reek"
17+
- "**.rviz"
18+
- "**.sublime-syntax"
19+
- "**.syntax"
20+
- "**.yaml"
21+
- "**.yaml-tmlanguage"
22+
- "**.yaml.sed"
23+
- "**.yml.mysql"
24+
pull_request:
25+
paths:
26+
- ".github/workflows/check-yaml.yml"
27+
- ".yamllint*"
28+
- "**/.clang-format"
29+
- "**/.clang-tidy"
30+
- "**/.gemrc"
31+
- "**/glide.lock"
32+
- "**.yml"
33+
- "**.mir"
34+
- "**.reek"
35+
- "**.rviz"
36+
- "**.sublime-syntax"
37+
- "**.syntax"
38+
- "**.yaml"
39+
- "**.yaml-tmlanguage"
40+
- "**.yaml.sed"
41+
- "**.yml.mysql"
42+
schedule:
43+
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to yamllint.
44+
- cron: "0 8 * * TUE"
45+
workflow_dispatch:
46+
repository_dispatch:
47+
48+
jobs:
49+
check:
50+
name: ${{ matrix.configuration.name }}
51+
runs-on: ubuntu-latest
52+
53+
strategy:
54+
fail-fast: false
55+
56+
matrix:
57+
configuration:
58+
- name: Generate problem matcher output
59+
# yamllint's "github" output type produces annotated diffs, but is not useful to humans reading the log.
60+
format: github
61+
# The other matrix job is used to set the result, so this job is configured to always pass.
62+
continue-on-error: true
63+
- name: Check formatting
64+
# yamllint's "colored" output type is most suitable for humans reading the log.
65+
format: colored
66+
continue-on-error: false
67+
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v2
71+
72+
- name: Check YAML
73+
continue-on-error: ${{ matrix.configuration.continue-on-error }}
74+
run: |
75+
yamllint \
76+
--config-file "${{ github.workspace }}/.github/.yamllint.yml" \
77+
--format ${{ matrix.configuration.format }} \
78+
.

0 commit comments

Comments
 (0)