Skip to content

Commit dbb1e24

Browse files
Merge pull request #6 from nevergiveupcpp/ngu/ci
ci: add clang checks (format and tidy)
2 parents 9c60308 + ac1fee4 commit dbb1e24

File tree

7 files changed

+464
-194
lines changed

7 files changed

+464
-194
lines changed

.clang-format

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
Language: Cpp
3+
Standard: c++20
4+
BasedOnStyle: LLVM
5+
6+
IndentWidth: 4
7+
TabWidth: 4
8+
NamespaceIndentation: All
9+
AccessModifierOffset: -4
10+
11+
ColumnLimit: 120
12+
13+
PenaltyReturnTypeOnItsOwnLine: 1000
14+
15+
BinPackParameters: false
16+
BinPackArguments: false
17+
AlignAfterOpenBracket: BlockIndent
18+
19+
AllowShortFunctionsOnASingleLine: None
20+
InsertBraces: true
21+
AllowShortLambdasOnASingleLine: Empty
22+
23+
BreakConstructorInitializers: AfterColon
24+
PackConstructorInitializers: CurrentLine
25+
26+
PointerAlignment: Left
27+
ReferenceAlignment: Left
28+
29+
SpaceAfterTemplateKeyword: false
30+
AlwaysBreakTemplateDeclarations: No
31+
32+
SortIncludes: Never
33+
34+
AlignTrailingComments:
35+
Kind: Always
36+
OverEmptyLines: 2

.clang-tidy

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Checks: >
2+
readability-identifier-naming,
3+
readability-implicit-bool-conversion,
4+
misc-const-correctness,
5+
-clang-diagnostic-error
6+
7+
CheckOptions:
8+
- key: readability-identifier-naming.ClassCase
9+
value: lower_case
10+
- key: readability-identifier-naming.StructCase
11+
value: lower_case
12+
13+
- key: readability-identifier-naming.FunctionCase
14+
value: lower_case
15+
- key: readability-identifier-naming.MethodCase
16+
value: lower_case
17+
- key: readability-identifier-naming.MethodIgnoredRegexp
18+
value: '^[A-Z][A-Z0-9_]*$'
19+
20+
- key: readability-identifier-naming.VariableCase
21+
value: lower_case
22+
- key: readability-identifier-naming.VariableIgnoredRegexp
23+
value: '^[A-Z][A-Z0-9_]*$'
24+
- key: readability-identifier-naming.LocalVariableCase
25+
value: lower_case
26+
- key: readability-identifier-naming.ParameterCase
27+
value: lower_case
28+
29+
- key: readability-identifier-naming.MemberCase
30+
value: lower_case
31+
- key: readability-identifier-naming.MemberIgnoredRegexp
32+
value: '^([A-Z][A-Z0-9_]*|[a-z][a-z0-9_]*_)$'
33+
- key: readability-identifier-naming.PrivateMemberSuffix
34+
value: '_'
35+
- key: readability-identifier-naming.ProtectedMemberSuffix
36+
value: '_'
37+
- key: readability-identifier-naming.ConstantMemberIgnoredRegexp
38+
value: '^[A-Z][A-Z0-9_]*$'
39+
40+
- key: readability-identifier-naming.EnumConstantCase
41+
value: CamelCase
42+
43+
- key: readability-identifier-naming.EnumCase
44+
value: lower_case
45+
46+
- key: readability-identifier-naming.TemplateParameterCase
47+
value: CamelCase
48+
49+
- key: readability-identifier-naming.NamespaceCase
50+
value: lower_case
51+
52+
- key: readability-identifier-naming.TypeAliasCase
53+
value: lower_case
54+
- key: readability-identifier-naming.TypeAliasIgnoredRegexp
55+
value: '^[A-Z]$'

.github/workflows/ci.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,38 @@ jobs:
107107
alert-threshold: '150%'
108108
fail-on-alert: true
109109

110+
clang-format:
111+
name: Clang Format
112+
runs-on: ubuntu-latest
113+
if: github.event_name == 'pull_request'
114+
steps:
115+
- uses: actions/checkout@v4
116+
- name: Check formatting
117+
run: |
118+
find include tests -name "*.h" -o -name "*.cpp" | \
119+
xargs clang-format --dry-run --Werror
120+
121+
clang-tidy:
122+
name: Clang Tidy
123+
runs-on: ubuntu-latest
124+
if: github.event_name == 'pull_request'
125+
steps:
126+
- uses: actions/checkout@v4
127+
- name: Install Clang-Tidy 19
128+
run: |
129+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
130+
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list
131+
sudo apt-get update
132+
sudo apt-get install -y clang-tidy-19
133+
- name: Check tidy
134+
run: |
135+
find include -name "*.h" -o -name "*.cpp" | \
136+
xargs -I{} clang-tidy-19 {} -- -x c++ -std=c++20 -I include -include cstdint -include cstddef
137+
110138
all-checks:
111139
name: All Checks
112140
runs-on: ubuntu-latest
113141
if: github.event_name == 'pull_request'
114-
needs: [unittests]
142+
needs: [unittests, clang-format, clang-tidy]
115143
steps:
116144
- run: echo "All checks passed"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ install/
1818
*.tlog
1919
*.user
2020
*.iml
21-
*.xml
21+
*.xml
22+
*.bat

0 commit comments

Comments
 (0)