-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Style Checker and Pre-commit hook CI (#9132)
* Add Config * Add Cache and remove pre-commit action * [pre-commit.ci lite] apply automatic fixes * Remove freeze * Fix * Update action * Use latest stable Python 3 version * Improve caching * Improve cache tag * Improve bot message * Fix flake and make Vale manual * Add filter --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Rodrigo Garcia <[email protected]>
- Loading branch information
1 parent
5573806
commit 4909dec
Showing
9 changed files
with
528 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
# Source: https://github.com/arduino/tooling-project-assets/tree/main/other/clang-format-configuration | ||
--- | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignArrayOfStructures: None | ||
AlignConsecutiveAssignments: None | ||
AlignConsecutiveBitFields: None | ||
AlignConsecutiveDeclarations: None | ||
AlignConsecutiveMacros: None | ||
AlignEscapedNewlines: DontAlign | ||
AlignOperands: Align | ||
AlignTrailingComments: true | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllConstructorInitializersOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: Always | ||
AllowShortCaseLabelsOnASingleLine: true | ||
AllowShortEnumsOnASingleLine: true | ||
AllowShortFunctionsOnASingleLine: Empty | ||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse | ||
AllowShortLambdasOnASingleLine: Empty | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: No | ||
AttributeMacros: | ||
- __capability | ||
BasedOnStyle: LLVM | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BitFieldColonSpacing: Both | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: false | ||
AfterControlStatement: Never | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
BeforeLambdaBody: false | ||
BeforeWhile: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakBeforeBinaryOperators: NonAssignment | ||
BreakBeforeBraces: Attach | ||
BreakBeforeConceptDeclarations: false | ||
BreakBeforeInheritanceComma: false | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializers: BeforeColon | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakInheritanceList: BeforeColon | ||
BreakStringLiterals: false | ||
ColumnLimit: 0 | ||
CommentPragmas: '' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 2 | ||
ContinuationIndentWidth: 2 | ||
Cpp11BracedListStyle: false | ||
DeriveLineEnding: true | ||
DerivePointerAlignment: true | ||
DisableFormat: false | ||
EmptyLineAfterAccessModifier: Leave | ||
EmptyLineBeforeAccessModifier: Leave | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: false | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IfMacros: | ||
- KJ_IF_MAYBE | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
- Regex: '.*' | ||
Priority: 1 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
IncludeIsMainRegex: '' | ||
IncludeIsMainSourceRegex: '' | ||
IndentAccessModifiers: false | ||
IndentCaseBlocks: true | ||
IndentCaseLabels: true | ||
IndentExternBlock: Indent | ||
IndentGotoLabels: false | ||
IndentPPDirectives: None | ||
IndentRequires: true | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
InsertTrailingCommas: None | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
LambdaBodyIndentation: Signature | ||
Language: Cpp | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 100000 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCBreakBeforeNestedBlockParam: true | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PPIndentWidth: -1 | ||
PackConstructorInitializers: BinPack | ||
PenaltyBreakAssignment: 1 | ||
PenaltyBreakBeforeFirstCallParameter: 1 | ||
PenaltyBreakComment: 1 | ||
PenaltyBreakFirstLessLess: 1 | ||
PenaltyBreakOpenParenthesis: 1 | ||
PenaltyBreakString: 1 | ||
PenaltyBreakTemplateDeclaration: 1 | ||
PenaltyExcessCharacter: 1 | ||
PenaltyIndentedWhitespace: 1 | ||
PenaltyReturnTypeOnItsOwnLine: 1 | ||
PointerAlignment: Right | ||
QualifierAlignment: Leave | ||
ReferenceAlignment: Pointer | ||
ReflowComments: false | ||
RemoveBracesLLVM: false | ||
SeparateDefinitionBlocks: Leave | ||
ShortNamespaceLines: 0 | ||
SortIncludes: Never | ||
SortJavaStaticImport: Before | ||
SortUsingDeclarations: false | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: false | ||
SpaceAroundPointerQualifiers: Default | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCaseColon: false | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeParensOptions: | ||
AfterControlStatements: true | ||
AfterForeachMacros: true | ||
AfterFunctionDefinitionName: false | ||
AfterFunctionDeclarationName: false | ||
AfterIfMacros: true | ||
AfterOverloadedOperator: false | ||
BeforeNonEmptyParentheses: false | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceBeforeSquareBrackets: false | ||
SpaceInEmptyBlock: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 2 | ||
SpacesInAngles: Leave | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInConditionalStatement: false | ||
SpacesInContainerLiterals: false | ||
SpacesInLineCommentPrefix: | ||
Minimum: 0 | ||
Maximum: -1 | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Auto | ||
StatementAttributeLikeMacros: | ||
- Q_EMIT | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 2 | ||
UseCRLF: false | ||
UseTab: Never | ||
WhitespaceSensitiveMacros: | ||
- STRINGIZE | ||
- PP_STRINGIZE | ||
- BOOST_PP_STRINGIZE | ||
- NS_SWIFT_NAME | ||
- CF_SWIFT_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[codespell] | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc | ||
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: | ||
ignore-words-list = ba,licence,ot,dout,als,exten,acount,totaly,pasttime | ||
skip = ./.git,./.licenses,__pycache__,.clang-format,.codespellrc,.editorconfig,.flake8,.prettierignore,.yamllint.yml,.gitignore,boards.txt,platform.txt,programmers.txt | ||
builtin = clear,informal,en-GB_to_en-US | ||
check-filenames = | ||
check-hidden = | ||
write-changes = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/general/.editorconfig | ||
# See: https://editorconfig.org/ | ||
# The formatting style defined in this file is the official standardized style to be used in all Arduino Tooling | ||
# projects and should not be modified. | ||
# Note: indent style for each file type is defined even when it matches the universal config in order to make it clear | ||
# that this type has an official style. | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{adoc,asc,asciidoc}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.{bash,sh}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.{c,cc,cp,cpp,cxx,h,hh,hpp,hxx,ii,inl,ino,ixx,pde,tpl,tpp,txx}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.{go,mod}] | ||
indent_style = tab | ||
|
||
[*.java] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.{js,jsx,json,jsonc,json5,ts,tsx}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.{md,mdx,mkdn,mdown,markdown}] | ||
indent_size = unset | ||
indent_style = space | ||
|
||
[*.proto] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.py] | ||
indent_size = 4 | ||
indent_style = space | ||
|
||
[*.svg] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.{yaml,yml}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[{.gitconfig,.gitmodules}] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python/.flake8 | ||
# See: https://flake8.pycqa.org/en/latest/user/configuration.html | ||
# The code style defined in this file is the official standardized style to be used in all Arduino tooling projects and | ||
# should not be modified. | ||
|
||
[flake8] | ||
doctests = True | ||
# W503 and W504 are mutually exclusive. PEP 8 recommends line break before. | ||
ignore = W503,E203 | ||
max-complexity = 10 | ||
max-line-length = 120 | ||
select = E,W,F,C,N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Pre-commit check | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize, labeled] | ||
|
||
jobs: | ||
lint: | ||
if: | | ||
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') | ||
name: Checking if any fixes are needed | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout latest commit | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Set up Python 3 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Get Python version hash | ||
run: | | ||
echo "Using $(python -VV)" | ||
echo "PY_HASH=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV | ||
- name: Restore pre-commit cache | ||
uses: actions/cache/restore@v4 | ||
id: restore-cache | ||
with: | ||
path: | | ||
~/.cache/pre-commit | ||
~/.cache/pip | ||
key: pre-commit|${{ env.PY_HASH }}|${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml') }} | ||
|
||
- name: Install python dependencies | ||
run: python -m pip install pre-commit docutils | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/[email protected] | ||
|
||
- name: Run pre-commit hooks in changed files | ||
run: pre-commit run --color=always --show-diff-on-failure --files ${{ steps.changed-files.outputs.all_changed_files }} | ||
|
||
- name: Save pre-commit cache | ||
uses: actions/cache/save@v4 | ||
if: ${{ always() && steps.restore-cache.outputs.cache-hit != 'true' }} | ||
continue-on-error: true | ||
with: | ||
path: | | ||
~/.cache/pre-commit | ||
~/.cache/pip | ||
key: ${{ steps.restore-cache.outputs.cache-primary-key }} | ||
|
||
- name: Push changes using pre-commit-ci-lite | ||
uses: pre-commit-ci/[email protected] | ||
if: always() | ||
with: | ||
msg: "ci(pre-commit): Apply automatic fixes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.