Skip to content

Commit 4b0512f

Browse files
committed
Add cpp-linter action
This uses the same .clang-format as numpy for consistency.
1 parent 7dbd9b6 commit 4b0512f

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.clang-format

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# A clang-format style that approximates Python's PEP 7
2+
# Useful for IDE integration
3+
#
4+
# Based on Paul Ganssle's version at
5+
# https://gist.github.com/pganssle/0e3a5f828b4d07d79447f6ced8e7e4db
6+
# and modified for NumPy
7+
BasedOnStyle: Google
8+
AlignAfterOpenBracket: Align
9+
AllowShortEnumsOnASingleLine: false
10+
AllowShortIfStatementsOnASingleLine: false
11+
AlwaysBreakAfterReturnType: TopLevel
12+
BreakBeforeBraces: Stroustrup
13+
ColumnLimit: 88
14+
ContinuationIndentWidth: 8
15+
DerivePointerAlignment: false
16+
IndentWidth: 4
17+
IncludeBlocks: Regroup
18+
IncludeCategories:
19+
- Regex: '^[<"](Python|structmember|pymem)\.h'
20+
Priority: -3
21+
CaseSensitive: true
22+
- Regex: '^"numpy/'
23+
Priority: -2
24+
- Regex: '^"(npy_pycompat|npy_config)'
25+
Priority: -1
26+
- Regex: '^"[[:alnum:]_.]+"'
27+
Priority: 1
28+
- Regex: '^<[[:alnum:]_.]+"'
29+
Priority: 2
30+
Language: Cpp
31+
PointerAlignment: Right
32+
ReflowComments: true
33+
SpaceBeforeParens: ControlStatements
34+
SpacesInParentheses: false
35+
StatementMacros: [PyObject_HEAD, PyObject_VAR_HEAD, PyObject_HEAD_EXTRA]
36+
TabWidth: 4
37+
UseTab: Never

.github/workflows/cpp-linter.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: cpp-linter
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- "npsr/*"
9+
10+
jobs:
11+
cpp-linter:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
15+
- uses: cpp-linter/cpp-linter-action@f91c446a32ae3eb9f98fef8c9ed4c7cb613a4f8a
16+
id: linter
17+
continue-on-error: true
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
style: "file"
22+
23+
- name: Linter Outputs
24+
if: steps.linter.outputs.checks-failed != 0
25+
run: exit 1

0 commit comments

Comments
 (0)