Skip to content

Commit 7ef3ebb

Browse files
authored
[skip changelog] Sync general formatting check workflow with template (#1380)
* [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. * Remove superfluous formatting tasks These are replaced by the `general:format-prettier` task. Even though that doesn't provide a formatting compliance check, the developer doesn't have any need for such a thing, since they will be better off to simply format, and the CI now takes the approach of formatting and then failing if it produced a diff. * [skip changelog] Bring all files into Prettier formatting style compliance Previously, Prettier was only run on the Markdown and YAML files. With the new expanded scope of Prettier coverage, the JSON files are now required to be compliant.
1 parent 4fbf7b7 commit 7ef3ebb

File tree

97 files changed

+36815
-81131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+36815
-81131
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
.vscode/
44
.vs/
55
.ionide/
6+
7+
/arduino/libraries/librariesindex/testdata/invalid.json
8+
/arduino/security/testdata/
9+
/site/

Taskfile.yml

Lines changed: 6 additions & 22 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
@@ -54,11 +54,6 @@ tasks:
5454
cmds:
5555
- mkdocs serve
5656

57-
docs:check:
58-
desc: Run documentation linting
59-
cmds:
60-
- npx {{ .PRETTIER }} --check "**/*.md"
61-
6257
docs:check-links:
6358
desc: Verifies there are no dead links in documentation
6459
cmds:
@@ -71,10 +66,11 @@ tasks:
7166
done
7267
exit $STATUS'
7368
74-
docs:format:
75-
desc: Automatically formats documentation
69+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml
70+
general:format-prettier:
71+
desc: Format all supported files with Prettier
7672
cmds:
77-
- npx {{ .PRETTIER }} --write "**/*.md"
73+
- npx prettier --write .
7874

7975
protoc:
8076
desc: Lint, format and compile protobuf definitions
@@ -149,20 +145,8 @@ tasks:
149145
- "'{{.GOLINTBIN}}' {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }}"
150146
- task: i18n:check
151147
- task: python:check
152-
- task: docs:check
153-
- task: config:check
154148
- task: protoc:check
155149

156-
config:check:
157-
desc: Check linting of configuration and supporting files
158-
cmds:
159-
- npx {{ .PRETTIER }} --check "**/*.{yml,yaml}"
160-
161-
config:format:
162-
desc: Automatically formats configuration and supporting files
163-
cmds:
164-
- npx {{ .PRETTIER }} --write "**/*.{yml,yaml}"
165-
166150
python:check:
167151
desc: Linting for Python files
168152
cmds:

0 commit comments

Comments
 (0)