Skip to content

Commit

Permalink
ci(clang-format): add clang-format check workflow
Browse files Browse the repository at this point in the history
Signed-off-by: João Peixoto <[email protected]>
  • Loading branch information
joaopeixoto13 committed Oct 24, 2024
1 parent ac32018 commit aa8d439
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
119 changes: 119 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
Language: Cpp
BasedOnStyle: Mozilla
AccessModifierOffset: -2
AlignAfterOpenBracket: DontAlign
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
AlignOperands: DontAlign
AlignTrailingComments:
Kind: Always
OverEmptyLines: 2
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterStruct: false
AfterUnion: false
BeforeElse: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
BreakBeforeInlineASMColon: Never
BreakStringLiterals: true
ColumnLimit: 100
ContinuationIndentWidth: 4
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
IncludeBlocks: Preserve
IndentCaseBlocks: false
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: true
InsertNewlineAtEOF: true
InsertTrailingCommas: None
KeepEmptyLinesAtEOF: false
KeepEmptyLinesAtTheStartOfBlocks: false
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 100
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 10
PenaltyBreakOpenParenthesis: 100
PenaltyBreakString: 100
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 50
PenaltyReturnTypeOnItsOwnLine: 100
PointerAlignment: Left
# Not using QualigierAlignment as it seems only to affect parameter lists, not
# variable declarations. May enable it if this changes in future clang-format
# versions.
# QualifierAlignment: Custom
# QualifierOrder: ['static', 'inline', 'type', 'const', 'volatile']
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: MultipleParentheses
RemoveSemicolon: true
SeparateDefinitionBlocks: Leave
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyBlock: true
SpacesInParens: Custom
SpacesInParensOptions:
InConditionalStatements: false
InEmptyParentheses: false
InCStyleCasts: false
Other: false
SpacesBeforeTrailingComments: 1
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
ForEachMacros: ['list_foreach']
# TODO:
# - IncludeCategories
# - IncludeIsMainRegex
# - IncludeIsMainSourceRegex
...
27 changes: 27 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Clang Format Check

on:
pull_request:
push:
branches:
- main

jobs:
clang-format-check:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code from the repository
- name: Checkout the code
uses: actions/checkout@v3

# Step 2: Install clang-format 20.0.0
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
# Step 3: Run clang-format
- name: Run clang-format check
run: |
FILES_TO_CHECK=$(find . -name "*.c" -o -name "*.h")
clang-format -i $FILES_TO_CHECK --dry-run --Werror

0 comments on commit aa8d439

Please sign in to comment.