GHA : Add clang-tidy

This commit is contained in:
Magne Sjaastad
2021-04-05 18:33:12 +02:00
parent 77696b6f9d
commit b01569869a

94
.github/workflows/clang-tidy.yml vendored Normal file
View File

@@ -0,0 +1,94 @@
name: clang-tidy
on:
workflow_dispatch:
schedule:
# Once every night
- cron: '0 1 * * * '
jobs:
ResInsight-x64-buildcache:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu 20.04",
os: ubuntu-20.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@v2
with:
submodules: true
- name: Cache Qt
id: cache-qt
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/Qt/
key: ${{ matrix.config.os }}-QtCache-v03
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: 5.9.9
modules: qtscript qtcharts
dir: '${{ github.workspace }}/Qt/'
cached: ${{ steps.cache-qt.outputs.cache-hit }}
- name: Install Linux dependencies
if: "contains( matrix.config.os, 'ubuntu')"
run: sudo apt-get install libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev libhdf5-dev
- name: Set vcpkg's response file path used as part of cache's key.
uses: lukka/set-shell-env@master
with:
VCPKGRESPONSEFILE: ${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}
- name: Run vcpkg
uses: lukka/run-vcpkg@v5
id: runvcpkg
with:
vcpkgArguments: '@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}'
vcpkgDirectory: '${{ github.workspace }}/ThirdParty/vcpkg'
# Ensure the cache key changes any time the content of the response file changes.
appendedCacheKey: ${{ hashFiles(env.VCPKGRESPONSEFILE) }}
- 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 }} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
sudo apt-get install clang-tidy
mv compile_commands.json compile_commands_original.json
python ../scripts/fix_json_database.py compile_commands_original.json >> compile_commands.json
- name: clang-tidy on ApplicationCode/Application
run: |
cd build
run-clang-tidy -fix files ApplicationCode/Application
- name: clang-tidy on ApplicationCode/ProjectDataModel
run: |
cd build
run-clang-tidy -fix files ApplicationCode/ProjectDataModel
- name: clang-tidy on ApplicationCode/ReservoirDataModel
run: |
cd build
run-clang-tidy -fix files ApplicationCode/ReservoirDataModel
- name: clang-tidy on ApplicationCode/Commands
run: |
cd build
run-clang-tidy -fix files ApplicationCode/Commands
- name: clang-tidy on ApplicationCode/GeoMech
run: |
cd build
run-clang-tidy -fix files ApplicationCode/GeoMech
- name: Remove Qt before creating PR
run: |
rm -rf Qt
- uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Fixes by clang-tidy'
title: 'Fixes by clang-tidy'
branch: clang-tidy-patches