Skip to content

Commit 82067d6

Browse files
committed
Add CI workflow to lint YAML files
On every push and pull request that affects relevant files, 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 35a7bfa commit 82067d6

File tree

6 files changed

+231
-1
lines changed

6 files changed

+231
-1
lines changed

.github/workflows/check-yaml-task.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-yaml-task.md
2+
name: Check YAML
3+
4+
env:
5+
# See: https://github.com/actions/setup-python/tree/v2#available-versions-of-python
6+
PYTHON_VERSION: "3.9"
7+
8+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
9+
on:
10+
push:
11+
paths:
12+
- ".yamllint*"
13+
- "poetry.lock"
14+
- "pyproject.toml"
15+
# Source: https://github.com/ikatyang/linguist-languages/blob/master/data/YAML.json (used by Prettier)
16+
- "**/.clang-format"
17+
- "**/.clang-tidy"
18+
- "**/.gemrc"
19+
- "**/glide.lock"
20+
- "**.ya?ml*"
21+
- "**.mir"
22+
- "**.reek"
23+
- "**.rviz"
24+
- "**.sublime-syntax"
25+
- "**.syntax"
26+
pull_request:
27+
paths:
28+
- ".yamllint*"
29+
- "poetry.lock"
30+
- "pyproject.toml"
31+
# Source: https://github.com/ikatyang/linguist-languages/blob/master/data/YAML.json (used by Prettier)
32+
- "**/.clang-format"
33+
- "**/.clang-tidy"
34+
- "**/.gemrc"
35+
- "**/glide.lock"
36+
- "**.ya?ml*"
37+
- "**.mir"
38+
- "**.reek"
39+
- "**.rviz"
40+
- "**.sublime-syntax"
41+
- "**.syntax"
42+
workflow_dispatch:
43+
repository_dispatch:
44+
45+
jobs:
46+
check:
47+
name: ${{ matrix.configuration.name }}
48+
runs-on: ubuntu-latest
49+
50+
strategy:
51+
fail-fast: false
52+
53+
matrix:
54+
configuration:
55+
- name: Generate problem matcher output
56+
# yamllint's "github" output type produces annotated diffs, but is not useful to humans reading the log.
57+
format: github
58+
# The other matrix job is used to set the result, so this job is configured to always pass.
59+
continue-on-error: true
60+
- name: Check formatting
61+
# yamllint's "colored" output type is most suitable for humans reading the log.
62+
format: colored
63+
continue-on-error: false
64+
65+
steps:
66+
- name: Checkout repository
67+
uses: actions/checkout@v3
68+
69+
- name: Install Python
70+
uses: actions/setup-python@v3
71+
with:
72+
python-version: ${{ env.PYTHON_VERSION }}
73+
74+
- name: Install Poetry
75+
run: pip install poetry
76+
77+
- name: Install Task
78+
uses: arduino/setup-task@v1
79+
with:
80+
repo-token: ${{ secrets.GITHUB_TOKEN }}
81+
version: 3.x
82+
83+
- name: Check YAML
84+
continue-on-error: ${{ matrix.configuration.continue-on-error }}
85+
run: task yaml:lint YAMLLINT_FORMAT=${{ matrix.configuration.format }}

.yamllint.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-yaml/.yamllint.yml
2+
# See: https://yamllint.readthedocs.io/en/stable/configuration.html
3+
# The code style defined in this file is the official standardized style to be used in all Arduino tooling projects and
4+
# should not be modified.
5+
# Note: Rules disabled solely because they are redundant to Prettier are marked with a "Prettier" comment.
6+
7+
rules:
8+
braces:
9+
level: error
10+
forbid: non-empty
11+
min-spaces-inside: -1 # Prettier
12+
max-spaces-inside: -1 # Prettier
13+
min-spaces-inside-empty: -1 # Prettier
14+
max-spaces-inside-empty: -1 # Prettier
15+
brackets:
16+
level: error
17+
forbid: non-empty
18+
min-spaces-inside: -1 # Prettier
19+
max-spaces-inside: -1 # Prettier
20+
min-spaces-inside-empty: -1 # Prettier
21+
max-spaces-inside-empty: -1 # Prettier
22+
colons: disable # Prettier
23+
commas: disable # Prettier
24+
comments: disable # Prettier
25+
comments-indentation: disable # Prettier
26+
document-end: disable # Prettier
27+
document-start: disable
28+
empty-lines: disable # Prettier
29+
empty-values: disable
30+
hyphens: disable # Prettier
31+
indentation: disable # Prettier
32+
key-duplicates: disable # Prettier
33+
key-ordering: disable
34+
line-length:
35+
level: warning
36+
max: 120
37+
allow-non-breakable-words: true
38+
allow-non-breakable-inline-mappings: true
39+
new-line-at-end-of-file: disable # Prettier
40+
new-lines: disable # Prettier
41+
octal-values:
42+
level: warning
43+
forbid-implicit-octal: true
44+
forbid-explicit-octal: false
45+
quoted-strings: disable
46+
trailing-spaces: disable # Prettier
47+
truthy:
48+
level: error
49+
allowed-values:
50+
- "true"
51+
- "false"
52+
- "on" # Used by GitHub Actions as a workflow key.
53+
check-keys: true
54+
55+
yaml-files:
56+
# Source: https://github.com/ikatyang/linguist-languages/blob/master/data/YAML.json (used by Prettier)
57+
- ".clang-format"
58+
- ".clang-tidy"
59+
- ".gemrc"
60+
- ".yamllint"
61+
- "glide.lock"
62+
- "*.yml"
63+
- "*.mir"
64+
- "*.reek"
65+
- "*.rviz"
66+
- "*.sublime-syntax"
67+
- "*.syntax"
68+
- "*.yaml"
69+
- "*.yaml-tmlanguage"
70+
- "*.yaml.sed"
71+
- "*.yml.mysql"
72+
73+
ignore: |
74+
/.git/
75+
__pycache__/
76+
node_modules/

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
[![Check Markdown status](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-markdown-task.yml)
1313
[![Check License status](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-license.yml)
1414
[![Check Go Dependencies status](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-go-dependencies-task.yml/badge.svg)](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-go-dependencies-task.yml)
15+
[![Check YAML status](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-yaml-task.yml/badge.svg)](https://github.com/arduino/libraries-repository-engine/actions/workflows/check-yaml-task.yml)
1516

1617
This is the tool that generates [the Arduino Library Manager index](http://downloads.arduino.cc/libraries/library_index.json).
1718

Taskfile.yml

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ tasks:
2727
- task: markdown:lint
2828
- task: markdown:check-links
2929
- task: python:lint
30+
- task: yaml:lint
3031

3132
format:
3233
desc: Correct the formatting of the project's files
@@ -260,3 +261,11 @@ tasks:
260261
- task: poetry:install-deps
261262
cmds:
262263
- poetry run codespell --write-changes
264+
265+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-yaml-task/Taskfile.yml
266+
yaml:lint:
267+
desc: Check for problems with YAML files
268+
deps:
269+
- task: poetry:install-deps
270+
cmds:
271+
- poetry run yamllint --format {{default "colored" .YAMLLINT_FORMAT}} .

poetry.lock

+59-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ flake8 = "^4.0.1"
1717
invoke = "^1.6.0"
1818
pep8-naming = "^0.12.1"
1919
pytest = "^7.0.1"
20+
yamllint = "^1.26.3"
2021

2122
[build-system]
2223
requires = ["poetry-core>=1.0.0"]

0 commit comments

Comments
 (0)