Skip to content

Commit 19f5e91

Browse files
authored
Merge pull request #67 from per1234/prettier
Add infrastructure for formatting with the Prettier tool
2 parents 5494460 + 1acee02 commit 19f5e91

8 files changed

+322
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
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+
permissions: {}
213+
outputs:
214+
result: ${{ steps.determination.outputs.result }}
215+
steps:
216+
- name: Determine if the rest of the workflow should run
217+
id: determination
218+
run: |
219+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
220+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
221+
if [[
222+
"${{ github.event_name }}" != "create" ||
223+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
224+
]]; then
225+
# Run the other jobs.
226+
RESULT="true"
227+
else
228+
# There is no need to run the other jobs.
229+
RESULT="false"
230+
fi
231+
232+
echo "result=$RESULT" >> $GITHUB_OUTPUT
233+
234+
check:
235+
needs: run-determination
236+
if: needs.run-determination.outputs.result == 'true'
237+
runs-on: ubuntu-latest
238+
permissions:
239+
contents: read
240+
241+
steps:
242+
- name: Checkout repository
243+
uses: actions/checkout@v4
244+
245+
- name: Setup Node.js
246+
uses: actions/setup-node@v4
247+
with:
248+
node-version: ${{ env.NODE_VERSION }}
249+
250+
- name: Install Task
251+
uses: arduino/setup-task@v1
252+
with:
253+
repo-token: ${{ secrets.GITHUB_TOKEN }}
254+
version: 3.x
255+
256+
- name: Format with Prettier
257+
run: task general:format-prettier
258+
259+
- name: Check formatting
260+
run: git diff --color --exit-code

.github/workflows/test-integration.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ name: Run integration tests
33
on:
44
pull_request:
55
paths:
6-
- '.github/workflows/test-integration.yml'
7-
- '.github/workflows/testdata/**'
8-
- 'action.yml'
9-
- 'Dockerfile'
10-
- 'reportsizedeltas/**'
6+
- ".github/workflows/test-integration.yml"
7+
- ".github/workflows/testdata/**"
8+
- "action.yml"
9+
- "Dockerfile"
10+
- "reportsizedeltas/**"
1111
push:
1212
paths:
13-
- '.github/workflows/test-integration.yml'
14-
- '.github/workflows/testdata/**'
15-
- 'action.yml'
16-
- 'Dockerfile'
17-
- 'reportsizedeltas/**'
13+
- ".github/workflows/test-integration.yml"
14+
- ".github/workflows/testdata/**"
15+
- "action.yml"
16+
- "Dockerfile"
17+
- "reportsizedeltas/**"
1818
schedule:
1919
# Run daily at 8 AM UTC to catch breakage caused by changes to external resources.
2020
- cron: "0 8 * * *"

.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.github/workflows/testdata/sketches-reports/
2+
/reportsizedeltas/tests/data/size-deltas-reports-new/
3+
/reportsizedeltas/tests/data/size-deltas-reports-old/
4+
.licenses/
5+
__pycache__/
6+
node_modules/

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Check Markdown status](https://github.com/arduino/report-size-deltas/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/check-markdown-task.yml)
44
[![Check npm status](https://github.com/arduino/report-size-deltas/actions/workflows/check-npm-task.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/check-npm-task.yml)
55
[![Check Poetry status](https://github.com/arduino/report-size-deltas/actions/workflows/check-poetry-task.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/check-poetry-task.yml)
6+
[![Check Prettier Formatting status](https://github.com/arduino/report-size-deltas/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/check-prettier-formatting-task.yml)
67
[![Check Python status](https://github.com/arduino/report-size-deltas/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/check-python-task.yml)
78
[![Check Taskfiles status](https://github.com/arduino/report-size-deltas/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/check-taskfiles.yml)
89
[![Check ToC status](https://github.com/arduino/report-size-deltas/actions/workflows/check-toc-task.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/check-toc-task.yml)
@@ -72,7 +73,7 @@ In this usage, the `sketches-reports-source` defines the path to the folder cont
7273
```yaml
7374
on:
7475
schedule:
75-
- cron: '*/5 * * * *'
76+
- cron: "*/5 * * * *"
7677
jobs:
7778
build:
7879
runs-on: ubuntu-latest
@@ -81,6 +82,7 @@ jobs:
8182
```
8283
8384
This must be used in conjunction with a workflow that runs the [`arduino/compile-sketches`](https://github.com/arduino/compile-sketches) action and uploads the resulting sketches report to a [workflow artifact](https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts):
85+
8486
```yaml
8587
on: [push, pull_request]
8688
jobs:
@@ -122,7 +124,7 @@ jobs:
122124
enable-deltas-report: true
123125
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
124126
125-
# This step is needed to pass the size data to the report job
127+
# This step is needed to pass the size data to the report job
126128
- name: Upload sketches report to workflow artifact
127129
uses: actions/upload-artifact@v3
128130
with:
@@ -131,7 +133,7 @@ jobs:
131133
132134
# When using a matrix to compile for multiple boards, it's necessary to use a separate job for the deltas report
133135
report:
134-
needs: compile # Wait for the compile job to finish to get the data for the report
136+
needs: compile # Wait for the compile job to finish to get the data for the report
135137
if: github.event_name == 'pull_request' # Only run the job when the workflow is triggered by a pull request
136138
runs-on: ubuntu-latest
137139
steps:

Taskfile.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ tasks:
2323
desc: Make automated corrections to the project's files
2424
deps:
2525
- task: general:correct-spelling
26+
- task: general:format-prettier
2627
- task: markdown:fix
2728
- task: markdown:toc
2829
- task: poetry:sync
@@ -49,6 +50,14 @@ tasks:
4950
cmds:
5051
- poetry run codespell --write-changes
5152

53+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml
54+
general:format-prettier:
55+
desc: Format all supported files with Prettier
56+
deps:
57+
- task: npm:install-deps
58+
cmds:
59+
- npx prettier --write .
60+
5261
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
5362
markdown:check-links:
5463
desc: Check for broken links
@@ -125,7 +134,6 @@ tasks:
125134
cmds:
126135
- npm install
127136

128-
129137
# Parameter variables:
130138
# - PROJECT_PATH: path of the npm-managed project. Default value: "./"
131139
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml

action.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: 'Report Arduino Sketch Size Deltas'
2-
description: 'Comments on the pull request with a report on the resulting change in memory usage of Arduino sketches'
1+
name: "Report Arduino Sketch Size Deltas"
2+
description: "Comments on the pull request with a report on the resulting change in memory usage of Arduino sketches"
33
inputs:
44
sketches-reports-source:
5-
description: 'When run from scheduled workflow, name of the workflow artifact that contains sketches reports. When run from a pull request triggered workflow, path to the folder containing sketches reports.'
6-
default: 'sketches-reports'
5+
description: "When run from scheduled workflow, name of the workflow artifact that contains sketches reports. When run from a pull request triggered workflow, path to the folder containing sketches reports."
6+
default: "sketches-reports"
77
github-token:
8-
description: 'GitHub access token used to comment the memory usage comparison results to the PR thread'
8+
description: "GitHub access token used to comment the memory usage comparison results to the PR thread"
99
default: ${{ github.token }}
1010
runs:
11-
using: 'docker'
12-
image: 'Dockerfile'
11+
using: "docker"
12+
image: "Dockerfile"

0 commit comments

Comments
 (0)