mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 15:41:00 -05:00
Replace the vcpkg-cache action, whose post step saves even when the job fails or is cancelled, with actions/cache/restore and a save step that only runs after a successful configure.
106 lines
3.9 KiB
YAML
106 lines
3.9 KiB
YAML
name: clang-tidy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
paths:
|
|
- '**.clang-tidy'
|
|
workflow_dispatch:
|
|
schedule:
|
|
# Once every night
|
|
- cron: "0 1 * * *"
|
|
|
|
env:
|
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
|
|
|
jobs:
|
|
ResInsight-clang-tidy:
|
|
runs-on: ubuntu-26.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Install Linux dependencies
|
|
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-19 clang-format-19
|
|
|
|
- name: Install Qt
|
|
uses: CeetronSolutions/install-qt-action@bump-node24
|
|
with:
|
|
version: 6.7.0
|
|
dir: "${{ github.workspace }}/Qt/"
|
|
cache: true
|
|
modules: "qtnetworkauth"
|
|
|
|
- name: vcpkg bootstrap
|
|
run: ThirdParty/vcpkg/bootstrap-vcpkg.sh
|
|
|
|
- name: Get vcpkg submodule SHA
|
|
id: vcpkg-sha
|
|
shell: bash
|
|
run: echo "sha=$(git rev-parse HEAD:ThirdParty/vcpkg)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Restore vcpkg cache
|
|
id: vcpkg-cache
|
|
# Restore only; saved after a successful configure so partial caches are never written.
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: ${{ github.workspace }}/.vcpkg-cache
|
|
key: vcpkg-${{ runner.os }}-clang-tidy-19-${{ steps.vcpkg-sha.outputs.sha }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
|
|
|
|
- name: Create compile commands and run clang-tidy
|
|
# https://clang.llvm.org/extra/doxygen/run-clang-tidy_8py_source.html
|
|
env:
|
|
VCPKG_FEATURE_FLAGS: "binarycaching" # Possibly redundant, but explicitly sets the binary caching feature flag
|
|
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite"
|
|
run: |
|
|
mkdir build
|
|
cd build
|
|
cmake \
|
|
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
|
|
-DVCPKG_HOST_TRIPLET=x64-linux-release \
|
|
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
|
-DCMAKE_C_COMPILER=clang-19 \
|
|
-DCMAKE_CXX_COMPILER=clang++-19 \
|
|
-DRESINSIGHT_USE_OPENMP=OFF \
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
|
-DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake \
|
|
..
|
|
- name: Save vcpkg cache
|
|
if: success() && steps.vcpkg-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v6
|
|
with:
|
|
path: ${{ github.workspace }}/.vcpkg-cache
|
|
key: ${{ steps.vcpkg-cache.outputs.cache-primary-key }}
|
|
- name: Run clang-tidy and apply fixes
|
|
continue-on-error: true
|
|
run: |
|
|
cd build
|
|
# The path regex excludes generated files (moc/qrc) under build/, which are listed in
|
|
# compile_commands.json but not produced when the project is only configured, not built.
|
|
run-clang-tidy-19 -config-file ../ApplicationLibCode/.clang-tidy -fix '^(?!.*/build/).*(files|ApplicationLibCode)'
|
|
run-clang-tidy-19 -config-file ../GrpcInterface/.clang-tidy -fix '^(?!.*/build/).*(files|GrpcInterface)'
|
|
- name: Run clang-format after clang-tidy
|
|
continue-on-error: true
|
|
run: |
|
|
cd ApplicationLibCode
|
|
find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | xargs clang-format-19 -i
|
|
cd ../GrpcInterface
|
|
find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | xargs clang-format-19 -i
|
|
- uses: peter-evans/create-pull-request@v8
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
commit-message: "Fixes by clang-tidy"
|
|
title: "Fixes by clang-tidy"
|
|
branch: clang-tidy-patches
|
|
branch-suffix: random
|
|
add-paths: |
|
|
ApplicationLibCode/*
|
|
GrpcInterface/*
|