Skip to content

Commit

Permalink
Add cpp linter workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeorgakoudis committed Jan 8, 2025
1 parent ec7a39a commit a84e760
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 20 deletions.
26 changes: 26 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming,-misc-include-cleaner,-llvm-header-guard'
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelBack
# Exclude from scanning as this is an exported symbol used for fuzzing
# throughout the code base.
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: "LLVMFuzzerTestOneInput"
- key: readability-identifier-naming.MemberCase
value: CamelCase
- key: readability-identifier-naming.ParameterCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.VariableCase
value: CamelCase
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
value: 1
- key: modernize-use-default-member-init.UseAssignment
value: 1
20 changes: 0 additions & 20 deletions .github/workflows/check-clang-format.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: cpp-linter

on:
pull_request:

jobs:
cpp-linter:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
conda-remove-defaults: true
# Install Clang/LLVM using conda
- name: Create environment
run: |
conda install -y -q -c conda-forge \
clang=18.1.3 \
clangxx=18.1.3 \
llvmdev=18.1.3 \
lit=18.1.3
ln -s ${CONDA_PREFIX}/libexec/llvm/FileCheck ${CONDA_PREFIX}/bin
- name: Run cmake to export compilation database
run: |
mkdir -p build
pushd build
cmake .. \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_EXPORT_COMPILE_COMMANDS=on
- uses: cpp-linter/cpp-linter-action@v2
id: linter
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: 18
ignore: .github | tests | scripts
style: file
tidy-checks: ''
database: build
lines-changed-only: true
format-review: true
tidy-review: true
passive-reviews: true
- name: Check linter status
if: steps.linter.outputs.checks-failed != 0
run: exit 1

0 comments on commit a84e760

Please sign in to comment.