Skip to content

Commit

Permalink
ENH: add clang-tidy checks in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
JJL772 committed Jul 17, 2023
1 parent 460b6d9 commit bd8609c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,cert-*,performance-*'
WarningsAsErrors: '*'
3 changes: 3 additions & 0 deletions .clang-tidy-exclude.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"\\S+registerRecordDeviceDriver.cpp"
]
32 changes: 26 additions & 6 deletions .github/workflows/ci-scripts-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,27 @@ jobs:
- os: ubuntu-20.04
cmp: gcc
configuration: static
extra: "CMD_CXXFLAGS=-std=c++11"
name: "Ub-20 gcc-9 C++11, static"
extra: "CMD_CXXFLAGS=-std=c++14"
name: "clang-tidy checks"
clang-tidy: true

- os: ubuntu-20.04
cmp: gcc
configuration: static
extra: "CMD_CXXFLAGS=-std=c++14"
name: "Ub-20 gcc-9 C++14, static"

- os: ubuntu-20.04
cmp: gcc
configuration: static
extra: "CMD_CXXFLAGS=-std=c++03"
name: "Ub-20 gcc-9 C++03, static"

- os: ubuntu-20.04
cmp: clang
configuration: default
extra: "CMD_CXXFLAGS=-std=c++11"
name: "Ub-20 clang-10 C++11"
extra: "CMD_CXXFLAGS=-std=c++14"
name: "Ub-20 clang-10 C++14"

- os: ubuntu-20.04
cmp: gcc
Expand All @@ -101,7 +114,8 @@ jobs:
- os: ubuntu-20.04
cmp: clang
configuration: default
name: "Ub-20 clang-10"
extra: "CMD_CXXFLAGS=-std=c++03"
name: "Ub-20 clang-10 C++03"

- os: macos-latest
cmp: clang
Expand All @@ -122,7 +136,7 @@ jobs:
- name: "apt-get install"
run: |
sudo apt-get update
sudo apt-get -y install qemu-system-x86 g++-mingw-w64-x86-64 gdb
sudo apt-get -y install qemu-system-x86 g++-mingw-w64-x86-64 gdb bear clang-tidy
if: runner.os == 'Linux'
- name: "apt-get install ${{ matrix.cmp }}"
run: |
Expand All @@ -135,6 +149,12 @@ jobs:
run: python .ci/cue.py prepare
- name: Build main module
run: python .ci/cue.py build
- name: Run clang-tidy
run: |
make clean
bear make -j$(nproc)
python3 clang-tidy.py
if: matrix.clang-tidy
- name: Run main module tests
run: python .ci/cue.py test
- name: Upload tapfiles Artifact
Expand Down
32 changes: 32 additions & 0 deletions clang-tidy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3

import json
import subprocess
import re

if __name__ == '__main__':
exclude = []
with open('.clang-tidy-exclude.json', 'rb') as fp:
exclude = json.load(fp)

assert isinstance(exclude, list)

def is_excluded(file: str) -> bool:
for reg in exclude:
if re.search(reg, file) is not None:
return True
return False

returnCode = 0
files = []
with open('compile_commands.json', 'rb') as fp:
f = json.load(fp)
for cmd in f:
file = cmd['file']
if not is_excluded(file):
files.append(file)
else:
print(f'Skipping {file}')
print(f'Files: {files}')
r = subprocess.run(['run-clang-tidy'] + files)
exit(r.returncode)
6 changes: 0 additions & 6 deletions ek9000App/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ DBD += devEK9000.dbd
DBD += ek9000.dbd
DBD += ek9000Include.dbd

ifneq ($(NO_FORCE_CXX03),1)
USR_CXXFLAGS += -std=c++03
else
USR_CXXFLAGS += -std=c++11
endif

ifeq ($(BUILD_STRICT),1)
USR_CXXFLAGS += -Wunused -Wall -Wextra -Wpedantic -Werror -Wno-deprecated-declarations -Wno-variadic-macros
endif
Expand Down

0 comments on commit bd8609c

Please sign in to comment.