From ce036f446c2211464223a8f59c468a0c547a7956 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 18 Aug 2021 18:55:33 +0200 Subject: [PATCH] GitHub Action to check for formatting errors. --- .github/workflows/format-check.yml | 60 ++++++++++++++++++++++++++ formatters/build.gradle | 2 +- formatters/cpp.clang-format | 67 ------------------------------ 3 files changed, 61 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/format-check.yml delete mode 100644 formatters/cpp.clang-format diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml new file mode 100644 index 000000000..03e017150 --- /dev/null +++ b/.github/workflows/format-check.yml @@ -0,0 +1,60 @@ +name: Check format + +on: + push: + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - name: Install OS dependencies (needed for act on ubuntu-latest) + run: | + apt update + apt install -y --force-yes curl xz-utils libicu-dev git + + - name: Cache Clang + id: cache-clang + uses: actions/cache@v2 + with: + path: clang + key: ${{ runner.os }}-clang + + - name: Install Clang + if: steps.cache-clang.outputs.cache-hit != 'true' + run: | + curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz --output clang.tar.xz + tar -xf clang.tar.xz + mv clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu- clang + + - name: Install dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "6.0.x" + include-prerelease: true + - run: dotnet tool install -g dotnet-format + + - uses: actions/checkout@v1 + + - name: Install Node and dependenceis + uses: actions/setup-node@v1 + with: + node-version: "16" + - run: npm install -g typescript typescript-formatter + + - name: Install JDK + uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: "16" + + - name: Format + run: | + export PATH=$PATH:`pwd`/clang/bin/ + export PATH="$PATH:/root/.dotnet/tools" + ./formatters/format.sh + + - name: Fail on format changes + run: | + git status --porcelain + if [[ `git status --porcelain` ]]; then echo "detected format changes!" & exit 1; fi \ No newline at end of file diff --git a/formatters/build.gradle b/formatters/build.gradle index 8e7db017f..cd9ad698e 100644 --- a/formatters/build.gradle +++ b/formatters/build.gradle @@ -26,7 +26,7 @@ spotless { 'spine-sfml/**/*.h', 'spine-ue4/**/*.cpp', 'spine-ue4/**/*.h' - clangFormat('12.0.1').style('file') + clangFormat("12.0.1").style('file') } typescript { diff --git a/formatters/cpp.clang-format b/formatters/cpp.clang-format deleted file mode 100644 index 40900c339..000000000 --- a/formatters/cpp.clang-format +++ /dev/null @@ -1,67 +0,0 @@ -# Generated from CLion C/C++ Code Style settings -BasedOnStyle: LLVM -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: None -AlignOperands: Align -AllowAllArgumentsOnNextLine: false -AllowAllConstructorInitializersOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: Always -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: Always -AllowShortLambdasOnASingleLine: All -AllowShortLoopsOnASingleLine: true -AlwaysBreakAfterReturnType: None -AlwaysBreakTemplateDeclarations: Yes -BreakBeforeBraces: Custom -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: Never - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: true -BreakBeforeBinaryOperators: None -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: BeforeColon -BreakInheritanceList: BeforeColon -ColumnLimit: 0 -CompactNamespaces: false -ContinuationIndentWidth: 8 -IndentCaseLabels: true -IndentPPDirectives: None -IndentWidth: 4 -KeepEmptyLinesAtTheStartOfBlocks: true -MaxEmptyLinesToKeep: 2 -NamespaceIndentation: All -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PointerAlignment: Right -ReflowComments: false -SortIncludes: false -SpaceAfterCStyleCast: true -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 0 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -TabWidth: 4 -UseTab: ForContinuationAndIndentation