Skip to content

Commit 08f4a9d

Browse files
authored
Add pre-commit ci (#6)
* adds pre-commit ci * forgot to add .config * more pre-commit * emojis
1 parent c07021f commit 08f4a9d

File tree

6 files changed

+123
-2
lines changed

6 files changed

+123
-2
lines changed

.config/.yamllint.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length:
6+
max: 256
7+
commas: false

.config/clang-format

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
# C++ Formatting rules for WATonomous Standard
3+
4+
# See https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormatStyleOptions.html for documentation of these options
5+
BasedOnStyle: Google
6+
IndentWidth: 2
7+
ColumnLimit: 120
8+
9+
AccessModifierOffset: -2
10+
AlignAfterOpenBracket: AlwaysBreak
11+
AlignConsecutiveAssignments: None
12+
AlignConsecutiveDeclarations: None
13+
AlignEscapedNewlines: Left
14+
AlignTrailingComments: false
15+
AllowAllArgumentsOnNextLine: true
16+
AllowAllParametersOfDeclarationOnNextLine: true
17+
AllowShortBlocksOnASingleLine: Empty
18+
AllowShortFunctionsOnASingleLine: false
19+
BinPackArguments: false
20+
BinPackParameters: false
21+
BraceWrapping:
22+
AfterClass: true
23+
AfterControlStatement: MultiLine
24+
AfterEnum: true
25+
AfterFunction: true
26+
AfterNamespace: true
27+
AfterStruct: true
28+
AfterUnion: true
29+
AfterExternBlock: true
30+
BeforeCatch: false
31+
BeforeElse: false
32+
BeforeLambdaBody: false
33+
BeforeWhile: false
34+
IndentBraces: false
35+
SplitEmptyFunction: false
36+
SplitEmptyRecord: false
37+
SplitEmptyNamespace: false
38+
BreakBeforeBraces: Custom
39+
BreakConstructorInitializers: BeforeComma
40+
CompactNamespaces: false
41+
ContinuationIndentWidth: 2
42+
ConstructorInitializerIndentWidth: 0
43+
DerivePointerAlignment: false
44+
EmptyLineAfterAccessModifier: Never
45+
EmptyLineBeforeAccessModifier: LogicalBlock
46+
FixNamespaceComments: true
47+
IncludeBlocks: Regroup
48+
IncludeCategories:
49+
# Headers in <> with .h extension (best guess at C system headers)
50+
- Regex: '<([A-Za-z0-9\Q/-_\E])+\.h>'
51+
Priority: 1
52+
# Headers in <> without extension (C++ system headers)
53+
- Regex: '<([A-Za-z0-9\Q/-_\E])+>'
54+
Priority: 2
55+
# Headers in <> with other extensions.
56+
- Regex: '<([A-Za-z0-9.\Q/-_\E])+>'
57+
Priority: 3
58+
# Headers in ""
59+
- Regex: '"([A-Za-z0-9.\Q/-_\E])+"'
60+
Priority: 4
61+
IndentAccessModifiers: false
62+
IndentPPDirectives: BeforeHash
63+
PackConstructorInitializers: Never
64+
PointerAlignment: Middle
65+
ReferenceAlignment: Middle
66+
ReflowComments: false
67+
SeparateDefinitionBlocks: Always
68+
SortIncludes: CaseInsensitive
69+
SpacesBeforeTrailingComments: 2

.config/copyright.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright (c) 2025-present WATonomous. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

.cpplint.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ filter=-whitespace/braces
1111
filter=-whitespace/indent
1212
filter=-whitespace/newline
1313
filter=-whitespace/parens
14-
filter=-whitespace/semicolon
14+
filter=-whitespace/semicolon

.github/workflows/pre_commit.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Pre-commit
3+
4+
on:
5+
pull_request:
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
run-pre-commit:
11+
name: ✅ Pre-commit Check
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.x'
20+
21+
- name: Install xmllint dependency
22+
run: |
23+
sudo apt-get update -qq
24+
sudo apt-get install -y --no-install-recommends libxml2-utils
25+
26+
- name: Install pre-commit
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install pre-commit
30+
31+
- name: Run pre-commit hooks
32+
run: pre-commit run --all-files

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ repos:
109109
- id: insert-license
110110
types_or: [c++, c]
111111
name: Copyright headers for C/C++
112-
args: [--license-filepath, .config/copyright.txt, --comment-style, "//", --allow-past-years]
112+
args: [--license-filepath, .config/copyright.txt, --comment-style, "//", --allow-past-years]

0 commit comments

Comments
 (0)