Skip to content

Commit eacbf40

Browse files
committed
Merge branch 'ci/style_check'
2 parents 93448d7 + 1febffe commit eacbf40

File tree

11 files changed

+576
-3
lines changed

11 files changed

+576
-3
lines changed

.clang-format

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/tree/main/other/clang-format-configuration
2+
---
3+
AccessModifierOffset: -2
4+
AlignAfterOpenBracket: Align
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveAssignments: None
7+
AlignConsecutiveBitFields: None
8+
AlignConsecutiveDeclarations: None
9+
AlignConsecutiveMacros: None
10+
AlignEscapedNewlines: DontAlign
11+
AlignOperands: Align
12+
AlignTrailingComments: true
13+
AllowAllArgumentsOnNextLine: true
14+
AllowAllConstructorInitializersOnNextLine: true
15+
AllowAllParametersOfDeclarationOnNextLine: true
16+
AllowShortBlocksOnASingleLine: Always
17+
AllowShortCaseLabelsOnASingleLine: true
18+
AllowShortEnumsOnASingleLine: true
19+
AllowShortFunctionsOnASingleLine: Empty
20+
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
21+
AllowShortLambdasOnASingleLine: Empty
22+
AllowShortLoopsOnASingleLine: true
23+
AlwaysBreakAfterDefinitionReturnType: None
24+
AlwaysBreakAfterReturnType: None
25+
AlwaysBreakBeforeMultilineStrings: false
26+
AlwaysBreakTemplateDeclarations: No
27+
AttributeMacros:
28+
- __capability
29+
BasedOnStyle: LLVM
30+
BinPackArguments: true
31+
BinPackParameters: true
32+
BitFieldColonSpacing: Both
33+
BraceWrapping:
34+
AfterCaseLabel: false
35+
AfterClass: false
36+
AfterControlStatement: Never
37+
AfterEnum: false
38+
AfterFunction: false
39+
AfterNamespace: false
40+
AfterObjCDeclaration: false
41+
AfterStruct: false
42+
AfterUnion: false
43+
AfterExternBlock: false
44+
BeforeCatch: false
45+
BeforeElse: false
46+
BeforeLambdaBody: false
47+
BeforeWhile: false
48+
IndentBraces: false
49+
SplitEmptyFunction: true
50+
SplitEmptyRecord: true
51+
SplitEmptyNamespace: true
52+
BreakAfterJavaFieldAnnotations: false
53+
BreakBeforeBinaryOperators: NonAssignment
54+
BreakBeforeBraces: Attach
55+
BreakBeforeConceptDeclarations: false
56+
BreakBeforeInheritanceComma: false
57+
BreakBeforeTernaryOperators: true
58+
BreakConstructorInitializers: BeforeColon
59+
BreakConstructorInitializersBeforeComma: false
60+
BreakInheritanceList: BeforeColon
61+
BreakStringLiterals: false
62+
ColumnLimit: 0
63+
CommentPragmas: ''
64+
CompactNamespaces: false
65+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
66+
ConstructorInitializerIndentWidth: 2
67+
ContinuationIndentWidth: 2
68+
Cpp11BracedListStyle: false
69+
DeriveLineEnding: true
70+
DerivePointerAlignment: true
71+
DisableFormat: false
72+
EmptyLineAfterAccessModifier: Leave
73+
EmptyLineBeforeAccessModifier: Leave
74+
ExperimentalAutoDetectBinPacking: false
75+
FixNamespaceComments: false
76+
ForEachMacros:
77+
- foreach
78+
- Q_FOREACH
79+
- BOOST_FOREACH
80+
IfMacros:
81+
- KJ_IF_MAYBE
82+
IncludeBlocks: Preserve
83+
IncludeCategories:
84+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
85+
Priority: 2
86+
SortPriority: 0
87+
CaseSensitive: false
88+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
89+
Priority: 3
90+
SortPriority: 0
91+
CaseSensitive: false
92+
- Regex: '.*'
93+
Priority: 1
94+
SortPriority: 0
95+
CaseSensitive: false
96+
IncludeIsMainRegex: ''
97+
IncludeIsMainSourceRegex: ''
98+
IndentAccessModifiers: false
99+
IndentCaseBlocks: true
100+
IndentCaseLabels: true
101+
IndentExternBlock: Indent
102+
IndentGotoLabels: false
103+
IndentPPDirectives: None
104+
IndentRequires: true
105+
IndentWidth: 2
106+
IndentWrappedFunctionNames: false
107+
InsertTrailingCommas: None
108+
JavaScriptQuotes: Leave
109+
JavaScriptWrapImports: true
110+
KeepEmptyLinesAtTheStartOfBlocks: true
111+
LambdaBodyIndentation: Signature
112+
Language: Cpp
113+
MacroBlockBegin: ''
114+
MacroBlockEnd: ''
115+
MaxEmptyLinesToKeep: 100000
116+
NamespaceIndentation: None
117+
ObjCBinPackProtocolList: Auto
118+
ObjCBlockIndentWidth: 2
119+
ObjCBreakBeforeNestedBlockParam: true
120+
ObjCSpaceAfterProperty: false
121+
ObjCSpaceBeforeProtocolList: true
122+
PPIndentWidth: -1
123+
PackConstructorInitializers: BinPack
124+
PenaltyBreakAssignment: 1
125+
PenaltyBreakBeforeFirstCallParameter: 1
126+
PenaltyBreakComment: 1
127+
PenaltyBreakFirstLessLess: 1
128+
PenaltyBreakOpenParenthesis: 1
129+
PenaltyBreakString: 1
130+
PenaltyBreakTemplateDeclaration: 1
131+
PenaltyExcessCharacter: 1
132+
PenaltyIndentedWhitespace: 1
133+
PenaltyReturnTypeOnItsOwnLine: 1
134+
PointerAlignment: Right
135+
QualifierAlignment: Leave
136+
ReferenceAlignment: Pointer
137+
ReflowComments: false
138+
RemoveBracesLLVM: false
139+
SeparateDefinitionBlocks: Leave
140+
ShortNamespaceLines: 0
141+
SortIncludes: Never
142+
SortJavaStaticImport: Before
143+
SortUsingDeclarations: false
144+
SpaceAfterCStyleCast: false
145+
SpaceAfterLogicalNot: false
146+
SpaceAfterTemplateKeyword: false
147+
SpaceAroundPointerQualifiers: Default
148+
SpaceBeforeAssignmentOperators: true
149+
SpaceBeforeCaseColon: false
150+
SpaceBeforeCpp11BracedList: false
151+
SpaceBeforeCtorInitializerColon: true
152+
SpaceBeforeInheritanceColon: true
153+
SpaceBeforeParens: ControlStatements
154+
SpaceBeforeParensOptions:
155+
AfterControlStatements: true
156+
AfterForeachMacros: true
157+
AfterFunctionDefinitionName: false
158+
AfterFunctionDeclarationName: false
159+
AfterIfMacros: true
160+
AfterOverloadedOperator: false
161+
BeforeNonEmptyParentheses: false
162+
SpaceBeforeRangeBasedForLoopColon: true
163+
SpaceBeforeSquareBrackets: false
164+
SpaceInEmptyBlock: false
165+
SpaceInEmptyParentheses: false
166+
SpacesBeforeTrailingComments: 2
167+
SpacesInAngles: Leave
168+
SpacesInCStyleCastParentheses: false
169+
SpacesInConditionalStatement: false
170+
SpacesInContainerLiterals: false
171+
SpacesInLineCommentPrefix:
172+
Minimum: 0
173+
Maximum: -1
174+
SpacesInParentheses: false
175+
SpacesInSquareBrackets: false
176+
Standard: Auto
177+
StatementAttributeLikeMacros:
178+
- Q_EMIT
179+
StatementMacros:
180+
- Q_UNUSED
181+
- QT_REQUIRE_VERSION
182+
TabWidth: 2
183+
UseCRLF: false
184+
UseTab: Never
185+
WhitespaceSensitiveMacros:
186+
- STRINGIZE
187+
- PP_STRINGIZE
188+
- BOOST_PP_STRINGIZE
189+
- NS_SWIFT_NAME
190+
- CF_SWIFT_NAME

.codespellrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[codespell]
2+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc
3+
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
4+
ignore-words-list = ba,licence,ot,dout,als,exten,acount,totaly,pasttime
5+
skip = ./.git,./.licenses,__pycache__,.clang-format,.codespellrc,.editorconfig,.flake8,.prettierignore,.yamllint.yml,.gitignore,boards.txt,platform.txt,programmers.txt
6+
builtin = clear,informal,en-GB_to_en-US
7+
check-filenames =
8+
check-hidden =
9+
write-changes =

.editorconfig

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/general/.editorconfig
2+
# See: https://editorconfig.org/
3+
# The formatting style defined in this file is the official standardized style to be used in all Arduino Tooling
4+
# projects and should not be modified.
5+
# Note: indent style for each file type is defined even when it matches the universal config in order to make it clear
6+
# that this type has an official style.
7+
8+
[*]
9+
charset = utf-8
10+
end_of_line = lf
11+
indent_size = 2
12+
indent_style = space
13+
insert_final_newline = true
14+
trim_trailing_whitespace = true
15+
16+
[*.{adoc,asc,asciidoc}]
17+
indent_size = 2
18+
indent_style = space
19+
20+
[*.{bash,sh}]
21+
indent_size = 2
22+
indent_style = space
23+
24+
[*.{c,cc,cp,cpp,cxx,h,hh,hpp,hxx,ii,inl,ino,ixx,pde,tpl,tpp,txx}]
25+
indent_size = 2
26+
indent_style = space
27+
28+
[*.{go,mod}]
29+
indent_style = tab
30+
31+
[*.java]
32+
indent_size = 2
33+
indent_style = space
34+
35+
[*.{js,jsx,json,jsonc,json5,ts,tsx}]
36+
indent_size = 2
37+
indent_style = space
38+
39+
[*.{md,mdx,mkdn,mdown,markdown}]
40+
indent_size = unset
41+
indent_style = space
42+
43+
[*.proto]
44+
indent_size = 2
45+
indent_style = space
46+
47+
[*.py]
48+
indent_size = 4
49+
indent_style = space
50+
51+
[*.svg]
52+
indent_size = 2
53+
indent_style = space
54+
55+
[*.{yaml,yml}]
56+
indent_size = 2
57+
indent_style = space
58+
59+
[{.gitconfig,.gitmodules}]
60+
indent_style = tab

.flake8

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python/.flake8
2+
# See: https://flake8.pycqa.org/en/latest/user/configuration.html
3+
# The code style defined in this file is the official standardized style to be used in all Arduino tooling projects and
4+
# should not be modified.
5+
6+
[flake8]
7+
doctests = True
8+
# W503 and W504 are mutually exclusive. PEP 8 recommends line break before.
9+
ignore = W503
10+
max-complexity = 10
11+
max-line-length = 120
12+
select = E,W,F,C,N

.github/scripts/on-push.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
set -e
44

5-
export ARDUINO_BUILD_DIR="$HOME/.arduino/build.tmp"
6-
75
function build(){
86
local target=$1
97
local fqbn=$2

.github/workflows/pre-commit.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Pre-commit check
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, reopened, synchronize, labeled]
7+
workflow_run:
8+
workflows: ["ESP32 Arduino CI"]
9+
types: [completed]
10+
11+
concurrency:
12+
group: pre-commit-${{github.event.pull_request.number || github.ref}}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
save-workflow-id:
17+
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
18+
name: Save compilation workflow ID
19+
runs-on: ubuntu-latest
20+
outputs:
21+
workflow_id: ${{ steps.save-workflow-id.outputs.workflow_id }}
22+
steps:
23+
- name: Save workflow ID
24+
id: save-workflow-id
25+
run: echo "workflow_id=${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT
26+
27+
lint:
28+
if: always()
29+
#if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') }}
30+
needs: save-workflow-id
31+
name: Run pre-commit hooks
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout latest commit
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 2
38+
39+
- name: Set up Python 3
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: "3.x"
43+
44+
- name: Get Python version hash
45+
run: |
46+
echo "Using $(python -VV)"
47+
echo "PY_HASH=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
48+
49+
- name: Restore pre-commit cache
50+
uses: actions/cache/restore@v4
51+
id: restore-cache
52+
with:
53+
path: |
54+
~/.cache/pre-commit
55+
~/.cache/pip
56+
key: pre-commit|${{ env.PY_HASH }}|${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml') }}
57+
58+
- name: Download compilation artifacts
59+
uses: actions/download-artifact@v4
60+
if: ${{ needs.save-workflow-id.outputs.workflow_id != '' }}
61+
with:
62+
pattern: build-job-*
63+
merge-multiple: true
64+
path: ~/.arduino/tests/
65+
run-id: ${{ needs.save-workflow-id.outputs.workflow_id }}
66+
github-token: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Merge compile commands
69+
if: ${{ needs.save-workflow-id.outputs.workflow_id != '' }}
70+
run: |
71+
find ~/.arduino/tests/ -iname "compile_commands.json" | xargs jq -s 'map(.[])' > ~/compile_commands.json
72+
73+
- name: Upload compile commands
74+
if: ${{ needs.save-workflow-id.outputs.workflow_id != '' }}
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: compile_commands
78+
path: ~/compile_commands.json
79+
80+
- name: Install python dependencies
81+
run: python -m pip install pre-commit docutils
82+
83+
- name: Get changed files
84+
id: changed-files
85+
uses: tj-actions/[email protected]
86+
87+
- name: Run pre-commit hooks in changed files
88+
run: pre-commit run --color=always --show-diff-on-failure --files ${{ steps.changed-files.outputs.all_changed_files }}
89+
90+
- name: Save pre-commit cache
91+
uses: actions/cache/save@v4
92+
if: ${{ always() && steps.restore-cache.outputs.cache-hit != 'true' }}
93+
continue-on-error: true
94+
with:
95+
path: |
96+
~/.cache/pre-commit
97+
~/.cache/pip
98+
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
99+
100+
- name: Push changes using pre-commit-ci-lite
101+
uses: pre-commit-ci/[email protected]
102+
if: always()

0 commit comments

Comments
 (0)