clang-tidy #918
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: clang-tidy | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
paths: | |
- '**.clang-tidy' | |
workflow_dispatch: | |
schedule: | |
# Once every night | |
- cron: "0 1 * * *" | |
jobs: | |
ResInsight-x64-buildcache: | |
runs-on: ${{ matrix.config.os }} | |
continue-on-error: true | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Ubuntu 22.04", | |
os: ubuntu-22.04, | |
cc: "gcc", | |
cxx: "g++", | |
vcpkg-response-file: vcpkg_x64-linux.txt, | |
vcpkg-triplet: x64-linux, | |
cmake-toolchain: "ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake", | |
} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install Linux dependencies | |
if: ${{contains( matrix.config.os, 'ubuntu') }} | |
run: | | |
sudo apt-get update --option="APT::Acquire::Retries=3" | |
sudo apt-get install --option="APT::Acquire::Retries=3" libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev libhdf5-dev | |
sudo apt-get install clang-tidy-15 clang-format-15 | |
- name: Install Qt | |
uses: jurplel/install-qt-action@v3 | |
with: | |
version: 5.12.12 | |
modules: qtscript | |
dir: "${{ github.workspace }}/Qt/" | |
cache: true | |
- name: Run vcpkg | |
uses: lukka/run-vcpkg@v7 | |
id: runvcpkg | |
with: | |
vcpkgArguments: "@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}" | |
vcpkgDirectory: | |
"${{ github.workspace }}/ThirdParty/vcpkg" | |
- name: Create compile commands and run clang-tidy | |
# https://clang.llvm.org/extra/doxygen/run-clang-tidy_8py_source.html | |
run: | | |
mkdir build | |
cd build | |
cmake -DCMAKE_TOOLCHAIN_FILE=${{ matrix.config.cmake-toolchain }} -DRESINSIGHT_USE_OPENMP=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. | |
mv compile_commands.json compile_commands_original.json | |
python ../scripts/fix_json_database.py compile_commands_original.json >> compile_commands.json | |
- name: Run clang-tidy and apply fixes, clang-format after fixes | |
run: | | |
cd build | |
run-clang-tidy-15 -fix files ApplicationLibCode/Application ApplicationLibCode/ProjectDataModel ApplicationLibCode/ReservoirDataModel ApplicationLibCode/Commands ApplicationLibCode/GeoMech | |
- name: Run clang-format after clang-tidy | |
run: | | |
cd build/ApplicationLibCode | |
find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | xargs clang-format-15 -i | |
- name: Remove Qt before creating PR | |
run: | | |
rm -rf Qt | |
cd ThirdParty/vcpkg | |
git reset --hard HEAD | |
git clean -fxd | |
- uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "Fixes by clang-tidy" | |
title: "Fixes by clang-tidy" | |
branch: clang-tidy-patches | |
branch-suffix: random |