Skip to content

Commit 7e8e525

Browse files
committed
[ci] Add basic github actions infrastructure
1 parent b412d66 commit 7e8e525

File tree

6 files changed

+428
-0
lines changed

6 files changed

+428
-0
lines changed

.clang-format

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: Google
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlinesLeft: true
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: All
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakBeforeMultilineStrings: true
20+
AlwaysBreakTemplateDeclarations: true
21+
BinPackArguments: true
22+
BinPackParameters: true
23+
BraceWrapping:
24+
AfterClass: false
25+
AfterControlStatement: false
26+
AfterEnum: false
27+
AfterFunction: false
28+
AfterNamespace: false
29+
AfterObjCDeclaration: false
30+
AfterStruct: false
31+
AfterUnion: false
32+
BeforeCatch: false
33+
BeforeElse: false
34+
IndentBraces: false
35+
BreakBeforeBinaryOperators: None
36+
BreakBeforeBraces: Attach
37+
BreakBeforeTernaryOperators: true
38+
BreakConstructorInitializersBeforeComma: false
39+
BreakAfterJavaFieldAnnotations: false
40+
BreakStringLiterals: true
41+
ColumnLimit: 80
42+
CommentPragmas: '^ IWYU pragma:'
43+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
44+
ConstructorInitializerIndentWidth: 4
45+
ContinuationIndentWidth: 4
46+
Cpp11BracedListStyle: true
47+
DerivePointerAlignment: true
48+
DisableFormat: false
49+
ExperimentalAutoDetectBinPacking: false
50+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
51+
IncludeCategories:
52+
- Regex: '^<.*\.h>'
53+
Priority: 1
54+
- Regex: '^<.*'
55+
Priority: 2
56+
- Regex: '.*'
57+
Priority: 3
58+
IncludeIsMainRegex: '([-_](test|unittest))?$'
59+
IndentCaseLabels: true
60+
IndentWidth: 2
61+
IndentWrappedFunctionNames: false
62+
JavaScriptQuotes: Leave
63+
JavaScriptWrapImports: true
64+
KeepEmptyLinesAtTheStartOfBlocks: false
65+
MacroBlockBegin: ''
66+
MacroBlockEnd: ''
67+
MaxEmptyLinesToKeep: 1
68+
NamespaceIndentation: None
69+
ObjCBlockIndentWidth: 2
70+
ObjCSpaceAfterProperty: false
71+
ObjCSpaceBeforeProtocolList: false
72+
PenaltyBreakBeforeFirstCallParameter: 1
73+
PenaltyBreakComment: 300
74+
PenaltyBreakFirstLessLess: 120
75+
PenaltyBreakString: 1000
76+
PenaltyExcessCharacter: 1000000
77+
PenaltyReturnTypeOnItsOwnLine: 200
78+
PointerAlignment: Left
79+
ReflowComments: true
80+
SortIncludes: true
81+
SpaceAfterCStyleCast: false
82+
SpaceBeforeAssignmentOperators: true
83+
SpaceBeforeParens: ControlStatements
84+
SpaceInEmptyParentheses: false
85+
SpacesBeforeTrailingComments: 2
86+
SpacesInAngles: false
87+
SpacesInContainerLiterals: true
88+
SpacesInCStyleCastParentheses: false
89+
SpacesInParentheses: false
90+
SpacesInSquareBrackets: false
91+
Standard: Auto
92+
TabWidth: 8
93+
UseTab: Never
94+
...
95+

.clang-tidy

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
Checks: >
2+
-*,
3+
bugprone-*,
4+
clang-diagnostic-*,
5+
clang-analyzer-*,
6+
concurrency-*,
7+
cppcoreguidelines-*,
8+
llvm-*,
9+
misc-*,
10+
modernize-*,
11+
openmp-*
12+
performance-*,
13+
portability-*,
14+
readability-*
15+
16+
CheckOptions:
17+
- key: google-readability-braces-around-statements.ShortStatementLines
18+
value: '1'
19+
- key: google-readability-function-size.StatementThreshold
20+
value: '800'
21+
- key: google-readability-namespace-comments.ShortNamespaceLines
22+
value: '10'
23+
- key: google-readability-namespace-comments.SpacesBeforeComments
24+
value: '2'
25+
26+
- key: readability-identifier-naming.AbstractClassCase
27+
value: CamelCase
28+
- key: readability-identifier-naming.ClassCase
29+
value: CamelCase
30+
- key: readability-identifier-naming.ClassConstantCase
31+
value: CamelCase
32+
- key: readability-identifier-naming.ClassConstantPrefix
33+
value: 'k'
34+
- key: readability-identifier-naming.ClassConstantSuffix
35+
value: ''
36+
- key: readability-identifier-naming.ClassMemberCase
37+
value: lower_case
38+
- key: readability-identifier-naming.ClassMemberPrefix
39+
value: ''
40+
- key: readability-identifier-naming.ClassMemberSuffix
41+
value: '_'
42+
- key: readability-identifier-naming.ConstantCase
43+
value: CamelCase
44+
- key: readability-identifier-naming.ConstantPrefix
45+
value: 'k'
46+
- key: readability-identifier-naming.ConstantSuffix
47+
value: ''
48+
- key: readability-identifier-naming.ConstexprFunctionCase
49+
value: CamelCase
50+
- key: readability-identifier-naming.ConstexprMethodCase
51+
value: CamelCase
52+
- key: readability-identifier-naming.ConstexprVariableCase
53+
value: CamelCase
54+
- key: readability-identifier-naming.ConstexprVariablePrefix
55+
value: 'k'
56+
- key: readability-identifier-naming.EnumCase
57+
value: CamelCase
58+
- key: readability-identifier-naming.EnumConstantCase
59+
value: CamelCase
60+
- key: readability-identifier-naming.EnumConstantPrefix
61+
value: 'k'
62+
- key: readability-identifier-naming.EnumConstantSuffix
63+
value: ''
64+
- key: readability-identifier-naming.FunctionCase
65+
value: CamelCase
66+
- key: readability-identifier-naming.GlobalConstantCase
67+
value: CamelCase
68+
- key: readability-identifier-naming.GlobalConstantPrefix
69+
value: 'g'
70+
- key: readability-identifier-naming.GlobalFunctionCase
71+
value: CamelCase
72+
- key: readability-identifier-naming.GlobalVariableCase
73+
value: CamelCase
74+
- key: readability-identifier-naming.GlobalVariablePrefix
75+
value: 'g'
76+
- key: readability-identifier-naming.InlineNamespaceCase
77+
value: lower_case
78+
- key: readability-identifier-naming.LocalConstantCase
79+
value: lower_case
80+
- key: readability-identifier-naming.LocalConstantPrefix
81+
value: ''
82+
- key: readability-identifier-naming.LocalVariableCase
83+
value: lower_case
84+
- key: readability-identifier-naming.MemberCase
85+
value: lower_case
86+
- key: readability-identifier-naming.MemberPrefix
87+
value: ''
88+
- key: readability-identifier-naming.MemberSuffix
89+
value: '_'
90+
- key: readability-identifier-naming.ConstantMemberCase
91+
value: CamelCase
92+
- key: readability-identifier-naming.ConstantMemberPrefix
93+
value: 'k'
94+
- key: readability-identifier-naming.PrivateMemberPrefix
95+
value: ''
96+
- key: readability-identifier-naming.ProtectedMemberPrefix
97+
value: ''
98+
- key: readability-identifier-naming.PublicMemberCase
99+
value: lower_case
100+
- key: readability-identifier-naming.MethodCase
101+
value: CamelCase
102+
- key: readability-identifier-naming.PrivateMethodPrefix
103+
value: ''
104+
- key: readability-identifier-naming.ProtectedMethodPrefix
105+
value: ''
106+
- key: readability-identifier-naming.NamespaceCase
107+
value: lower_case
108+
- key: readability-identifier-naming.ParameterCase
109+
value: lower_case
110+
- key: readability-identifier-naming.ParameterPrefix
111+
value: ''
112+
- key: readability-identifier-naming.ConstantParameterCase
113+
value: lower_case
114+
- key: readability-identifier-naming.ConstantParameterPrefix
115+
value: ''
116+
- key: readability-identifier-naming.ParameterPackCase
117+
value: lower_case
118+
- key: readability-identifier-naming.PureFunctionCase
119+
value: CamelCase
120+
- key: readability-identifier-naming.PureMethodCase
121+
value: CamelCase
122+
- key: readability-identifier-naming.StaticVariableCase
123+
value: CamelCase
124+
- key: readability-identifier-naming.StaticVariablePrefix
125+
value: 'k'
126+
- key: readability-identifier-naming.StructCase
127+
value: CamelCase
128+
- key: readability-identifier-naming.TemplateParameterCase
129+
value: CamelCase
130+
- key: readability-identifier-naming.TemplateTemplateParameterCase
131+
value: CamelCase
132+
- key: readability-identifier-naming.TemplateUsingCase
133+
value: CamelCase
134+
- key: readability-identifier-naming.TemplateUsingPrefix
135+
value: ''
136+
- key: readability-identifier-naming.TypeTemplateParameterCase
137+
value: CamelCase
138+
- key: readability-identifier-naming.TypeTemplateParameterSuffix
139+
value: ''
140+
- key: readability-identifier-naming.TypedefCase
141+
value: CamelCase
142+
- key: readability-identifier-naming.UnionCase
143+
value: CamelCase
144+
- key: readability-identifier-naming.UnionPrefix
145+
value: ''
146+
- key: readability-identifier-naming.UsingCase
147+
value: CamelCase
148+
- key: readability-identifier-naming.ValueTemplateParameterCase
149+
value: CamelCase
150+
- key: readability-identifier-naming.VariableCase
151+
value: lower_case
152+
- key: readability-identifier-naming.VirtualMethodCase
153+
value: CamelCase
154+
- key: readability-identifier-naming.VirtualMethodPrefix
155+
value: ''
156+
- key: readability-identifier-naming.IgnoreFailedSplit
157+
value: 0

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
name: ${{ matrix.compiler }}
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
compiler: [gcc, clang]
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: 3.11
29+
30+
- name: Install dependencies
31+
run: |
32+
sudo apt-get update
33+
if [ "${{ matrix.compiler }}" = "gcc" ]; then
34+
sudo apt-get install -y gcc g++ cmake make
35+
echo "CC=gcc" >> $GITHUB_ENV
36+
echo "CXX=g++" >> $GITHUB_ENV
37+
else
38+
sudo apt-get install -y clang cmake make
39+
echo "CC=clang" >> $GITHUB_ENV
40+
echo "CXX=clang++" >> $GITHUB_ENV
41+
fi
42+
43+
- name: Configure project
44+
run: |
45+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
46+
47+
- name: Build project
48+
run: |
49+
cmake --build build -- -j$(nproc)
50+
51+
- name: Run tests
52+
run: |
53+
ctest --test-dir build --output-on-failure

.github/workflows/clang-format.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: clang-format
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**/*.h'
7+
- '**/*.cpp'
8+
- '**/*.cc'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
precheckin:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout PR branch
19+
uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.event.pull_request.head.sha }}
22+
fetch-depth: 0
23+
24+
- name: Install clang-format
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y clang-format-18
28+
clang-format-18 --version
29+
30+
- name: Run git-clang-format
31+
run: |
32+
PR_BASE=$(git rev-list ${{ github.event.pull_request.head.sha }} ^${{ github.event.pull_request.base.sha }} | tail --lines 1 | xargs -I {} git rev-parse {}~1)
33+
echo "Running git clang-format against $PR_BASE commit"
34+
if ! git -c color.ui='always' -c diff.wsErrorHighlight='all' -c color.diff.whitespace='red reverse' \
35+
clang-format-18 --diff --binary clang-format-18 $PR_BASE; then
36+
echo "::error::Code is not properly formatted. Please run 'git clang-format-18 HEAD~' locally. \n
37+
for multiple commits we should place the formatting changes in the related commit with:\n
38+
\t\tgit rebase -i -x 'git-clang-format-18 master && git commit -a --allow-empty --fixup=HEAD' --strategy-option=theirs origin/master\n
39+
\t\t Then inspect the results with: git log --oneline\n
40+
\t\t Then squash without poluting the history with: git rebase --autosquash -i master\n"
41+
exit 1
42+
fi
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Post clang-tidy review comments
2+
3+
on:
4+
workflow_run:
5+
workflows: ["clang-tidy-review"]
6+
types:
7+
- completed
8+
9+
permissions:
10+
checks: write
11+
pull-requests: write
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Post review comments
23+
id: post-review
24+
uses: ZedThree/clang-tidy-review/[email protected]
25+
with:
26+
max_comments: 10
27+
28+
# If there are any comments, fail the check
29+
- if: steps.post-review.outputs.total_comments > 0
30+
run: exit 1

0 commit comments

Comments
 (0)