diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000000000000000000000000000000000..19ff63cb42294f1ce5aa49d78a74d82e6141927b --- /dev/null +++ b/.clang-format @@ -0,0 +1,149 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +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 +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + - Regex: '.*' + Priority: 1 + SortPriority: 0 +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: Latest +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE +... + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 07782e9fbfe4f02eb065513195d60ef40a351a0c..5ba0f66c69a47c9ef0fb8794e129c63ca8f5ad58 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,6 +46,13 @@ build-testenv: -t $CI_REGISTRY_IMAGE . - docker push $CI_REGISTRY_IMAGE +# formatting with clang-format +code_style: + tags: [ docker ] + stage: test + script: + - clang-format -n --verbose **/*.c **/*.h **/*.h.in **/*.c.in + allow_failure: true # cmocka tests test: @@ -63,13 +70,10 @@ test: pages: tags: [ docker ] stage: deploy - #only: - #refs: - #- /^release-.*$/i - #- master - #variables: - ## run pages only on gitlab.com - #- $CI_SERVER_HOST == "gitlab.com" + only: + refs: + - /^release-.*$/i + - master script: - mkdir -p build - cd build diff --git a/include/libcaosdbConfig.h.in b/include/libcaosdbConfig.h.in index 158ae0e1204a8b312e95b95aac9025b76a951b5b..2abf00b7d0bd9ceb3316f1d12d904faa4d720a19 100644 --- a/include/libcaosdbConfig.h.in +++ b/include/libcaosdbConfig.h.in @@ -1,3 +1,5 @@ +// clang-format off #define LIBCAOSDB_VERSION_MAJOR @libcaosdb_VERSION_MAJOR@ #define LIBCAOSDB_VERSION_MINOR @libcaosdb_VERSION_MINOR@ #define LIBCAOSDB_VERSION_PATCH @libcaosdb_VERSION_PATCH@ +// clang-format on diff --git a/test/.docker/Dockerfile b/test/.docker/Dockerfile index 5e06fbd0edba0490c5aaf0272baa3201377488c1..b79acda3e92628ec0d6628539997736aa656a20d 100644 --- a/test/.docker/Dockerfile +++ b/test/.docker/Dockerfile @@ -8,3 +8,5 @@ RUN apt-get install -y python3-pip COPY doc/requirements.txt requirements.txt RUN pip3 install -r requirements.txt + +RUN apt-get install -y clang-format diff --git a/test/test_connection.c b/test/test_connection.c index 8ee7520bfb3537d31e5be8ca722d94dc630cae26..2fc5d53f15ee420505a75f6b0e033eb5a04384d3 100644 --- a/test/test_connection.c +++ b/test/test_connection.c @@ -10,7 +10,7 @@ static void test_configure_connection(void **state) { int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(test_configure_connection), + cmocka_unit_test(test_configure_connection), }; return cmocka_run_group_tests(tests, NULL, NULL);