Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
BasedOnStyle: LLVM
IndentWidth: 4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignOperands: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: true
BinPackParameters: true
ColumnLimit: 100
IndentPPDirectives: AfterHash
MaxEmptyLinesToKeep: 1
PointerAlignment: Right
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
BracedInitializerIndentWidth: 2

# includes
IncludeBlocks: Preserve
SortIncludes: true

# indentation
IndentWidth: 2
TabWidth: 2
UseTab: Never

# if
AllowShortIfStatementsOnASingleLine: true

# case
IndentCaseLabels: false
AllowShortCaseLabelsOnASingleLine: true
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: true
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,24 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: ./build-${{ matrix.pg-version }}/coverage.info

style:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v31.5.1
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Use Cachix Cache
uses: cachix/cachix-action@v16
with:
name: nxpg
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Run style check
run: nix-shell --run "net-style-check"
4 changes: 2 additions & 2 deletions nix/xpg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ let
dep = fetchFromGitHub {
owner = "steve-chavez";
repo = "xpg";
rev = "v1.6.0";
sha256 = "sha256-NsdAmsYIRH/DWIZp93AHGYdPiJOztUIUSYcPikeebvw=";
rev = "v1.8.0";
sha256 = "sha256-ltS2bprvzrmaBjzMmIiSdJh5P3gBV/blzFpYazevv8g=";
};
xpg = import dep;
in
Expand Down
11 changes: 11 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@ mkShell {
psycopg2
sqlalchemy
];
style =
writeShellScriptBin "net-style" ''
${clang-tools}/bin/clang-format -i src/*
'';
styleCheck =
writeShellScriptBin "net-style-check" ''
${clang-tools}/bin/clang-format -i src/*
${git}/bin/git diff-index --exit-code HEAD -- '*.c'
'';
in
[
xpg.xpg
pythonDeps
nginxCustom.nginxScript
curlWithGnuTls
loadtest
style
styleCheck
];
shellHook = ''
export HISTFILE=.history
Expand Down
Loading