Skip to content

Commit b5c0e41

Browse files
committed
[skip changelog] Sync general formatting check workflow with template
We have assembled a collection of reusable GitHub Actions workflows: https://github.com/arduino/tooling-project-assets These workflows will be used in the repositories of all Arduino tooling projects. The Prettier formatting tool is used in the tasks for formatting and checking the formatting of the repository's Markdown and YAML files. Prettier supports a long list of other languages. There is no reason not to take advantage of those capabilities as well, so the new workflow applies it to all supported files. Several of the tasks have been deprecated in favor of the new `general:format-prettier` task: - `docs:check` - `docs:format` - `config:check` - `config:format` These still work as before, but they now display a deprecation warning.
1 parent 4713586 commit b5c0e41

File tree

5 files changed

+246
-54
lines changed

5 files changed

+246
-54
lines changed
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-prettier-formatting-task.md
2+
name: Check Prettier Formatting
3+
4+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
paths:
8+
- ".github/workflows/check-prettier-formatting-task.ya?ml"
9+
- "Taskfile.ya?ml"
10+
- "**/.prettierignore"
11+
- "**/.prettierrc*"
12+
# CSS
13+
- "**.css"
14+
- "**.wxss"
15+
# PostCSS
16+
- "**.pcss"
17+
- "**.postcss"
18+
# Less
19+
- "**.less"
20+
# SCSS
21+
- "**.scss"
22+
# GraphQL
23+
- "**.graphqls?"
24+
- "**.gql"
25+
# handlebars
26+
- "**.handlebars"
27+
- "**.hbs"
28+
# HTML
29+
- "**.mjml"
30+
- "**.html?"
31+
- "**.html.hl"
32+
- "**.st"
33+
- "**.xht"
34+
- "**.xhtml"
35+
# Vue
36+
- "**.vue"
37+
# JavaScript
38+
- "**.flow"
39+
- "**._?jsb?"
40+
- "**.bones"
41+
- "**.cjs"
42+
- "**.es6?"
43+
- "**.frag"
44+
- "**.gs"
45+
- "**.jake"
46+
- "**.jscad"
47+
- "**.jsfl"
48+
- "**.js[ms]"
49+
- "**.[mn]js"
50+
- "**.pac"
51+
- "**.wxs"
52+
- "**.[xs]s?js"
53+
- "**.xsjslib"
54+
# JSX
55+
- "**.jsx"
56+
# TypeScript
57+
- "**.ts"
58+
# TSX
59+
- "**.tsx"
60+
# JSON
61+
- "**/.eslintrc"
62+
- "**.json"
63+
- "**.avsc"
64+
- "**.geojson"
65+
- "**.gltf"
66+
- "**.har"
67+
- "**.ice"
68+
- "**.JSON-tmLanguage"
69+
- "**.mcmeta"
70+
- "**.tfstate"
71+
- "**.topojson"
72+
- "**.webapp"
73+
- "**.webmanifest"
74+
- "**.yyp?"
75+
# JSONC
76+
- "**/.babelrc"
77+
- "**/.jscsrc"
78+
- "**/.js[hl]intrc"
79+
- "**.jsonc"
80+
- "**.sublime-*"
81+
# JSON5
82+
- "**.json5"
83+
# Markdown
84+
- "**.mdx?"
85+
- "**.markdown"
86+
- "**.mk?down"
87+
- "**.mdwn"
88+
- "**.mkdn?"
89+
- "**.ronn"
90+
- "**.workbook"
91+
# YAML
92+
- "**/.clang-format"
93+
- "**/.clang-tidy"
94+
- "**/.gemrc"
95+
- "**/glide.lock"
96+
- "**.ya?ml*"
97+
- "**.mir"
98+
- "**.reek"
99+
- "**.rviz"
100+
- "**.sublime-syntax"
101+
- "**.syntax"
102+
pull_request:
103+
paths:
104+
- ".github/workflows/check-prettier-formatting-task.ya?ml"
105+
- "Taskfile.ya?ml"
106+
- "**/.prettierignore"
107+
- "**/.prettierrc*"
108+
# CSS
109+
- "**.css"
110+
- "**.wxss"
111+
# PostCSS
112+
- "**.pcss"
113+
- "**.postcss"
114+
# Less
115+
- "**.less"
116+
# SCSS
117+
- "**.scss"
118+
# GraphQL
119+
- "**.graphqls?"
120+
- "**.gql"
121+
# handlebars
122+
- "**.handlebars"
123+
- "**.hbs"
124+
# HTML
125+
- "**.mjml"
126+
- "**.html?"
127+
- "**.html.hl"
128+
- "**.st"
129+
- "**.xht"
130+
- "**.xhtml"
131+
# Vue
132+
- "**.vue"
133+
# JavaScript
134+
- "**.flow"
135+
- "**._?jsb?"
136+
- "**.bones"
137+
- "**.cjs"
138+
- "**.es6?"
139+
- "**.frag"
140+
- "**.gs"
141+
- "**.jake"
142+
- "**.jscad"
143+
- "**.jsfl"
144+
- "**.js[ms]"
145+
- "**.[mn]js"
146+
- "**.pac"
147+
- "**.wxs"
148+
- "**.[xs]s?js"
149+
- "**.xsjslib"
150+
# JSX
151+
- "**.jsx"
152+
# TypeScript
153+
- "**.ts"
154+
# TSX
155+
- "**.tsx"
156+
# JSON
157+
- "**/.eslintrc"
158+
- "**.json"
159+
- "**.avsc"
160+
- "**.geojson"
161+
- "**.gltf"
162+
- "**.har"
163+
- "**.ice"
164+
- "**.JSON-tmLanguage"
165+
- "**.mcmeta"
166+
- "**.tfstate"
167+
- "**.topojson"
168+
- "**.webapp"
169+
- "**.webmanifest"
170+
- "**.yyp?"
171+
# JSONC
172+
- "**/.babelrc"
173+
- "**/.jscsrc"
174+
- "**/.js[hl]intrc"
175+
- "**.jsonc"
176+
- "**.sublime-*"
177+
# JSON5
178+
- "**.json5"
179+
# Markdown
180+
- "**.mdx?"
181+
- "**.markdown"
182+
- "**.mk?down"
183+
- "**.mdwn"
184+
- "**.mkdn?"
185+
- "**.ronn"
186+
- "**.workbook"
187+
# YAML
188+
- "**/.clang-format"
189+
- "**/.clang-tidy"
190+
- "**/.gemrc"
191+
- "**/glide.lock"
192+
- "**.ya?ml*"
193+
- "**.mir"
194+
- "**.reek"
195+
- "**.rviz"
196+
- "**.sublime-syntax"
197+
- "**.syntax"
198+
workflow_dispatch:
199+
repository_dispatch:
200+
201+
jobs:
202+
check:
203+
runs-on: ubuntu-latest
204+
205+
steps:
206+
- name: Checkout repository
207+
uses: actions/checkout@v2
208+
209+
- name: Install Task
210+
uses: arduino/setup-task@v1
211+
with:
212+
repo-token: ${{ secrets.GITHUB_TOKEN }}
213+
version: 3.x
214+
215+
- name: Format with Prettier
216+
run: task general:format-prettier
217+
218+
- name: Check formatting
219+
run: git diff --color --exit-code

.github/workflows/verify-formatting.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
.vscode/
44
.vs/
55
.ionide/
6+
7+
/arduino/libraries/librariesindex/testdata/invalid.json
8+
/site/

Taskfile.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tasks:
1414
# we invoke `arduino-cli` like this instead of `./arduino-cli` to remove
1515
# the `./` chars from the examples
1616
- PATH=. arduino-cli ../docs/commands
17-
- task: docs:format
17+
- task: general:format-prettier
1818

1919
docs:gen:protobuf:
2020
desc: Generate markdown contents for protobuffers
@@ -23,7 +23,7 @@ tasks:
2323
- '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,monitor.md --proto_path=rpc ./rpc/cc/arduino/cli/monitor/v1/*.proto'
2424
- '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,settings.md --proto_path=rpc ./rpc/cc/arduino/cli/settings/v1/*.proto'
2525
- '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,debug.md --proto_path=rpc ./rpc/cc/arduino/cli/debug/v1/*.proto'
26-
- task: docs:format
26+
- task: general:format-prettier
2727

2828
docs:gen:
2929
desc: Generate documentation files
@@ -58,6 +58,8 @@ tasks:
5858
desc: Run documentation linting
5959
cmds:
6060
- npx {{ .PRETTIER }} --check "**/*.md"
61+
- |
62+
echo "WARNING: this task is deprecated. Use general:format-prettier instead"
6163
6264
docs:check-links:
6365
desc: Verifies there are no dead links in documentation
@@ -73,8 +75,17 @@ tasks:
7375
7476
docs:format:
7577
desc: Automatically formats documentation
78+
deps:
79+
- task: general:format-prettier
80+
cmds:
81+
- |
82+
echo "WARNING: this task is deprecated. Use general:format-prettier instead"
83+
84+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml
85+
general:format-prettier:
86+
desc: Format all supported files with Prettier
7687
cmds:
77-
- npx {{ .PRETTIER }} --write "**/*.md"
88+
- npx prettier --write .
7889

7990
protoc:
8091
desc: Lint, format and compile protobuf definitions
@@ -157,11 +168,16 @@ tasks:
157168
desc: Check linting of configuration and supporting files
158169
cmds:
159170
- npx {{ .PRETTIER }} --check "**/*.{yml,yaml}"
171+
- |
172+
echo "WARNING: this task is deprecated. Use general:format-prettier instead"
160173
161174
config:format:
162175
desc: Automatically formats configuration and supporting files
176+
deps:
177+
- task: general:format-prettier
163178
cmds:
164-
- npx {{ .PRETTIER }} --write "**/*.{yml,yaml}"
179+
- |
180+
echo "WARNING: this task is deprecated. Use general:format-prettier instead"
165181
166182
python:check:
167183
desc: Linting for Python files

docs/CONTRIBUTING.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,10 @@ extension][prettier-vscode-extension] to automatically format as you write.
230230
Otherwise you can use the following tasks. To do so you'll need to install `npm` if not already installed. Check the
231231
[official documentation][npm-install-docs] to learn how to install `npm` for your platform.
232232

233-
To check if the files are correctly formatted run:
233+
Ensure the formatting is compliant by running the command:
234234

235235
```shell
236-
task config:check
237-
```
238-
239-
If the output tells you that some files are not formatted correctly run:
240-
241-
```shell
242-
task config:format
236+
task general:format-prettier
243237
```
244238

245239
When opening a new Pull Request, checks are automatically run to verify that configuration files are correctly
@@ -328,16 +322,10 @@ extension][prettier-vscode-extension] to automatically format as you write.
328322
Otherwise you can use the following tasks. To do so you'll need to install `npm` if not already installed. Check the
329323
[official documentation][npm-install-docs] to learn how to install `npm` for your platform.
330324

331-
To check if the files are correctly formatted run:
332-
333-
```shell
334-
task docs:check
335-
```
336-
337-
If the output tells you that some files are not formatted correctly run:
325+
Ensure the formatting is compliant by running the command:
338326

339327
```shell
340-
task docs:format
328+
task general:format-prettier
341329
```
342330

343331
When opening a new Pull Request, checks are automatically run to verify that documentation is correctly formatted. In

0 commit comments

Comments
 (0)