Skip to content

Commit c4f586b

Browse files
kvedalafhlasekgithub-actions
authored
[bug fix] fix code formatting in CI (#1052)
* fix: linter and spacing for is_graph_bipartite. * updating DIRECTORY.md * clang-tidy fixes for a49ec9b * use clang-12 * downgrade to clang11 * added clang-format confiug file * added explicit clang-format step in workflow * fix git command * commit format and lint together lint first and then format * corrected order * Revert "Merge branch 'is_graph_bipartite' into fix_clang" This reverts commit d4d4060, reversing changes made to 2ccc3a3. Co-authored-by: Filip Hlásek <[email protected]> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent 63333f3 commit c4f586b

File tree

2 files changed

+172
-11
lines changed

2 files changed

+172
-11
lines changed

.clang-format

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -3
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveMacros: true
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlines: Left
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllArgumentsOnNextLine: true
12+
AllowAllConstructorInitializersOnNextLine: true
13+
AllowAllParametersOfDeclarationOnNextLine: true
14+
AllowShortBlocksOnASingleLine: Never
15+
AllowShortCaseLabelsOnASingleLine: false
16+
AllowShortFunctionsOnASingleLine: All
17+
AllowShortLambdasOnASingleLine: All
18+
AllowShortIfStatementsOnASingleLine: Never
19+
AllowShortLoopsOnASingleLine: true
20+
AlwaysBreakAfterDefinitionReturnType: None
21+
AlwaysBreakAfterReturnType: None
22+
AlwaysBreakBeforeMultilineStrings: true
23+
AlwaysBreakTemplateDeclarations: Yes
24+
BinPackArguments: true
25+
BinPackParameters: true
26+
BraceWrapping:
27+
AfterCaseLabel: false
28+
AfterClass: false
29+
AfterControlStatement: false
30+
AfterEnum: false
31+
AfterFunction: false
32+
AfterNamespace: false
33+
AfterObjCDeclaration: false
34+
AfterStruct: false
35+
AfterUnion: false
36+
AfterExternBlock: false
37+
BeforeCatch: false
38+
BeforeElse: false
39+
IndentBraces: false
40+
SplitEmptyFunction: true
41+
SplitEmptyRecord: true
42+
SplitEmptyNamespace: true
43+
BreakBeforeBinaryOperators: None
44+
BreakBeforeBraces: Attach
45+
BreakBeforeInheritanceComma: false
46+
BreakInheritanceList: BeforeColon
47+
BreakBeforeTernaryOperators: true
48+
BreakConstructorInitializersBeforeComma: false
49+
BreakConstructorInitializers: BeforeColon
50+
BreakAfterJavaFieldAnnotations: false
51+
BreakStringLiterals: true
52+
ColumnLimit: 80
53+
CommentPragmas: '^ IWYU pragma:'
54+
CompactNamespaces: false
55+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
56+
ConstructorInitializerIndentWidth: 4
57+
ContinuationIndentWidth: 4
58+
Cpp11BracedListStyle: true
59+
DeriveLineEnding: true
60+
DerivePointerAlignment: true
61+
DisableFormat: false
62+
ExperimentalAutoDetectBinPacking: false
63+
FixNamespaceComments: true
64+
ForEachMacros:
65+
- foreach
66+
- Q_FOREACH
67+
- BOOST_FOREACH
68+
IncludeBlocks: Regroup
69+
IncludeCategories:
70+
- Regex: '^<ext/.*\.h>'
71+
Priority: 2
72+
SortPriority: 0
73+
- Regex: '^<.*\.h>'
74+
Priority: 1
75+
SortPriority: 0
76+
- Regex: '^<.*'
77+
Priority: 2
78+
SortPriority: 0
79+
- Regex: '.*'
80+
Priority: 3
81+
SortPriority: 0
82+
IncludeIsMainRegex: '([-_](test|unittest))?$'
83+
IncludeIsMainSourceRegex: ''
84+
IndentCaseLabels: true
85+
IndentGotoLabels: true
86+
IndentPPDirectives: None
87+
IndentWidth: 4
88+
IndentWrappedFunctionNames: false
89+
JavaScriptQuotes: Leave
90+
JavaScriptWrapImports: true
91+
KeepEmptyLinesAtTheStartOfBlocks: false
92+
MacroBlockBegin: ''
93+
MacroBlockEnd: ''
94+
MaxEmptyLinesToKeep: 1
95+
NamespaceIndentation: None
96+
ObjCBinPackProtocolList: Never
97+
ObjCBlockIndentWidth: 2
98+
ObjCSpaceAfterProperty: false
99+
ObjCSpaceBeforeProtocolList: true
100+
PenaltyBreakAssignment: 2
101+
PenaltyBreakBeforeFirstCallParameter: 1
102+
PenaltyBreakComment: 300
103+
PenaltyBreakFirstLessLess: 120
104+
PenaltyBreakString: 1000
105+
PenaltyBreakTemplateDeclaration: 10
106+
PenaltyExcessCharacter: 1000000
107+
PenaltyReturnTypeOnItsOwnLine: 200
108+
PointerAlignment: Left
109+
RawStringFormats:
110+
- Language: Cpp
111+
Delimiters:
112+
- cc
113+
- CC
114+
- cpp
115+
- Cpp
116+
- CPP
117+
- 'c++'
118+
- 'C++'
119+
CanonicalDelimiter: ''
120+
BasedOnStyle: google
121+
- Language: TextProto
122+
Delimiters:
123+
- pb
124+
- PB
125+
- proto
126+
- PROTO
127+
EnclosingFunctions:
128+
- EqualsProto
129+
- EquivToProto
130+
- PARSE_PARTIAL_TEXT_PROTO
131+
- PARSE_TEST_PROTO
132+
- PARSE_TEXT_PROTO
133+
- ParseTextOrDie
134+
- ParseTextProtoOrDie
135+
CanonicalDelimiter: ''
136+
BasedOnStyle: google
137+
ReflowComments: true
138+
SortIncludes: true
139+
SortUsingDeclarations: true
140+
SpaceAfterCStyleCast: false
141+
SpaceAfterLogicalNot: false
142+
SpaceAfterTemplateKeyword: true
143+
SpaceBeforeAssignmentOperators: true
144+
SpaceBeforeCpp11BracedList: false
145+
SpaceBeforeCtorInitializerColon: true
146+
SpaceBeforeInheritanceColon: true
147+
SpaceBeforeParens: ControlStatements
148+
SpaceBeforeRangeBasedForLoopColon: true
149+
SpaceInEmptyBlock: false
150+
SpaceInEmptyParentheses: false
151+
SpacesBeforeTrailingComments: 2
152+
SpacesInAngles: false
153+
SpacesInConditionalStatement: false
154+
SpacesInContainerLiterals: true
155+
SpacesInCStyleCastParentheses: false
156+
SpacesInParentheses: false
157+
SpacesInSquareBrackets: false
158+
SpaceBeforeSquareBrackets: false
159+
Standard: Auto
160+
StatementMacros:
161+
- Q_UNUSED
162+
- QT_REQUIRE_VERSION
163+
TabWidth: 4
164+
UseCRLF: false
165+
UseTab: Never
166+
...
167+

.github/workflows/awesome_workflow.yml

+5-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: requirements
1717
run: |
1818
sudo apt -qq -y update
19-
sudo apt -qq install clang-tidy-10
19+
sudo apt -qq install clang-tidy-10 clang-format-10
2020
# checks are passing with less errors when used with this version.
2121
# The default installs v6.0 which did not work out well in my tests
2222
- name: Setup Git Specs
@@ -44,7 +44,7 @@ jobs:
4444
git "mv" "${fname}" ${new_fname}
4545
fi
4646
done
47-
git commit -am "formatting filenames $GITHUB_SHA" || true
47+
git commit -am "formatting filenames ${GITHUB_SHA::8}" || true
4848
4949
- name: Update DIRECTORY.md
5050
shell: python
@@ -124,15 +124,9 @@ jobs:
124124
125125
subprocess.run(["clang-tidy-10", "--fix", "-p=build", "--extra-arg=-std=c++11", *cpp_files, "--"],
126126
check=True, text=True, stderr=subprocess.STDOUT)
127-
# for cpp_file in cpp_files:
128-
# subprocess.run(["clang-tidy-10", "--fix", "-p=build", cpp_file, "--"],
129-
# check=True, text=True, stderr=subprocess.STDOUT)
130127
131-
# print("g++:")
132-
# compile_exts = tuple(".c .c++ .cc .cpp .cu .cxx".split())
133-
# compile_files = [file for file in cpp_files if file.lower().endswith(compile_exts)]
134-
# for cpp_file in cpp_files:
135-
# subprocess.run(["g++", cpp_file], check=True, text=True)
128+
subprocess.run(["clang-format-10", "-i", "-style=file", *cpp_files],
129+
check=True, text=True, stderr=subprocess.STDOUT)
136130
137131
upper_files = [file for file in cpp_files if file != file.lower()]
138132
if upper_files:
@@ -155,7 +149,7 @@ jobs:
155149
- name: Commit and push changes
156150
run: |
157151
git diff DIRECTORY.md
158-
git commit -am "clang-tidy fixes for $GITHUB_SHA" || true
152+
git commit -am "clang-format and clang-tidy fixes for ${GITHUB_SHA::8}" || true
159153
git push --force origin HEAD:$GITHUB_REF || true
160154
161155
build:

0 commit comments

Comments
 (0)