Skip to content

Cleanup

Cleanup #1993

name: Static Code Analysis
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
env:
INEXOR_VULKAN_SDK_VERSION: "1.3.283.0"
INEXOR_VULKAN_SDK_PATH: "${{ github.workspace }}/vulkan_sdk"
# Cancel CI workflows which are still running from previous pushes
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
clang-tidy:
name: clang-tidy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set build date
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
BUILD_DATE=$(date +'%Y-%b-%d_%H-%M-%S')
BUILD_VERSION="${SHORT_SHA}_${BUILD_DATE}"
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt-get install -y \
gcc-14 \
g++-14 \
clang-18 \
clang-tidy \
cmake \
curl \
git \
libgl1-mesa-dev \
libwayland-dev \
libx11-dev \
libx11-xcb-dev \
libxkbcommon-dev \
libxcb-dri3-dev \
libxcb-icccm4-dev \
libxcb-image0-dev \
libxcb-keysyms1-dev \
libxcb-randr0-dev \
libxcb-render-util0-dev \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-sync-dev \
libxcb-util-dev \
libxcb-xfixes0-dev \
libxcb-xinerama0-dev \
libxcb-xkb-dev \
lld \
ninja-build \
pkg-config \
python3 \
python3-pip \
xkb-data \
xorg-dev
pip3 install --break-system-packages wheel setuptools
- name: Load Vulkan SDK from Cache
id: cache-vulkan-sdk
uses: actions/cache@v4
with:
path: ${{ env.INEXOR_VULKAN_SDK_PATH }}
key: vulkan-sdk-${{ env.INEXOR_VULKAN_SDK_VERSION }}-${{ runner.os }}
- name: Download Vulkan SDK
if: steps.cache-vulkan-sdk.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.INEXOR_VULKAN_SDK_PATH }}
wget -O vulkansdk.tar.xz https://sdk.lunarg.com/sdk/download/${{ env.INEXOR_VULKAN_SDK_VERSION }}/linux/vulkan-sdk.tar.xz
tar -xJf vulkansdk.tar.xz -C ${{ env.INEXOR_VULKAN_SDK_PATH }}
- name: Load CMake Setup from Cache
id: cache-cmake
uses: actions/cache@v4
with:
path: build
key: cmake-${{ runner.os }}-clang-tidy-${{ hashFiles('CMakeLists.txt', '**/CMakeLists.txt', '**/*.cmake') }}
- name: Configure CMake
if: steps.cache-cmake.outputs.cache-hit != 'true'
run: |
rm -rf ${{ env.INEXOR_VULKAN_SDK_PATH }}/${{ env.INEXOR_VULKAN_SDK_VERSION }}/x86_64/lib/cmake/volk/
export CC=${{ matrix.config.cc }}
export CXX=${{ matrix.config.cxx }}
export VULKAN_SDK="${{ env.INEXOR_VULKAN_SDK_PATH }}/${{ env.INEXOR_VULKAN_SDK_VERSION }}/x86_64"
export PATH=$VULKAN_SDK/bin:$PATH
export LD_LIBRARY_PATH=$VULKAN_SDK/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export VK_LAYER_PATH=$VULKAN_SDK/share/vulkan/explicit_layer.d
cmake . \
-Bbuild \
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
-DVULKAN_SDK=$VULKAN_SDK \
-DINEXOR_BUILD_BENCHMARKS=OFF \
-DINEXOR_BUILD_TESTS=OFF \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_FLAGS="-Wall -Wextra" \
-GNinja \
${{ matrix.config.cmake_configure_options }}
- name: Check the files found for clang-tidy
run: |
find example src include \
-path '*/_deps/*' -prune -o \
-path '*/build/*' -prune -o \
\( -name '*.cpp' -o -name '*.hpp' \) -print
- name: Run clang-tidy
run: |
find example src include \
-path '*/_deps/*' -prune -o \
-path '*/build/*' -prune -o \
\( -name '*.cpp' -o -name '*.hpp' \) -print0 |
parallel -0 clang-tidy -p build {} |
tee clang-tidy_analysis.txt || true
- name: Summarize clang-tidy warnings
run: |
grep -hEo '\[[a-z0-9]+-[a-z0-9-]+\]' clang-tidy_analysis.txt \
| sort | uniq -c | sort -nr \
| sed 's/[][]//g' || true
- name: Upload clang-tidy results
uses: actions/upload-artifact@v4
with:
name: Nightly_Linux_StaticCodeAnalysis_clang-tidy_${{ env.BUILD_VERSION }}
path: clang-tidy_analysis.txt
clang-scan-build:
name: scan-build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set build date
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
BUILD_DATE=$(date +'%Y-%b-%d_%H-%M-%S')
BUILD_VERSION="${SHORT_SHA}_${BUILD_DATE}"
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt-get install -y \
clang-18 \
clang-tools-18 \
cmake \
ninja-build \
git \
python3 \
python3-pip \
libgl1-mesa-dev \
libwayland-dev \
libx11-dev \
libx11-xcb-dev \
libxkbcommon-dev \
libxcb-dri3-dev \
libxcb-icccm4-dev \
libxcb-image0-dev \
libxcb-keysyms1-dev \
libxcb-randr0-dev \
libxcb-render-util0-dev \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-sync-dev \
libxcb-util-dev \
libxcb-xfixes0-dev \
libxcb-xinerama0-dev \
libxcb-xkb-dev \
xkb-data \
xorg-dev
pip3 install --break-system-packages wheel setuptools
- name: Load Vulkan SDK from Cache
id: cache-vulkan-sdk
uses: actions/cache@v4
with:
path: ${{ env.INEXOR_VULKAN_SDK_PATH }}
key: vulkan-sdk-${{ env.INEXOR_VULKAN_SDK_VERSION }}-${{ runner.os }}
- name: Download Vulkan SDK
if: steps.cache-vulkan-sdk.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.INEXOR_VULKAN_SDK_PATH }}
wget -O vulkansdk.tar.xz https://sdk.lunarg.com/sdk/download/${{ env.INEXOR_VULKAN_SDK_VERSION }}/linux/vulkan-sdk.tar.xz
tar -xJf vulkansdk.tar.xz -C ${{ env.INEXOR_VULKAN_SDK_PATH }}
- name: Configure CMake
run: |
export CC=clang-18
export CXX=clang++-18
export VULKAN_SDK="${{ env.INEXOR_VULKAN_SDK_PATH }}/${{ env.INEXOR_VULKAN_SDK_VERSION }}/x86_64"
export PATH=$VULKAN_SDK/bin:$PATH
export LD_LIBRARY_PATH=$VULKAN_SDK/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export VK_LAYER_PATH=$VULKAN_SDK/share/vulkan/explicit_layer.d
cmake . \
-Bbuild-scan-build \
-DCMAKE_BUILD_TYPE=Debug \
-DVULKAN_SDK=$VULKAN_SDK \
-DINEXOR_BUILD_BENCHMARKS=OFF \
-DINEXOR_BUILD_TESTS=OFF \
-GNinja
- name: Run scan-build
run: |
mkdir -p clang-scan-build-report
scan-build-18 \
-o clang-scan-build-report \
cmake --build build-scan-build -- -j$(nproc) 2>&1 | tee scan-build-summary.txt
- name: Upload Clang Scan-Build Report
uses: actions/upload-artifact@v4
with:
name: Nightly_Linux_StaticCodeAnalysis_scan-build_${{ env.BUILD_VERSION }}
path: |
clang-scan-build-report
scan-build-summary.txt
cppcheck:
name: cppcheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set build date
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
BUILD_DATE=$(date +'%Y-%b-%d_%H-%M-%S')
BUILD_VERSION="${SHORT_SHA}_${BUILD_DATE}"
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt-get install -y \
gcc-14 \
g++-14 \
clang-18 \
clang-tidy \
cmake \
cppcheck \
curl \
git \
libgl1-mesa-dev \
libwayland-dev \
libx11-dev \
libx11-xcb-dev \
libxkbcommon-dev \
libxcb-dri3-dev \
libxcb-icccm4-dev \
libxcb-image0-dev \
libxcb-keysyms1-dev \
libxcb-randr0-dev \
libxcb-render-util0-dev \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-sync-dev \
libxcb-util-dev \
libxcb-xfixes0-dev \
libxcb-xinerama0-dev \
libxcb-xkb-dev \
lld \
ninja-build \
pkg-config \
python3 \
python3-pip \
xkb-data \
xorg-dev
pip3 install --break-system-packages wheel setuptools
- name: Load Vulkan SDK from Cache
id: cache-vulkan-sdk
uses: actions/cache@v4
with:
path: ${{ env.INEXOR_VULKAN_SDK_PATH }}
key: vulkan-sdk-${{ env.INEXOR_VULKAN_SDK_VERSION }}-${{ runner.os }}
- name: Download Vulkan SDK
if: steps.cache-vulkan-sdk.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.INEXOR_VULKAN_SDK_PATH }}
wget -O vulkansdk.tar.xz https://sdk.lunarg.com/sdk/download/${{ env.INEXOR_VULKAN_SDK_VERSION }}/linux/vulkan-sdk.tar.xz
tar -xJf vulkansdk.tar.xz -C ${{ env.INEXOR_VULKAN_SDK_PATH }}
- name: Load CMake Setup from Cache
id: cache-cmake
uses: actions/cache@v4
with:
path: build
key: cmake-${{ runner.os }}-cppcheck-${{ hashFiles('CMakeLists.txt', '**/CMakeLists.txt', '**/*.cmake') }}
- name: Configure CMake
if: steps.cache-cmake.outputs.cache-hit != 'true'
run: |
rm -rf ${{ env.INEXOR_VULKAN_SDK_PATH }}/${{ env.INEXOR_VULKAN_SDK_VERSION }}/x86_64/lib/cmake/volk/
export CC=${{ matrix.config.cc }}
export CXX=${{ matrix.config.cxx }}
export VULKAN_SDK="${{ env.INEXOR_VULKAN_SDK_PATH }}/${{ env.INEXOR_VULKAN_SDK_VERSION }}/x86_64"
export PATH=$VULKAN_SDK/bin:$PATH
export LD_LIBRARY_PATH=$VULKAN_SDK/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export VK_LAYER_PATH=$VULKAN_SDK/share/vulkan/explicit_layer.d
cmake . \
-Bbuild \
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
-DVULKAN_SDK=$VULKAN_SDK \
-DINEXOR_BUILD_BENCHMARKS=OFF \
-DINEXOR_BUILD_TESTS=OFF \
-DCMAKE_CXX_FLAGS="-Wall -Wextra" \
-GNinja \
${{ matrix.config.cmake_configure_options }}
- name: Find source files for cppcheck
id: find_sources
run: |
find example src include \
-path '*/_deps/*' -prune -o \
-path '*/build/*' -prune -o \
\( -name '*.cpp' -o -name '*.hpp' \) -print > source_files.txt
cat source_files.txt
- name: Run cppcheck on source_files.txt
run: |
# Use xargs to run cppcheck on all files listed in source_files.txt
xargs -a source_files.txt cppcheck \
--enable=all \
--inconclusive \
--force \
--suppress=missingIncludeSystem \
--inline-suppr \
2> cppcheck_output.txt || true
- name: Summarize cppcheck warnings
run: |
cat cppcheck_output.txt | sort | uniq -c | sort -nr || true
- name: Upload cppcheck results
uses: actions/upload-artifact@v4
with:
name: Nightly_Linux_StaticCodeAnalysis_cppcheck_${{ env.BUILD_VERSION }}
path: cppcheck_output.txt
windows:
name: msvc ${{ matrix.config.name }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
config:
- {
name: "Debug",
compiler: "msvc",
cc: "cl",
cxx: "cl",
cmake_configure_options: '-G "Visual Studio 17 2022" -A x64',
build_type: "Debug",
cmake_build_options: "--config Debug"
}
- {
name: "Release",
compiler: "msvc",
cc: "cl",
cxx: "cl",
cmake_configure_options: '-G "Visual Studio 17 2022" -A x64',
build_type: "Release",
cmake_build_options: "--config Release"
}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Update Environment
run: pip3 install wheel setuptools
- name: Set Build Date
run: |
$shortSha = git rev-parse --short HEAD
$buildDate = Get-Date -Format 'yyyy-MMM-dd_HH-mm-ss'
$buildVersion = "${shortSha}_$buildDate"
echo "BUILD_VERSION=$buildVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Check Cache for Vulkan SDK
id: cache-vulkan
uses: actions/cache@v4
with:
path: ${{ env.INEXOR_VULKAN_SDK_PATH }}
key: vulkan-sdk-${{ env.INEXOR_VULKAN_SDK_VERSION }}-${{ runner.os }}
- name: Download Vulkan SDK
if: steps.cache-vulkan.outputs.cache-hit != 'true'
run: |
curl -LS -o vulkansdk.exe https://sdk.lunarg.com/sdk/download/${{ env.INEXOR_VULKAN_SDK_VERSION }}/windows/VulkanSDK-${{ env.INEXOR_VULKAN_SDK_VERSION }}-Installer.exe
7z x -y vulkansdk.exe -o"${{ env.INEXOR_VULKAN_SDK_PATH }}"
- name: Check Cache for CMake Files (Static Code Analysis)
id: cache-cmake-analysis
uses: actions/cache@v4
with:
path: build-analysis
key: cmake-analysis-${{ matrix.config.compiler }}-${{ matrix.config.build_type }}-${{ hashFiles('CMakeLists.txt', '**/CMakeLists.txt', '**/*.cmake') }}
- name: Configure CMake (Static Code Analysis)
if: steps.cache-cmake-analysis.outputs.cache-hit != 'true'
run: |
$env:CC="${{ matrix.config.cc }}"
$env:CXX="${{ matrix.config.cxx }}"
$env:Path += ";${{ env.INEXOR_VULKAN_SDK_PATH }}\;${{ env.INEXOR_VULKAN_SDK_PATH }}\Bin\"
$env:VULKAN_SDK="${{ env.INEXOR_VULKAN_SDK_PATH }}"
cmake . `
-Bbuild-analysis `
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} `
-DINEXOR_BUILD_BENCHMARKS=ON `
-DINEXOR_BUILD_TESTS=ON `
-DCMAKE_CXX_FLAGS=/analyze `
${{ matrix.config.cmake_configure_options }}
- name: Run MSVC Static Code Analysis
run: |
cmake --build build-analysis --target inexor-vulkan-renderer --config ${{ matrix.config.build_type }} > msvc_code_analysis_${{ matrix.config.build_type }}.txt 2>&1 || true
cmake --build build-analysis --target inexor-vulkan-renderer-example --config ${{ matrix.config.build_type }} >> msvc_code_analysis_${{ matrix.config.build_type }} 2>&1 || true
cmake --build build-analysis --target inexor-vulkan-renderer-tests --config ${{ matrix.config.build_type }} >> msvc_code_analysis_${{ matrix.config.build_type }} 2>&1 || true
cmake --build build-analysis --target inexor-vulkan-renderer-benchmarks --config ${{ matrix.config.build_type }} >> msvc_code_analysis_${{ matrix.config.build_type }} 2>&1 || true
- name: Upload Static Analysis Report
uses: actions/upload-artifact@v4
with:
name: Nightly_Windows_StaticCodeAnalysis_${{ matrix.config.compiler }}_${{ matrix.config.build_type }}_${{ env.BUILD_VERSION}}
path: msvc_code_analysis_${{ matrix.config.build_type }}
retention-days: 60