Skip to content

Commit a982699

Browse files
committed
add clang/clang-tidy Github-Actions workflow
1 parent ab14d5e commit a982699

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

.clang-tidy

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Checks: >
4949
-modernize-use-transparent-functors,
5050
-modernize-use-trailing-return-type,
5151
-modernize-use-nodiscard,
52+
-modernize-return-braced-init-list,
53+
-modernize-type-traits,
5254
-modernize-avoid-c-arrays,
5355
-modernize-concat-nested-namespaces,
5456
use-emplace,

.github/workflows/clang.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: clang
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'aspect-*'
8+
# pull_request: disable testing of PRs because it is too slow
9+
10+
concurrency:
11+
group: ${{ github.actor }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
OMPI_MCA_btl_base_warn_component_unused: 0
16+
OMPI_MCA_mpi_yield_when_idle: 1
17+
OMPI_MCA_rmaps_base_oversubscribe: 1
18+
OMPI_ALLOW_RUN_AS_ROOT: 1
19+
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
20+
OMPI_MCA_btl_vader_single_copy_mechanism: none
21+
22+
jobs:
23+
tidy:
24+
# run clang-tidy
25+
name: tidy
26+
runs-on: [ubuntu-latest]
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- image: "geodynamics/aspect-tester:noble-dealii-master-clang"
32+
result-file: "clang-tidy-results.txt"
33+
container-options: '--user 0 --name container'
34+
35+
container:
36+
image: ${{ matrix.image }}
37+
options: ${{ matrix.container-options }}
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
- name: clang-tidy
42+
run: |
43+
mkdir build
44+
cd build
45+
../contrib/utilities/run_clang_tidy.sh $PWD/..
46+
mv output.txt ${{ matrix.result-file }}
47+
- name: compile
48+
run: |
49+
cd build
50+
cmake -D CMAKE_CXX_FLAGS='-Werror' .
51+
make -j 2
52+
- name: test
53+
run: |
54+
cd build
55+
./aspect --test
56+
- name: archive test results
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: ${{ matrix.result-file }}
60+
path: build/${{ matrix.result-file }}

contrib/utilities/run_clang_tidy.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if test ! -d "$SRC/source" -o ! -d "$SRC/include" -o ! -f "$SRC/CMakeLists.txt"
5454
exit 1
5555
fi
5656

57-
if ! [ -x "$(command -v run-clang-tidy.py)" ] || ! [ -x "$(command -v clang++)" ]; then
57+
if ! [ -x "$(command -v run-clang-tidy)" ] || ! [ -x "$(command -v clang++)" ]; then
5858
echo "Error: Either the 'run-clang-tidy.py' or the 'clang++' program could not be found."
5959
echo " Make sure 'clang', 'clang++', and 'run-clang-tidy.py' (part of clang) are in the path."
6060
exit 2
@@ -81,7 +81,7 @@ CC=clang CXX=clang++ cmake "${ARGS[@]}" "$SRC" || (echo "cmake failed!"; false)
8181
# finally run it:
8282
# pipe away stderr (just contains nonsensical "x warnings generated")
8383
# pipe output to output.txt
84-
run-clang-tidy.py -p . -quiet -header-filter="$SRC/include/*" 2>error.txt >output.txt
84+
run-clang-tidy -p . -quiet -header-filter="$SRC/include/*" 2>error.txt >output.txt
8585

8686
if grep -E -q '(warning|error): ' output.txt; then
8787
grep -E '(warning|error): ' output.txt
@@ -90,4 +90,3 @@ fi
9090

9191
echo "OK"
9292
exit 0
93-

0 commit comments

Comments
 (0)