Static checks #152
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Static checks | |
run-name: Static checks | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
jobs: | |
build-compilation-db: | |
name: Build with IWYU | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true # Recursively clone submodules | |
- name: Add repos | |
run: | | |
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' | |
wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash | |
wget https://apt.llvm.org/llvm-snapshot.gpg.key | |
sudo apt-key add llvm-snapshot.gpg.key | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install \ | |
ninja-build \ | |
iwyu \ | |
clang-16 \ | |
libomp-16-dev \ | |
libopenmpi-dev \ | |
openmpi-bin \ | |
openfoam2406-dev | |
- name: Create Compilation Database | |
run: | | |
source /usr/lib/openfoam/openfoam2406/etc/bashrc || true | |
cmake --preset develop \ | |
-DNEOFOAM_DEVEL_TOOLS=OFF \ | |
-DCMAKE_CXX_COMPILER=clang++-16 \ | |
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
-DNEOFOAM_ENABLE_MPI_WITH_THREAD_SUPPORT=OFF \ | |
-DNEOFOAM_ENABLE_IWYU=ON | |
cmake --build --preset develop | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifact | |
path: build | |
clang-tidy-check: | |
name: Clang-tidy Check | |
runs-on: ubuntu-latest | |
needs: [build-compilation-db] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true # Recursively clone submodules | |
- name: Add repos | |
run: | | |
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' | |
wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash | |
wget https://apt.llvm.org/llvm-snapshot.gpg.key | |
sudo apt-key add llvm-snapshot.gpg.key | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install \ | |
clang-tidy-16 \ | |
libomp-16-dev \ | |
libopenmpi-dev \ | |
openmpi-bin | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build-artifact | |
path: build | |
- name: Run clang-tidy | |
run: | | |
# Create list of .cpp files belonging to this repository | |
git ls-files | grep -E "\.(cpp)" > pattern | |
# Create list of .cpp files that are in this repository and part of the | |
# compilation database | |
# also filters out " at the begin and end of the filename | |
jq ".[] | .file" build/develop/compile_commands.json \ | |
| sed 's/^"\(.*\)"$/\1/' \ | |
| grep -F -f pattern - > files | |
# run clang-tidy on all specified files | |
clang-tidy-16 --fix --extra-arg=-w -p build/develop $(cat files) | |
- name: Check for fixes | |
run: | | |
if [[ $(git ls-files -m | wc -l) -eq 0 ]]; then | |
exit 0 | |
fi | |
echo "There are fixes available from clang-tidy." | |
echo "Please use your local clang-tidy or apply the following patch:" | |
git diff -p | |
exit 1 | |
pre-commit-run: | |
name: Pre-commit run | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true # Recursively clone submodules | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install \ | |
pre-commit | |
pip install identify --upgrade | |
pre-commit install | |
- name: Run pre-commit on all files | |
run: pre-commit run --all --color always --verbose | |
- name: check for todo fixme note | |
run: | | |
NTODOS="$(grep -r 'TODO DONT MERGE' --exclude-dir=.github | wc -l)" | |
echo "Found $NTODOS TODO DONT MERGE notes" | |
! grep -q -r "TODO DONT MERGE" --exclude-dir=.github | |
changelog: | |
name: Changelog check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: dangoslen/changelog-enforcer@v3 | |
with: | |
changeLogPath: CHANGELOG.md |