Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add clang/clang-tidy Github-Actions workflow #5908

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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