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
98 changes: 98 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
AccessModifierOffset: -2
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyNamespace: true
SplitEmptyRecord: true
BreakAfterJavaFieldAnnotations: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializersBeforeComma: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: true
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Priority: 2
Regex: ^"(llvm|llvm-c|clang|clang-c)/
- Priority: 3
Regex: ^(<|"(gtest|gmock|isl|json)/)
- Priority: 1
Regex: .*
IncludeIsMainRegex: (Test)?$
IndentCaseLabels: false
IndentWidth: 2
IndentWrappedFunctionNames: true
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
Language: Cpp
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: Inner
ObjCBlockIndentWidth: 7
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++20
TabWidth: 8
UseTab: Never

17 changes: 17 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
Checks: >-
bugprone-*,
cert-*,
clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-modernize-use-trailing-return-type,
-readability-identifier-length
WarningsAsErrors: '*'
CheckOptions:
readability-function-size.LineThreshold: 30
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7
161 changes: 158 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,174 @@ on:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
check-tests:
name: check-tests (${{ matrix.platform.os }}, ${{ matrix.platform.compiler }}, ${{ matrix.build_type }}, sanitizers ${{ matrix.sanitizers }})
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { os: ubuntu-24.04, compiler: gcc, cxx: g++, python-version: "3.10", analyzers: -DCPP_EXTRA_ANALYSIS_ENABLE_CPPCHECK=ON }
- { os: ubuntu-24.04, compiler: clang, cxx: clang++, python-version: "3.14", analyzers: -DCPP_EXTRA_ANALYSIS_ENABLE_CLANG_TIDY=ON }
- { os: macos-15, compiler: appleclang, cxx: c++, python-version: "3.12", analyzers: "" }
build_type: [Debug, Release]
sanitizers: ["ON", "OFF"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.platform.python-version }}

- name: Install analysis tools (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends clang-tools clang-tidy cppcheck

- name: Install analysis tools (macOS)
if: runner.os == 'macOS'
run: |
brew install llvm cppcheck
echo "CMAKE_PROGRAM_PATH=$(brew --prefix llvm)/bin" >> "$GITHUB_ENV"
echo "SDKROOT=$(xcrun --show-sdk-path)" >> "$GITHUB_ENV"

- name: Configure
env:
CXX: ${{ matrix.platform.cxx }}
BUILD_TYPE: ${{ matrix.build_type }}
SANITIZERS: ${{ matrix.sanitizers }}
ANALYZERS: ${{ matrix.platform.analyzers }}
run: >
cmake -S . -B build
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DCPP_EXTRA_ANALYSIS_ENABLE_SANITIZERS="$SANITIZERS"
-DCPP_EXTRA_ANALYSIS_REQUIRE_TOOLS=ON
${ANALYZERS:+"$ANALYZERS"}

- name: Build
run: cmake --build build --parallel

- name: Test
run: ctest --test-dir build --output-on-failure

coverage:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Install analysis tools
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.14"

- name: Install tools
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends clang-tools cppcheck
python -m pip install coverage==7.17.2 gcovr==8.8

- name: Configure
run: cmake -S . -B build -DCPP_EXTRA_ANALYSIS_REQUIRE_TOOLS=ON
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCPP_EXTRA_ANALYSIS_ENABLE_COVERAGE=ON -DCPP_EXTRA_ANALYSIS_REQUIRE_TOOLS=ON

- name: Build
run: cmake --build build --parallel

- name: Test
run: ctest --test-dir build --output-on-failure

- name: Python branch coverage
run: |
python -W error -m coverage run --branch --source=tools,tests -m unittest discover -s tests
python -m coverage report --show-missing

- name: C++ branch coverage
run: gcovr --root . --filter checks/ --txt-metric branch build

lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.14"

- name: Install tools
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends clang-format
python -m pip install ruff==0.17.4 mypy==2.4.1 lizard==1.25.0 actionlint-py==1.7.12.25 zizmor==1.32.0 pip-audit==2.10.1

- name: Check C++ formatting
run: git ls-files -z '*.cpp' '*.hpp' | xargs -0 clang-format --dry-run -Werror

- name: Check Python formatting
run: ruff format --check .

- name: Lint Python
run: ruff check .

- name: Type check Python
run: mypy .

- name: Limit function length
run: lizard --length 30 --warnings_only tools tests checks

- name: Detect copy-paste
run: npx --yes jscpd@5.4.2 --exit-code 1 --ignore ".github/**" .

- name: Lint GitHub Actions
run: |
actionlint
zizmor .github

- name: Audit Python tools
run: pip-audit

secret-scanning:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- uses: trufflesecurity/trufflehog@ea68ca03c865c5f324e86e849ced20ed3cf9dbbb # v3.99.8
with:
extra_args: --results=verified,unknown

project-validator:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: cpp-best-practices/project_validator
ref: main
path: project_validator
persist-credentials: false

- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.14"

- name: Install validator dependencies
run: python -m pip install "PyYAML>=6.0"

- name: Validate project
working-directory: project_validator
run: python -m project_validator --build --exclude project_validator ${{ github.workspace }}
46 changes: 46 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: codeql

on:
push:
branches: [main]
pull_request:
schedule:
- cron: "17 4 * * 1"

permissions:
contents: read

jobs:
analyze:
name: analyze (${{ matrix.language }})
runs-on: ubuntu-24.04
permissions:
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
include:
- { language: actions, build-mode: none }
- { language: c-cpp, build-mode: manual }
- { language: python, build-mode: none }
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
queries: security-and-quality

- name: Build
if: matrix.build-mode == 'manual'
run: |
cmake -S . -B build
cmake --build build --parallel

- uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
with:
category: /language:${{ matrix.language }}
36 changes: 36 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: scorecard

on:
push:
branches: [main]
schedule:
- cron: "41 5 * * 1"

permissions: read-all

jobs:
analysis:
runs-on: ubuntu-24.04
permissions:
security-events: write
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0
with:
results_file: results.sarif
results_format: sarif
publish_results: true

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: scorecard-results
path: results.sarif
retention-days: 5

- uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
with:
sarif_file: results.sarif
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/build/
/build-*/
/out/
__pycache__/
*.py[cod]
/.venv/
/.coverage
/.mypy_cache/
/.ruff_cache/
/project_validator/
Loading
Loading