Skip to content

Commit 3d1d8ba

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 63f7175 commit 3d1d8ba

File tree

5 files changed

+260
-0
lines changed

5 files changed

+260
-0
lines changed

Diff for: .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@v2
68+
69+
- name: Install Python
70+
uses: actions/setup-python@v2
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 }}

Diff for: .yamllint.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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/

Diff for: Taskfile.yml

+14
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ tasks:
4545
cmds:
4646
- npx prettier --write .
4747

48+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
49+
poetry:install-deps:
50+
desc: Install dependencies managed by Poetry
51+
cmds:
52+
- poetry install --no-root
53+
4854
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-shell-task/Taskfile.yml
4955
shell:check:
5056
desc: Check for problems with shell scripts
@@ -112,3 +118,11 @@ tasks:
112118
exit 1
113119
fi
114120
- shfmt -w .
121+
122+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-yaml-task/Taskfile.yml
123+
yaml:lint:
124+
desc: Check for problems with YAML files
125+
deps:
126+
- task: poetry:install-deps
127+
cmds:
128+
- poetry run yamllint --format {{default "colored" .YAMLLINT_FORMAT}} .

Diff for: poetry.lock

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

Diff for: pyproject.toml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[tool.poetry]
2+
name = "arduinoOTA"
3+
version = "0.0.0"
4+
description = ""
5+
authors = []
6+
7+
[tool.poetry.dependencies]
8+
python = "^3.9"
9+
10+
[tool.poetry.dev-dependencies]
11+
yamllint = "^1.26.3"
12+
13+
[build-system]
14+
requires = ["poetry-core>=1.0.0"]
15+
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)