Commit 84f2fb80 authored by Swann Perarnau's avatar Swann Perarnau
Browse files

[ci/style] clang-format style file and CI check step

Introduce a clang-format style to apply clang-format to our current
repo, as well as a CI job that can check the format of modified files in
a branch.
parent c0ce7e25
Pipeline #10219 passed with stages
in 3 minutes and 17 seconds
# Copyright 2019 UChicago Argonne, LLC.
# This file is part of the AML project.
# For more info, see
# SPDX-License-Identifier: BSD-3-Clause
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: true
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Linux
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
IncludeBlocks: Regroup
- Regex: 'config\.h'
Priority: 1
- Regex: 'test.*'
Priority: 1
- Regex: 'aml\.h'
Priority: 3
- Regex: 'aml/.*'
Priority: 4
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '.*'
Priority: 5
IncludeIsMainRegex: 'aml\.h'
IndentCaseLabels: false
IndentWidth: 8
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
PenaltyBreakAssignment: 10
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 8
UseTab: ForIndentation
DEFAULT_MERGE_TARGET: "origin/staging"
- style
......@@ -23,7 +24,7 @@ repoquality:
- .repoquality
stage: style
- /^wip.*/
......@@ -32,9 +33,16 @@ checkpatch:
- nix
- kvm
- nix run -f "$ARGOPKGS" checkpatch --command --ignore TRAILING_SEMICOLON --ignore MULTISTATEMENT_MACRO_USE_DO_WHILE include/aml/utils/inner-malloc.h
- git ls-files '*.c' '*.h' | grep -vE "benchmarks|inner-malloc" >> .checkpatch.conf
- nix run -f "$ARGOPKGS" checkpatch --command
- rm -f clang-format-diff
- target=$(git rev-parse $DEFAULT_MERGE_TARGET)
- nix-shell "$ARGOPKGS" -A ci.aml-format --run "git-clang-format --diff $target > clang-format-diff"
- lint=$(grep -v --color=never "did not modify any files" || true)
- if [ ! -z "$lint" ]; then exit 1; else exit 0; fi
when: on_failure
- ./clang-format-diff
expire_in: 1 week
stage: style
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment