Skip to content

Commit 6c9cf7b

Browse files
authored
Merge pull request #6 from arduino/check-workflows
Enhance CI system for checking GitHub Actions workflows
2 parents 841af8f + 0c09834 commit 6c9cf7b

File tree

4 files changed

+210
-1
lines changed

4 files changed

+210
-1
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-workflows.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Check Workflows
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/*.yaml"
8+
- ".github/workflows/*.yml"
9+
pull_request:
10+
paths:
11+
- ".github/workflows/*.yaml"
12+
- ".github/workflows/*.yml"
13+
schedule:
14+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
15+
- cron: "0 8 * * TUE"
16+
workflow_dispatch:
17+
repository_dispatch:
18+
19+
jobs:
20+
validate:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v2
26+
27+
- name: Download JSON schema for GitHub Actions workflows
28+
id: download-schema
29+
uses: carlosperate/[email protected]
30+
with:
31+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
32+
file-url: https://json.schemastore.org/github-workflow
33+
location: ${{ runner.temp }}/github-workflow-schema
34+
file-name: github-workflow.json
35+
36+
- name: Get week number for use in cache key
37+
id: get-date
38+
run: |
39+
echo "::set-output name=week-number::$(date --utc '+%V')"
40+
41+
- name: Load dependencies cache
42+
uses: actions/cache@v2
43+
with:
44+
path: ~/.npm
45+
key: ${{ runner.os }}-node-ajv-cli-${{ steps.get-date.outputs.week-number }}
46+
restore-keys: |
47+
${{ runner.os }}-node-ajv-cli-
48+
49+
- name: Install JSON schema validator
50+
run: sudo npm install --global ajv-cli
51+
52+
- name: Validate GitHub Actions workflows
53+
run: |
54+
# See: https://github.com/ajv-validator/ajv-cli#readme
55+
ajv validate \
56+
--strict=false \
57+
-s "${{ steps.download-schema.outputs.file-path }}" \
58+
-d "./.github/workflows/*.{yml,yaml}"

.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+
.

.github/workflows/spell-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: codespell-project/actions-codespell@master
2626
with:
2727
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
28-
ignore_words_list:
28+
ignore_words_list: ""
2929
builtin: clear,informal,en-GB_to_en-US
3030
check_filenames: true
3131
check_hidden: true

0 commit comments

Comments
 (0)