Skip to content
Merged
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
106 changes: 106 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
# Configuration for clang-format
# Based on Google C++ Style Guide with some modifications

BasedOnStyle: Google

# Indentation
IndentWidth: 4
TabWidth: 4
UseTab: Never
ContinuationIndentWidth: 4

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true

# Allow putting parameters of a function declaration onto the next line
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true

# Breaking
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true

# Braces
BreakBeforeBraces: Attach
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true

# Spacing
ColumnLimit: 100
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH

# Include sorting
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: "^<.*"
Priority: 2
- Regex: ".*"
Priority: 3
IncludeIsMainRegex: "([-_](test|unittest))?$"
IndentCaseLabels: true
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
67 changes: 67 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
# Configuration for clang-tidy
Checks: >
*,
-abseil-*,
-altera-*,
-android-*,
-fuchsia-*,
-google-*,
-llvm*,
-zircon-*,
-readability-else-after-return,
-readability-static-accessed-through-instance,
-readability-avoid-const-params-in-decls,
-readability-identifier-length,
-cppcoreguidelines-non-private-member-variables-in-classes,
-misc-non-private-member-variables-in-classes,
-modernize-use-trailing-return-type,
-modernize-avoid-c-arrays,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-hicpp-no-array-decay,
-cppcoreguidelines-avoid-magic-numbers,
-readability-magic-numbers,
-cert-err34-c,
-bugprone-easily-swappable-parameters,
-readability-function-cognitive-complexity,
-cert-err58-cpp,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-avoid-non-const-global-variables,
-misc-use-anonymous-namespace,
-bugprone-exception-escape,
-cppcoreguidelines-avoid-const-or-ref-data-members

# Exclude Google Test and external dependencies from analysis
HeaderFilterRegex: "^(?!.*(gtest|googletest|gmock|third_party|external|vendor|/opt/homebrew/)).*"

CheckOptions:
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelBack
- key: readability-identifier-naming.VariableCase
value: camelBack
- key: readability-identifier-naming.PrivateMemberSuffix
value: _
- key: readability-identifier-naming.ProtectedMemberSuffix
value: _
- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
- key: readability-identifier-naming.EnumConstantCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.GlobalConstantCase
value: CamelCase
- key: readability-identifier-naming.MemberConstantCase
value: CamelCase
- key: readability-identifier-naming.StaticConstantCase
value: CamelCase
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: true
47 changes: 47 additions & 0 deletions .github/workflows/linter-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: C++ Linter

on: # yamllint disable-line rule:truthy
push:
branches: ["main"]

jobs:
lint-cpp:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential clang-format \
clang-tidy cppcheck

- name: Install Google Test (required for compilation flags)
run: |
# Install Google Test from source - most reliable approach
git clone https://github.com/google/googletest.git --depth 1
cd googletest
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON
make -j$(nproc)
sudo make install
sudo ldconfig

- name: Debug Google Test configuration
run: make debug-gtest

- name: Lint C++ code using Makefile
run: |
make lint-cpp

- name: Format check C++ code using Makefile
run: |
make format-cpp
# Check if any files were modified by formatting
if ! git diff --exit-code; then
echo "Code formatting issues found. Please run 'make \
format-cpp' locally."
exit 1
fi
41 changes: 41 additions & 0 deletions .github/workflows/linter-py.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Python Linter

on: # yamllint disable-line rule:truthy
push:
branches: ["main"]

jobs:
lint-python:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Lint Python code using Makefile
run: |
make lint-python

- name: Format check Python code using Makefile
run: |
make format-python
# Check if any files were modified by formatting
if ! git diff --exit-code; then
echo "Code formatting issues found. Please run 'make \
format-python' locally."
exit 1
fi
40 changes: 40 additions & 0 deletions .github/workflows/postsubmit-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Postsubmit (C++)

on: # yamllint disable-line rule:truthy
push:
branches: ["main"]

jobs:
test-cpp:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential

- name: Install Google Test
run: |
# Install Google Test from source - most reliable approach
git clone https://github.com/google/googletest.git --depth 1
cd googletest
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON
make -j$(nproc)
sudo make install
sudo ldconfig

- name: Debug Google Test configuration
run: make debug-gtest

- name: Run all C++ tests using Makefile
run: |
make test-cpp:all

- name: Show project statistics
run: |
make stats
35 changes: 35 additions & 0 deletions .github/workflows/postsubmit-py.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Postsubmit (Python)

on: # yamllint disable-line rule:truthy
push:
branches: ["main"]

jobs:
test-python:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run all Python tests using Makefile
run: |
make test-py:all

- name: Show project statistics
run: |
make stats
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ jobs:
with:
fetch-depth: 0 # Fetch full history for git diff

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential clang-format clang-tidy
# Install Google Test from source - most reliable approach
git clone https://github.com/google/googletest.git --depth 1
cd googletest
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON
make -j$(nproc)
sudo make install
sudo ldconfig

- name: Debug Google Test configuration
run: make debug-gtest

- name: Detect changed C++ files
id: detect-changes
run: |
Expand Down Expand Up @@ -89,9 +73,29 @@ jobs:
[ -n "$COMMON_CHANGES" ] && echo 'true' || echo 'false')" >> \
$GITHUB_OUTPUT

- name: Format C++ code
if: steps.detect-changes.outputs.has_cpp_changes == 'true'
run: make format-cpp
- name: Install dependencies
if: >
steps.detect-changes.outputs.has_cpp_changes == 'true' ||
steps.detect-changes.outputs.has_cpp_config_changes == 'true' ||
steps.detect-changes.outputs.has_common_changes == 'true'
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential clang-format clang-tidy
# Install Google Test from source - most reliable approach
git clone https://github.com/google/googletest.git --depth 1
cd googletest
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON
make -j$(nproc)
sudo make install
sudo ldconfig

- name: Debug Google Test configuration
if: >
steps.detect-changes.outputs.has_cpp_changes == 'true' ||
steps.detect-changes.outputs.has_cpp_config_changes == 'true' ||
steps.detect-changes.outputs.has_common_changes == 'true'
run: make debug-gtest

- name: Lint C++ code
if: steps.detect-changes.outputs.has_cpp_changes == 'true'
Expand Down
Loading