Skip to content

Commit d9f73eb

Browse files
authored
Merge pull request #250 from per1234/clangformat-config
Host standardized ClangFormat configuration file
2 parents 44f1951 + c5f256f commit d9f73eb

File tree

2,667 files changed

+210856
-246
lines changed

Some content is hidden

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

2,667 files changed

+210856
-246
lines changed

.codespellrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# See: https://github.com/codespell-project/codespell#using-a-config-file
33
[codespell]
44
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
5-
ignore-words-list = licence,ot
6-
skip = ./.git,./.licenses,__pycache__,node_modules,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock
5+
ignore-words-list = ba,licence,ot
6+
skip = ./.git,./.licenses,__pycache__,node_modules,./other/clang-format-configuration/testdata/input/samples,./other/clang-format-configuration/testdata/golden,./other/clang-format-configuration/.clang-format,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock
77
builtin = clear,informal,en-GB_to_en-US
88
check-filenames =
99
check-hidden =

.ecrc

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"^\\.licenses[/\\\\]",
55
"__pycache__[/\\\\]",
66
"node_modules[/\\\\]",
7+
"^other[/\\\\]clang-format-configuration[/\\\\]testdata[/\\\\]",
8+
"^other[/\\\\]clang-format-configuration[/\\\\]\\.clang-format",
79
"^LICENSE\\.txt$",
810
"^poetry\\.lock$"
911
]

.eslintrc.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-javascript/.eslintrc.yml
2+
# See: https://eslint.org/docs/user-guide/configuring/
3+
# The code style defined in this file is the official standardized style to be used in all Arduino projects and should
4+
# not be modified.
5+
6+
extends:
7+
- airbnb-base
8+
- prettier
9+
rules:
10+
max-len:
11+
- error
12+
- code: 180
13+
no-console: "off"
14+
no-underscore-dangle: "off"
+230
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
name: Check ClangFormat Configuration
2+
3+
env:
4+
# See: https://github.com/actions/setup-node/#readme
5+
NODE_VERSION: 16.x
6+
7+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
8+
on:
9+
push:
10+
paths:
11+
- ".github/workflows/check-clang-format.yml"
12+
- "other/clang-format-configuration/scripts/convert-clang-format-configuration.js"
13+
- "other/clang-format-configuration/testdata/**"
14+
- "other/clang-format-configuration/.clang-format"
15+
- "package.json"
16+
- "package-lock.json"
17+
- "Taskfile.ya?ml"
18+
pull_request:
19+
paths:
20+
- ".github/workflows/check-clang-format.yml"
21+
- "other/clang-format-configuration/scripts/convert-clang-format-configuration.js"
22+
- "other/clang-format-configuration/testdata/**"
23+
- "other/clang-format-configuration/.clang-format"
24+
- "package.json"
25+
- "package-lock.json"
26+
- "Taskfile.ya?ml"
27+
schedule:
28+
# Run periodically to catch breakage caused by external changes.
29+
- cron: "0 17 * * WED"
30+
workflow_dispatch:
31+
inputs:
32+
clang-format-version:
33+
description: ClangFormat version (leave empty for standard version)
34+
type: string
35+
default: ""
36+
required: false
37+
repository_dispatch:
38+
39+
jobs:
40+
validate:
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v3
46+
47+
- name: Setup Node.js
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: ${{ env.NODE_VERSION }}
51+
52+
- name: Install Task
53+
uses: arduino/setup-task@v1
54+
with:
55+
repo-token: ${{ secrets.GITHUB_TOKEN }}
56+
version: 3.x
57+
58+
- name: Validate ClangFormat configuration files
59+
run: task --silent clang-format:validate
60+
61+
check-config:
62+
runs-on: ubuntu-latest
63+
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v3
67+
68+
- name: Install Task
69+
uses: arduino/setup-task@v1
70+
with:
71+
repo-token: ${{ secrets.GITHUB_TOKEN }}
72+
version: 3.x
73+
74+
- name: Set environment variables
75+
run: |
76+
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
77+
if [[ "${{ github.event.inputs.clang-format-version }}" == "" ]]; then
78+
echo "CLANG_FORMAT_VERSION=$(task clang-format:get-version)" >> "$GITHUB_ENV"
79+
else
80+
echo "CLANG_FORMAT_VERSION=${{ github.event.inputs.clang-format-version }}" >> "$GITHUB_ENV"
81+
fi
82+
echo "CLANG_FORMAT_INSTALL_PATH=${{ runner.temp }}/clang-format" >> "$GITHUB_ENV"
83+
echo "WORKING_FOLDER=${{ runner.temp }}" >> "$GITHUB_ENV"
84+
85+
- name: Download ClangFormat
86+
id: download
87+
uses: MrOctopus/[email protected]
88+
with:
89+
repository: arduino/clang-static-binaries
90+
tag: ${{ env.CLANG_FORMAT_VERSION }}
91+
asset: clang-format_${{ env.CLANG_FORMAT_VERSION }}_Linux_64bit.tar.bz2
92+
target: ${{ env.CLANG_FORMAT_INSTALL_PATH }}
93+
94+
- name: Install ClangFormat
95+
run: |
96+
cd "${{ env.CLANG_FORMAT_INSTALL_PATH }}"
97+
tar --extract --file="${{ steps.download.outputs.name }}"
98+
# Add installation to PATH:
99+
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path
100+
echo "${{ env.CLANG_FORMAT_INSTALL_PATH }}/clang_Linux_64bit" >> "$GITHUB_PATH"
101+
102+
- name: Check ClangFormat configuration file
103+
id: check
104+
run: |
105+
task \
106+
--silent \
107+
clang-format:check-config \
108+
CLANG_FORMAT_VERSION="${{ env.CLANG_FORMAT_VERSION }}"
109+
110+
- name: Save effective configuration file to a workflow artifact
111+
if: >
112+
always() &&
113+
steps.check.outcome == 'failure'
114+
uses: actions/upload-artifact@v3
115+
with:
116+
path: ${{ env.WORKING_FOLDER }}/expected/.clang-format
117+
if-no-files-found: error
118+
name: config-output
119+
120+
check-output:
121+
runs-on: ubuntu-latest
122+
123+
steps:
124+
- name: Checkout repository
125+
uses: actions/checkout@v3
126+
127+
- name: Install Task
128+
uses: arduino/setup-task@v1
129+
with:
130+
repo-token: ${{ secrets.GITHUB_TOKEN }}
131+
version: 3.x
132+
133+
- name: Set environment variables
134+
run: |
135+
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
136+
if [[ "${{ github.event.inputs.clang-format-version }}" == "" ]]; then
137+
echo "CLANG_FORMAT_VERSION=$(task clang-format:get-version)" >> "$GITHUB_ENV"
138+
else
139+
echo "CLANG_FORMAT_VERSION=${{ github.event.inputs.clang-format-version }}" >> "$GITHUB_ENV"
140+
fi
141+
echo "CLANG_FORMAT_INSTALL_PATH=${{ runner.temp }}/clang-format" >> "$GITHUB_ENV"
142+
echo "WORKING_FOLDER=${{ runner.temp }}" >> "$GITHUB_ENV"
143+
144+
- name: Download ClangFormat
145+
id: download
146+
uses: MrOctopus/[email protected]
147+
with:
148+
repository: arduino/clang-static-binaries
149+
tag: ${{ env.CLANG_FORMAT_VERSION }}
150+
asset: clang-format_${{ env.CLANG_FORMAT_VERSION }}_Linux_64bit.tar.bz2
151+
target: ${{ env.CLANG_FORMAT_INSTALL_PATH }}
152+
153+
- name: Install ClangFormat
154+
run: |
155+
cd "${{ env.CLANG_FORMAT_INSTALL_PATH }}"
156+
tar --extract --file="${{ steps.download.outputs.name }}"
157+
# Add installation to PATH:
158+
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path
159+
echo "${{ env.CLANG_FORMAT_INSTALL_PATH }}/clang_Linux_64bit" >> "$GITHUB_PATH"
160+
161+
- name: Check ClangFormat output
162+
id: check
163+
run: |
164+
task \
165+
clang-format:check-output \
166+
CLANG_FORMAT_VERSION="${{ env.CLANG_FORMAT_VERSION }}" \
167+
WORKING_FOLDER="${{ env.WORKING_FOLDER }}"
168+
169+
- name: Save formatted test data to a workflow artifact
170+
if: >
171+
always() &&
172+
steps.check.outcome == 'failure'
173+
uses: actions/upload-artifact@v3
174+
with:
175+
path: ${{ env.WORKING_FOLDER }}/output
176+
if-no-files-found: error
177+
name: testdata-output
178+
179+
check-testdata:
180+
runs-on: ubuntu-latest
181+
182+
steps:
183+
- name: Checkout repository
184+
uses: actions/checkout@v3
185+
186+
- name: Install Task
187+
uses: arduino/setup-task@v1
188+
with:
189+
repo-token: ${{ secrets.GITHUB_TOKEN }}
190+
version: 3.x
191+
192+
- name: Check ClangFormat test data
193+
run: task --silent clang-format:check-testdata
194+
195+
convert:
196+
runs-on: ubuntu-latest
197+
198+
steps:
199+
- name: Set environment variables
200+
run: |
201+
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
202+
echo "CONVERSION_OUTPUT_PATH=${{ runner.temp }}/clang-format-js-object.txt" >> "$GITHUB_ENV"
203+
204+
- name: Checkout repository
205+
uses: actions/checkout@v3
206+
207+
- name: Setup Node.js
208+
uses: actions/setup-node@v3
209+
with:
210+
node-version: ${{ env.NODE_VERSION }}
211+
212+
- name: Install Task
213+
uses: arduino/setup-task@v1
214+
with:
215+
repo-token: ${{ secrets.GITHUB_TOKEN }}
216+
version: 3.x
217+
218+
- name: Convert the ClangFormat configuration
219+
run: |
220+
task \
221+
--silent \
222+
clang-format:convert \
223+
OUTPUT_PATH="${{ env.CONVERSION_OUTPUT_PATH }}"
224+
225+
- name: Save conversion to a workflow artifact
226+
uses: actions/upload-artifact@v3
227+
with:
228+
path: ${{ env.CONVERSION_OUTPUT_PATH }}
229+
if-no-files-found: error
230+
name: javascript-configuration-object

.github/workflows/check-eslint.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Check ESLint Configuration
2+
3+
env:
4+
# See: https://github.com/actions/setup-node/#readme
5+
NODE_VERSION: 16.x
6+
7+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
8+
on:
9+
push:
10+
paths:
11+
- ".github/workflows/check-eslint.yml"
12+
- "workflow-templates/assets/check-javascript/.eslintrc.yml"
13+
- "package.json"
14+
- "package-lock.json"
15+
- "Taskfile.ya?ml"
16+
pull_request:
17+
paths:
18+
- ".github/workflows/check-eslint.yml"
19+
- "workflow-templates/assets/check-javascript/.eslintrc.yml"
20+
- "package.json"
21+
- "package-lock.json"
22+
- "Taskfile.ya?ml"
23+
schedule:
24+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
25+
- cron: "0 8 * * TUE"
26+
workflow_dispatch:
27+
repository_dispatch:
28+
29+
jobs:
30+
validate:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v3
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: ${{ env.NODE_VERSION }}
41+
42+
- name: Install Task
43+
uses: arduino/setup-task@v1
44+
with:
45+
repo-token: ${{ secrets.GITHUB_TOKEN }}
46+
version: 3.x
47+
48+
- name: Validate workflows
49+
run: task --silent eslint:validate
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-javascript-task.md
2+
name: Check JavaScript
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+
push:
11+
paths:
12+
- ".github/workflows/check-javascript-task.ya?ml"
13+
- ".eslintignore"
14+
- "**/.eslintrc*"
15+
- "package.json"
16+
- "package-lock.json"
17+
- "Taskfile.ya?ml"
18+
- "**.jsx?"
19+
pull_request:
20+
paths:
21+
- ".github/workflows/check-javascript-task.ya?ml"
22+
- ".eslintignore"
23+
- "**/.eslintrc*"
24+
- "package.json"
25+
- "package-lock.json"
26+
- "Taskfile.ya?ml"
27+
- "**.jsx?"
28+
workflow_dispatch:
29+
repository_dispatch:
30+
31+
permissions:
32+
contents: read
33+
34+
jobs:
35+
check:
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v3
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v3
44+
with:
45+
node-version: ${{ env.NODE_VERSION }}
46+
47+
- name: Install Task
48+
uses: arduino/setup-task@v1
49+
with:
50+
repo-token: ${{ secrets.GITHUB_TOKEN }}
51+
version: 3.x
52+
53+
- name: Lint
54+
run: task js:lint

.markdownlintignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.licenses/
33
__pycache__/
44
node_modules/
5+
/other/clang-format-configuration/testdata/golden/samples/
6+
/other/clang-format-configuration/testdata/input/samples/

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.licenses/
22
__pycache__/
33
node_modules/
4+
/other/clang-format-configuration/testdata/golden/samples/
5+
/other/clang-format-configuration/testdata/input/samples/
6+
/other/clang-format-configuration/.clang-format

.yamllint.yml

+1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,6 @@ yaml-files:
7272

7373
ignore: |
7474
/.git/
75+
/other/clang-format-configuration/.clang-format
7576
__pycache__/
7677
node_modules/

0 commit comments

Comments
 (0)