Skip to content

Commit 3dac34f

Browse files
committed
refactor: use clang-format style
You can run this with: ```bash net-style ``` The style is also checked on CI.
1 parent f387fc2 commit 3dac34f

File tree

12 files changed

+529
-476
lines changed

12 files changed

+529
-476
lines changed

.clang-format

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1-
BasedOnStyle: LLVM
2-
IndentWidth: 4
1+
AlignAfterOpenBracket: Align
2+
AlignConsecutiveAssignments: true
3+
AlignConsecutiveDeclarations: true
4+
AlignOperands: true
5+
AllowAllParametersOfDeclarationOnNextLine: false
6+
AllowShortFunctionsOnASingleLine: Empty
7+
AllowShortLoopsOnASingleLine: false
8+
AlwaysBreakAfterDefinitionReturnType: None
9+
AlwaysBreakAfterReturnType: None
10+
AlwaysBreakBeforeMultilineStrings: false
11+
BinPackArguments: true
12+
BinPackParameters: true
13+
ColumnLimit: 100
14+
IndentPPDirectives: AfterHash
15+
MaxEmptyLinesToKeep: 1
16+
PointerAlignment: Right
17+
SpaceBeforeAssignmentOperators: true
18+
SpaceBeforeParens: ControlStatements
19+
SpaceInEmptyParentheses: false
20+
SpacesBeforeTrailingComments: 1
21+
BracedInitializerIndentWidth: 2
22+
23+
# includes
24+
IncludeBlocks: Preserve
25+
SortIncludes: true
26+
27+
# indentation
28+
IndentWidth: 2
29+
TabWidth: 2
30+
UseTab: Never
31+
32+
# if
33+
AllowShortIfStatementsOnASingleLine: true
34+
35+
# case
36+
IndentCaseLabels: false
37+
AllowShortCaseLabelsOnASingleLine: true
38+
AlignConsecutiveShortCaseStatements:
39+
Enabled: true
40+
AcrossEmptyLines: true
41+
AcrossComments: true
42+
AlignCaseColons: true

.github/workflows/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,24 @@ jobs:
105105
with:
106106
github-token: ${{ secrets.GITHUB_TOKEN }}
107107
files: ./build-${{ matrix.pg-version }}/coverage.info
108+
109+
style:
110+
111+
runs-on: ubuntu-latest
112+
113+
steps:
114+
- uses: actions/checkout@v4
115+
116+
- name: Install Nix
117+
uses: cachix/[email protected]
118+
with:
119+
nix_path: nixpkgs=channel:nixos-unstable
120+
121+
- name: Use Cachix Cache
122+
uses: cachix/cachix-action@v16
123+
with:
124+
name: nxpg
125+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
126+
127+
- name: Run style check
128+
run: nix-shell --run "net-style-check"

shell.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,24 @@ mkShell {
1414
psycopg2
1515
sqlalchemy
1616
];
17+
style =
18+
writeShellScriptBin "net-style" ''
19+
${clang-tools}/bin/clang-format -i src/*
20+
'';
21+
styleCheck =
22+
writeShellScriptBin "net-style-check" ''
23+
${clang-tools}/bin/clang-format -i src/*
24+
${git}/bin/git diff-index --exit-code HEAD -- '*.c'
25+
'';
1726
in
1827
[
1928
xpg.xpg
2029
pythonDeps
2130
nginxCustom.nginxScript
2231
curlWithGnuTls
2332
loadtest
33+
style
34+
styleCheck
2435
];
2536
shellHook = ''
2637
export HISTFILE=.history

0 commit comments

Comments
 (0)