Skip to content

Commit dfe553f

Browse files
authored
Merge pull request #118 from per1234/prettier
Add infrastructure to check for Prettier formatting compliance
2 parents 87d316e + d48ac55 commit dfe553f

File tree

8 files changed

+350
-50
lines changed

8 files changed

+350
-50
lines changed
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
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+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
8+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
9+
on:
10+
create:
11+
push:
12+
paths:
13+
- ".github/workflows/check-prettier-formatting-task.ya?ml"
14+
- "Taskfile.ya?ml"
15+
- "**/.prettierignore"
16+
- "**/.prettierrc*"
17+
# CSS
18+
- "**.css"
19+
- "**.wxss"
20+
# PostCSS
21+
- "**.pcss"
22+
- "**.postcss"
23+
# Less
24+
- "**.less"
25+
# SCSS
26+
- "**.scss"
27+
# GraphQL
28+
- "**.graphqls?"
29+
- "**.gql"
30+
# handlebars
31+
- "**.handlebars"
32+
- "**.hbs"
33+
# HTML
34+
- "**.mjml"
35+
- "**.html?"
36+
- "**.html.hl"
37+
- "**.st"
38+
- "**.xht"
39+
- "**.xhtml"
40+
# Vue
41+
- "**.vue"
42+
# JavaScript
43+
- "**.flow"
44+
- "**._?jsb?"
45+
- "**.bones"
46+
- "**.cjs"
47+
- "**.es6?"
48+
- "**.frag"
49+
- "**.gs"
50+
- "**.jake"
51+
- "**.jscad"
52+
- "**.jsfl"
53+
- "**.js[ms]"
54+
- "**.[mn]js"
55+
- "**.pac"
56+
- "**.wxs"
57+
- "**.[xs]s?js"
58+
- "**.xsjslib"
59+
# JSX
60+
- "**.jsx"
61+
# TypeScript
62+
- "**.ts"
63+
# TSX
64+
- "**.tsx"
65+
# JSON
66+
- "**/.eslintrc"
67+
- "**.json"
68+
- "**.avsc"
69+
- "**.geojson"
70+
- "**.gltf"
71+
- "**.har"
72+
- "**.ice"
73+
- "**.JSON-tmLanguage"
74+
- "**.mcmeta"
75+
- "**.tfstate"
76+
- "**.topojson"
77+
- "**.webapp"
78+
- "**.webmanifest"
79+
- "**.yyp?"
80+
# JSONC
81+
- "**/.babelrc"
82+
- "**/.jscsrc"
83+
- "**/.js[hl]intrc"
84+
- "**.jsonc"
85+
- "**.sublime-*"
86+
# JSON5
87+
- "**.json5"
88+
# Markdown
89+
- "**.mdx?"
90+
- "**.markdown"
91+
- "**.mk?down"
92+
- "**.mdwn"
93+
- "**.mkdn?"
94+
- "**.ronn"
95+
- "**.workbook"
96+
# YAML
97+
- "**/.clang-format"
98+
- "**/.clang-tidy"
99+
- "**/.gemrc"
100+
- "**/glide.lock"
101+
- "**.ya?ml*"
102+
- "**.mir"
103+
- "**.reek"
104+
- "**.rviz"
105+
- "**.sublime-syntax"
106+
- "**.syntax"
107+
pull_request:
108+
paths:
109+
- ".github/workflows/check-prettier-formatting-task.ya?ml"
110+
- "Taskfile.ya?ml"
111+
- "**/.prettierignore"
112+
- "**/.prettierrc*"
113+
# CSS
114+
- "**.css"
115+
- "**.wxss"
116+
# PostCSS
117+
- "**.pcss"
118+
- "**.postcss"
119+
# Less
120+
- "**.less"
121+
# SCSS
122+
- "**.scss"
123+
# GraphQL
124+
- "**.graphqls?"
125+
- "**.gql"
126+
# handlebars
127+
- "**.handlebars"
128+
- "**.hbs"
129+
# HTML
130+
- "**.mjml"
131+
- "**.html?"
132+
- "**.html.hl"
133+
- "**.st"
134+
- "**.xht"
135+
- "**.xhtml"
136+
# Vue
137+
- "**.vue"
138+
# JavaScript
139+
- "**.flow"
140+
- "**._?jsb?"
141+
- "**.bones"
142+
- "**.cjs"
143+
- "**.es6?"
144+
- "**.frag"
145+
- "**.gs"
146+
- "**.jake"
147+
- "**.jscad"
148+
- "**.jsfl"
149+
- "**.js[ms]"
150+
- "**.[mn]js"
151+
- "**.pac"
152+
- "**.wxs"
153+
- "**.[xs]s?js"
154+
- "**.xsjslib"
155+
# JSX
156+
- "**.jsx"
157+
# TypeScript
158+
- "**.ts"
159+
# TSX
160+
- "**.tsx"
161+
# JSON
162+
- "**/.eslintrc"
163+
- "**.json"
164+
- "**.avsc"
165+
- "**.geojson"
166+
- "**.gltf"
167+
- "**.har"
168+
- "**.ice"
169+
- "**.JSON-tmLanguage"
170+
- "**.mcmeta"
171+
- "**.tfstate"
172+
- "**.topojson"
173+
- "**.webapp"
174+
- "**.webmanifest"
175+
- "**.yyp?"
176+
# JSONC
177+
- "**/.babelrc"
178+
- "**/.jscsrc"
179+
- "**/.js[hl]intrc"
180+
- "**.jsonc"
181+
- "**.sublime-*"
182+
# JSON5
183+
- "**.json5"
184+
# Markdown
185+
- "**.mdx?"
186+
- "**.markdown"
187+
- "**.mk?down"
188+
- "**.mdwn"
189+
- "**.mkdn?"
190+
- "**.ronn"
191+
- "**.workbook"
192+
# YAML
193+
- "**/.clang-format"
194+
- "**/.clang-tidy"
195+
- "**/.gemrc"
196+
- "**/glide.lock"
197+
- "**.ya?ml*"
198+
- "**.mir"
199+
- "**.reek"
200+
- "**.rviz"
201+
- "**.sublime-syntax"
202+
- "**.syntax"
203+
schedule:
204+
# Run periodically to catch breakage caused by external changes.
205+
- cron: "0 4 * * WED"
206+
workflow_dispatch:
207+
repository_dispatch:
208+
209+
jobs:
210+
run-determination:
211+
runs-on: ubuntu-latest
212+
outputs:
213+
result: ${{ steps.determination.outputs.result }}
214+
steps:
215+
- name: Determine if the rest of the workflow should run
216+
id: determination
217+
run: |
218+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
219+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
220+
if [[
221+
"${{ github.event_name }}" != "create" ||
222+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
223+
]]; then
224+
# Run the other jobs.
225+
RESULT="true"
226+
else
227+
# There is no need to run the other jobs.
228+
RESULT="false"
229+
fi
230+
231+
echo "result=$RESULT" >> $GITHUB_OUTPUT
232+
233+
check:
234+
needs: run-determination
235+
if: needs.run-determination.outputs.result == 'true'
236+
runs-on: ubuntu-latest
237+
238+
steps:
239+
- name: Checkout repository
240+
uses: actions/checkout@v3
241+
242+
- name: Setup Node.js
243+
uses: actions/setup-node@v3
244+
with:
245+
node-version: ${{ env.NODE_VERSION }}
246+
247+
- name: Install Task
248+
uses: arduino/setup-task@v1
249+
with:
250+
repo-token: ${{ secrets.GITHUB_TOKEN }}
251+
version: 3.x
252+
253+
- name: Format with Prettier
254+
run: task general:format-prettier
255+
256+
- name: Check formatting
257+
run: git diff --color --exit-code

.github/workflows/test-integration.yml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ name: Run integration tests
33
on:
44
pull_request:
55
paths:
6-
- '.github/workflows/test-integration.yml'
7-
- '.github/workflows/testdata/**'
8-
- '.python-version'
9-
- 'poetry.lock'
10-
- 'pyproject.toml'
11-
- 'action.yml'
12-
- 'compilesketches/**'
6+
- ".github/workflows/test-integration.yml"
7+
- ".github/workflows/testdata/**"
8+
- ".python-version"
9+
- "poetry.lock"
10+
- "pyproject.toml"
11+
- "action.yml"
12+
- "compilesketches/**"
1313

1414
push:
1515
paths:
16-
- '.github/workflows/test-integration.yml'
17-
- '.github/workflows/testdata/**'
18-
- '.python-version'
19-
- 'poetry.lock'
20-
- 'pyproject.toml'
21-
- 'action.yml'
22-
- 'compilesketches/**'
16+
- ".github/workflows/test-integration.yml"
17+
- ".github/workflows/testdata/**"
18+
- ".python-version"
19+
- "poetry.lock"
20+
- "pyproject.toml"
21+
- "action.yml"
22+
- "compilesketches/**"
2323

2424
env:
2525
SKETCHES_REPORTS_PATH: sketches-reports
2626
TESTDATA_PLATFORMS_PATH: .github/workflows/testdata/platforms
2727
TESTDATA_SKETCHES_PATH: .github/workflows/testdata/sketches
28-
TESTDATA_REPORTS_PATH: .github/workflows/testdata/reports
28+
TESTDATA_REPORTS_PATH: .github/workflows/testdata/reports
2929

3030
jobs:
3131
default-inputs:
@@ -48,7 +48,6 @@ jobs:
4848
# Use action from local path
4949
uses: ./extras/compile-sketches
5050

51-
5251
all-inputs:
5352
runs-on: ubuntu-latest
5453

@@ -119,7 +118,6 @@ jobs:
119118
outputs:
120119
report-artifact-name: ${{ steps.report-artifact-name.outputs.report-artifact-name }}
121120

122-
123121
multiple-steps:
124122
name: multiple-steps (${{ matrix.board.source-type }})
125123
runs-on: ubuntu-latest
@@ -239,7 +237,6 @@ jobs:
239237
sketch-paths: |
240238
- ${{ env.TESTDATA_SKETCHES_PATH }}/BareMinimum
241239
242-
243240
# Targeted testing for ESP32 boards platform support.
244241
pyserial-dependency:
245242
runs-on: ubuntu-latest
@@ -269,7 +266,6 @@ jobs:
269266
sketch-paths: |
270267
- ${{ env.TESTDATA_SKETCHES_PATH }}/BareMinimum
271268
272-
273269
check-sketches-reports:
274270
needs: all-inputs
275271
runs-on: ubuntu-latest
@@ -333,7 +329,6 @@ jobs:
333329
334330
exit $EXIT_STATUS
335331
336-
337332
expected-failed-compilation:
338333
runs-on: ubuntu-latest
339334

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.licenses/
2+
.pytest_cache/
3+
__pycache__/
4+
node_modules/

0 commit comments

Comments
 (0)