name: Static Analysis on: push: branches: [main] paths: - 'include/**' - 'src/**' - 'tests/**' - '.clang-tidy' pull_request: branches: [main] paths: - 'include/**' - 'src/**' - 'tests/**' - '.clang-tidy' schedule: - cron: '0 3 * * 1' # 每周一凌晨3点全量扫描 workflow_dispatch: # 手动触发 jobs: clang-tidy: name: clang-tidy scan (GCC 11.4) runs-on: ubuntu-22.04 container: image: vde-builder:latest options: --cpus=2 --memory=8g steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 1 - name: Install clang-tidy run: | apt-get update -qq apt-get install -y -qq clang-tidy-15 - name: Generate compile_commands.json run: | cmake -B build_analysis \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DBUILD_TESTS=ON \ -DBUILD_EXAMPLES=OFF \ -DBUILD_BENCHMARKS=OFF \ -DVDE_BUILD_PYTHON=OFF \ -DVDE_USE_OPENMP=ON cmake --build build_analysis -j2 --target vde_foundation vde_core vde_curves vde_mesh vde_spatial vde_boolean vde_collision vde_brep vde_sdf vde_sketch vde_capi - name: Run clang-tidy run: | run-clang-tidy-15 \ -p build_analysis \ -j2 \ -header-filter='include/vde/.*\.h$' \ 2>&1 | tee clang-tidy-report.txt continue-on-error: true - name: Summarize results if: always() run: | echo "## clang-tidy Results" >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY WARNINGS=$(grep -c 'warning:' clang-tidy-report.txt || echo 0) ERRORS=$(grep -c 'error:' clang-tidy-report.txt || echo 0) echo "Total warnings: $WARNINGS" >> $GITHUB_STEP_SUMMARY echo "Total errors: $ERRORS" >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY if [ "$ERRORS" -gt 0 ]; then echo "⚠️ Found $ERRORS clang-tidy errors" >> $GITHUB_STEP_SUMMARY fi - name: Upload clang-tidy report if: always() uses: actions/upload-artifact@v4 with: name: clang-tidy-report path: clang-tidy-report.txt retention-days: 30 if-no-files-found: ignore - name: Upload compile_commands.json if: always() uses: actions/upload-artifact@v4 with: name: compile-commands path: build_analysis/compile_commands.json retention-days: 7 if-no-files-found: ignore