From b0f5a93dc93b8a76f2052c12bb141665778c11e7 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Mon, 20 May 2024 15:50:44 -0700 Subject: [PATCH] Add clang format to action --- .clang-format | 58 +++++++++++++++++++++++++++++++++++++ .github/workflows/check.yml | 27 ++++++++++------- 2 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f93f79b --- /dev/null +++ b/.clang-format @@ -0,0 +1,58 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -4 +ConstructorInitializerIndentWidth: 4 +AlignEscapedNewlinesLeft: false +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AlwaysBreakTemplateDeclarations: true +AlwaysBreakBeforeMultilineStrings: false +BreakBeforeBinaryOperators: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BinPackParameters: true +ColumnLimit: 80 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +DerivePointerAlignment: false +ExperimentalAutoDetectBinPacking: false +IndentCaseLabels: false +IndentWrappedFunctionNames: false +IndentFunctionDeclarationAfterType: false +MaxEmptyLinesToKeep: 1 +KeepEmptyLinesAtTheStartOfBlocks: true +NamespaceIndentation: None +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakString: 1000 +PenaltyBreakFirstLessLess: 120 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +SpacesBeforeTrailingComments: 1 +Cpp11BracedListStyle: true +Standard: Cpp11 +IndentWidth: 4 +TabWidth: 4 +UseTab: Never +BreakBeforeBraces: Attach +SpacesInParentheses: false +SpacesInAngles: false +SpaceInEmptyParentheses: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: true +SpaceBeforeAssignmentOperators: true +ContinuationIndentWidth: 4 +CommentPragmas: '^ IWYU pragma:' +ForEachMacros: [ Q_FOREACH, BOOST_FOREACH ] +SpaceBeforeParens: ControlStatements +DisableFormat: false +SortIncludes: true +... + diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a1cd71f..b503192 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,5 +1,4 @@ name: CI - on: push: branches: @@ -7,10 +6,21 @@ on: pull_request: branches: - master - jobs: + clang-format: + name: Check clang-format + runs-on: ubuntu-latest + container: archlinux:latest + steps: + - name: Install dependencies + run: | + pacman -Syu --noconfirm git clang diffutils + git config --global --add safe.directory $GITHUB_WORKSPACE + - uses: actions/checkout@v4 + - uses: fcitx/github-actions@clang-format check: name: Build and test + needs: clang-format runs-on: ubuntu-latest container: archlinux:latest strategy: @@ -37,20 +47,15 @@ jobs: uses: actions/cache@v4 with: path: 'fcitx5/**/*.tar.*' - key: ${{ runner.os }}-${{ hashFiles('fcitx5/src/modules/spell/CMakeLists.txt') }} + key: ${{ runner.os }}-${{ hashFiles('fcitx5/src/modules/spell/CMakeLists.txt') + }} - name: Build and Install fcitx5 uses: fcitx/github-actions@cmake with: path: fcitx5 cmake-option: >- - -DENABLE_KEYBOARD=Off - -DENABLE_X11=Off - -DENABLE_WAYLAND=Off - -DENABLE_ENCHANT=Off - -DENABLE_DBUS=Off - -DENABLE_SERVER=Off - -DENABLE_EMOJI=Off - -DUSE_SYSTEMD=Off + -DENABLE_KEYBOARD=Off -DENABLE_X11=Off -DENABLE_WAYLAND=Off -DENABLE_ENCHANT=Off + -DENABLE_DBUS=Off -DENABLE_SERVER=Off -DENABLE_EMOJI=Off -DUSE_SYSTEMD=Off - uses: actions/checkout@v4 with: repository: fcitx/libime