Skip to content

Commit

Permalink
add clang/clang-tidy Github-Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhei committed Jun 14, 2024
1 parent ab14d5e commit a982699
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Checks: >
-modernize-use-transparent-functors,
-modernize-use-trailing-return-type,
-modernize-use-nodiscard,
-modernize-return-braced-init-list,
-modernize-type-traits,
-modernize-avoid-c-arrays,
-modernize-concat-nested-namespaces,
use-emplace,
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: clang

on:
push:
branches:
- 'main'
- 'aspect-*'
# pull_request: disable testing of PRs because it is too slow

concurrency:
group: ${{ github.actor }}-${{ github.ref }}
cancel-in-progress: true

env:
OMPI_MCA_btl_base_warn_component_unused: 0
OMPI_MCA_mpi_yield_when_idle: 1
OMPI_MCA_rmaps_base_oversubscribe: 1
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
OMPI_MCA_btl_vader_single_copy_mechanism: none

jobs:
tidy:
# run clang-tidy
name: tidy
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
matrix:
include:
- image: "geodynamics/aspect-tester:noble-dealii-master-clang"
result-file: "clang-tidy-results.txt"
container-options: '--user 0 --name container'

container:
image: ${{ matrix.image }}
options: ${{ matrix.container-options }}

steps:
- uses: actions/checkout@v4
- name: clang-tidy
run: |
mkdir build
cd build
../contrib/utilities/run_clang_tidy.sh $PWD/..
mv output.txt ${{ matrix.result-file }}
- name: compile
run: |
cd build
cmake -D CMAKE_CXX_FLAGS='-Werror' .
make -j 2
- name: test
run: |
cd build
./aspect --test
- name: archive test results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.result-file }}
path: build/${{ matrix.result-file }}
5 changes: 2 additions & 3 deletions contrib/utilities/run_clang_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if test ! -d "$SRC/source" -o ! -d "$SRC/include" -o ! -f "$SRC/CMakeLists.txt"
exit 1
fi

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

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

echo "OK"
exit 0

0 comments on commit a982699

Please sign in to comment.