Skip to content

Commit 546b613

Browse files
committed
[test,ci] add clang-tidy
1 parent e01aaae commit 546b613

File tree

5 files changed

+53
-20
lines changed

5 files changed

+53
-20
lines changed

.clang-tidy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Checks: 'bugprone*,performance*,portability*,
2+
-bugprone-easily-swappable-parameters,-bugprone-forwarding-reference-overload'
3+
4+
FormatStyle: file
5+
WarningsAsErrors: '*'
6+
HeaderFilterRegex: '.*/include/bio/.*'

.github/workflows/ci.yml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,89 +32,98 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
include:
35+
- name: "Unit clang16 + clang-tidy"
36+
cxx: "clang++-16"
37+
cc: "clang-16"
38+
pkg: "clang-16 clang-tidy-16 g++-12"
39+
os: "ubuntu-22.04"
40+
build: clang_tidy
41+
build_type: Debug
42+
3543
- name: "Unit gcc10 Debug"
3644
cxx: "g++-10"
3745
cc: "gcc-10"
46+
pkg: "gcc-10 g++-10"
3847
os: "ubuntu-22.04"
3948
build: unit
4049
build_type: Debug
4150

4251
- name: "Unit gcc11"
4352
cxx: "g++-11"
4453
cc: "gcc-11"
54+
pkg: "gcc-11 g++-11"
4555
os: "ubuntu-22.04"
4656
build: unit
4757
build_type: Release
4858

4959
- name: "Unit gcc12 Debug"
5060
cxx: "g++-12"
5161
cc: "gcc-12"
52-
os: "ubuntu-22.04"
53-
build: unit
54-
build_type: Debug
55-
56-
- name: "Unit Clang-16 Debug"
57-
cxx: "clang++-16"
58-
cc: "clang-16"
62+
pkg: "gcc-12 g++-12"
5963
os: "ubuntu-22.04"
6064
build: unit
6165
build_type: Debug
6266

6367
- name: "Integration gcc12"
6468
cxx: "g++-12"
6569
cc: "gcc-12"
70+
pkg: "gcc-12 g++-12"
6671
os: "ubuntu-22.04"
6772
build: integration
6873
build_type: Debug
6974

7075
- name: "Documentation"
71-
cxx: "doxygen"
72-
cc: "doxygen"
76+
pkg: "doxygen"
7377
os: "ubuntu-22.04"
7478
build: documentation
7579
build_type: Debug
7680

7781
- name: "Clang Format"
78-
cxx: "clang-format-16"
79-
cc: "clang-16"
82+
pkg: "clang-format-16"
8083
os: "ubuntu-22.04"
8184
build: clang_format
8285
build_type: Debug
8386

8487
- name: "Coverage gcc12"
8588
cxx: "g++-12"
8689
cc: "gcc-12"
90+
pkg: "gcc-12 g++-12"
8791
os: "ubuntu-22.04"
8892
build: coverage
8993
build_type: Debug
9094

9195
- name: "Snippet gcc10"
9296
cxx: "g++-10"
9397
cc: "gcc-10"
98+
pkg: "gcc-10 g++-10"
9499
build: snippet
95100
build_type: Debug
96101

97102
- name: "Snippet gcc12"
98103
cxx: "g++-12"
99104
cc: "gcc-12"
105+
pkg: "gcc-12 g++-12"
100106
build: snippet
101107
build_type: Release
102108

103109
- name: "Snippet Clang-16"
104110
cxx: "clang++-16"
105111
cc: "clang-16"
112+
pkg: "clang-16 g++-12"
106113
build: snippet
107114
build_type: Release
108115

109116
- name: "Performance gcc12"
110117
cxx: "g++-12"
111118
cc: "gcc-12"
119+
pkg: "gcc-12 g++-12"
112120
build: performance
113121
build_type: Release
114122

115123
- name: "Header gcc12"
116124
cxx: "g++-12"
117125
cc: "gcc-12"
126+
pkg: "gcc-12 g++-12"
118127
build: header
119128
build_type: Release
120129

@@ -136,7 +145,7 @@ jobs:
136145

137146
- name: Configure APT (llvm)
138147
continue-on-error: true
139-
if: matrix.cc == 'clang-16'
148+
if: contains(matrix.pkg, 'clang')
140149
run: |
141150
sudo apt-add-repository --no-update --yes "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
142151
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
@@ -155,13 +164,8 @@ jobs:
155164
- name: Install ccache
156165
run: sudo apt-get install --yes ccache
157166

158-
- name: Install compiler ${{ matrix.cxx }}
159-
if: matrix.cc != 'clang-16'
160-
run: sudo apt-get install --yes ${{ matrix.cxx }}
161-
162-
- name: Install compiler ${{ matrix.cxx }}
163-
if: matrix.cc == 'clang-16'
164-
run: sudo apt-get install --yes g++-12 ${{ matrix.cc }}
167+
- name: Install compiler/tool ${{ matrix.pkg }}
168+
run: sudo apt-get install --yes ${{ matrix.pkg }}
165169

166170
- name: Install documentation deps
167171
if: matrix.build == 'documentation'
@@ -211,7 +215,7 @@ jobs:
211215
make -k -j2
212216
ccache -sv
213217
- name: Run tests
214-
if: matrix.build != 'coverage'
218+
if: ${{ matrix.build != 'coverage' && matrix.build != 'clang_format' }}
215219
run: |
216220
cd biocpp-core-build
217221
ctest . -j2 --output-on-failure

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Summary: we now support LLVM/clang as a compiler; CIGARs have been much improved
2424
## Maintained
2525

2626
* `bio::ranges::small_string` now satisfies the std::ranges::view-concept for capacities <= 30.
27+
* Clang-tidy is automatically run as part of the CI.
2728

2829
## Renamed
2930

test/biocpp-test.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ file(MAKE_DIRECTORY ${BIOCPP_TEST_CLONE_DIR}/googletest/include/)
5151
# libraries which are in common for **all** bio tests
5252
add_library (biocpp_test INTERFACE)
5353
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
54+
#TODO we should remove and fix "-Wno-unused-variable" "-Wno-unused-local-typedef"
5455
target_compile_options (biocpp_test INTERFACE "-pedantic" "-fsized-deallocation" "-Wall" "-Wextra" "-Werror" "-Wno-missing-braces" "-Wno-unused-variable" "-Wno-unused-local-typedef")
5556
else ()
5657
target_compile_options (biocpp_test INTERFACE "-pedantic" "-Wall" "-Wextra" "-Werror")

test/clang_tidy/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cmake_minimum_required (VERSION 3.10)
2+
3+
### Attention: this runs clang-tidy IN ADDITION to regular unit tests
4+
### Also make sure to set your CXX_COMPILER to clang++
5+
6+
project(biocpp_clang_tidy NONE)
7+
8+
find_program(CLANG_TIDY "clang-tidy-16")
9+
10+
if (CLANG_TIDY STREQUAL "CLANG_TIDY-NOTFOUND")
11+
find_program(CLANG_TIDY "clang-tidy")
12+
endif()
13+
14+
if (NOT CLANG_TIDY STREQUAL "CLANG_TIDY-NOTFOUND")
15+
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY})
16+
add_subdirectory(../unit/ unit)
17+
enable_testing()
18+
else ()
19+
message(FATAL_ERROR "clang-tidy not found. No targets made.")
20+
endif()
21+

0 commit comments

Comments
 (0)