forked from ripple/validator-keys-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce same clang-format specification as rippled
- Loading branch information
Showing
2 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
Language: Cpp | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: AlwaysBreak | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlinesLeft: true | ||
AlignOperands: false | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterReturnType: All | ||
AlwaysBreakBeforeMultilineStrings: true | ||
AlwaysBreakTemplateDeclarations: true | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BraceWrapping: | ||
AfterClass: true | ||
AfterControlStatement: true | ||
AfterEnum: false | ||
AfterFunction: true | ||
AfterNamespace: false | ||
AfterObjCDeclaration: true | ||
AfterStruct: true | ||
AfterUnion: true | ||
BeforeCatch: true | ||
BeforeElse: true | ||
IndentBraces: false | ||
BreakBeforeBinaryOperators: false | ||
BreakBeforeBraces: Custom | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: true | ||
ColumnLimit: 80 | ||
CommentPragmas: '^ IWYU pragma:' | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
ForEachMacros: [ Q_FOREACH, BOOST_FOREACH ] | ||
IncludeCategories: | ||
- Regex: '^<(BeastConfig)' | ||
Priority: 0 | ||
- Regex: '^<(ripple)/' | ||
Priority: 2 | ||
- Regex: '^<(boost)/' | ||
Priority: 3 | ||
- Regex: '.*' | ||
Priority: 4 | ||
IncludeIsMainRegex: '$' | ||
IndentCaseLabels: true | ||
IndentFunctionDeclarationAfterType: false | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: false | ||
PenaltyBreakBeforeFirstCallParameter: 1 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
PointerAlignment: Left | ||
ReflowComments: true | ||
SortIncludes: true | ||
SpaceAfterCStyleCast: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 2 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Cpp11 | ||
TabWidth: 8 | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: clang-format | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
CLANG_VERSION: 10 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install clang-format | ||
run: | | ||
codename=$( lsb_release --codename --short ) | ||
sudo tee /etc/apt/sources.list.d/llvm.list >/dev/null <<EOF | ||
deb http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-${CLANG_VERSION} main | ||
deb-src http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-${CLANG_VERSION} main | ||
EOF | ||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add | ||
sudo apt-get update | ||
sudo apt-get install clang-format-${CLANG_VERSION} | ||
- name: Format src | ||
run: find src -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i | ||
- name: Check for differences | ||
id: assert | ||
run: | | ||
set -o pipefail | ||
git diff --exit-code | tee "clang-format.patch" | ||
- name: Upload patch | ||
if: failure() && steps.assert.outcome == 'failure' | ||
uses: actions/upload-artifact@v2 | ||
continue-on-error: true | ||
with: | ||
name: clang-format.patch | ||
if-no-files-found: ignore | ||
path: clang-format.patch | ||
- name: What happened? | ||
if: failure() && steps.assert.outcome == 'failure' | ||
env: | ||
PREAMBLE: | | ||
If you are reading this, you are looking at a failed Github Actions | ||
job. That means you pushed one or more files that did not conform | ||
to the formatting specified in .clang-format. That may be because | ||
you neglected to run 'git clang-format' or 'clang-format' before | ||
committing, or that your version of clang-format has an | ||
incompatibility with the one on this | ||
machine, which is: | ||
SUGGESTION: | | ||
To fix it, you can do one of two things: | ||
1. Download and apply the patch generated as an artifact of this | ||
job to your repo, commit, and push. | ||
2. Run 'git-clang-format --extensions c,cpp,h,cxx,ipp develop' | ||
in your repo, commit, and push. | ||
run: | | ||
echo "${PREAMBLE}" | ||
clang-format-${CLANG_VERSION} --version | ||
echo "${SUGGESTION}" | ||
exit 1 |