fix: Optimize CI/CD workflows for GoogleTest integration #7
This file contains hidden or 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: Test Suite | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| env: | |
| CI: true | |
| jobs: | |
| test: | |
| name: Run Tests (${{ matrix.os }}, ${{ matrix.compiler }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| compiler: gcc | |
| version: 11 | |
| - os: ubuntu-22.04 | |
| compiler: clang | |
| version: 14 | |
| - os: windows-2022 | |
| compiler: msvc | |
| version: 2022 | |
| - os: macos-12 | |
| compiler: clang | |
| version: apple | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up build environment | |
| shell: bash | |
| id: build-env | |
| run: | | |
| echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
| # ---------------- Linux (Ubuntu) setup ---------------- | |
| - name: Install dependencies (Ubuntu) | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential cmake ninja-build \ | |
| libgl1-mesa-dev libx11-dev libxrandr-dev libxinerama-dev \ | |
| libxcursor-dev libxi-dev libasound2-dev libglu1-mesa-dev \ | |
| libwayland-dev libxkbcommon-dev libegl1-mesa-dev \ | |
| pkg-config ccache | |
| - name: Set up GCC (Ubuntu) | |
| if: matrix.compiler == 'gcc' && startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| echo "CC=gcc-${{ matrix.version }}" >> "$GITHUB_ENV" | |
| echo "CXX=g++-${{ matrix.version }}" >> "$GITHUB_ENV" | |
| - name: Set up Clang (Ubuntu) | |
| if: matrix.compiler == 'clang' && startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| echo "CC=clang-${{ matrix.version }}" >> "$GITHUB_ENV" | |
| echo "CXX=clang++-${{ matrix.version }}" >> "$GITHUB_ENV" | |
| # ---------------- Windows setup ---------------- | |
| - name: Set up MSVC (Windows) | |
| if: matrix.os == 'windows-2022' | |
| uses: microsoft/setup-msbuild@v1.1 | |
| with: | |
| vs-version: '[17.0,18.0)' | |
| # ---------------- macOS setup ---------------- | |
| - name: Install dependencies (macOS) | |
| if: startsWith(matrix.os, 'macos') | |
| run: | | |
| brew update | |
| brew install cmake ninja ccache | |
| - name: Clear CMake cache | |
| run: | | |
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}" | |
| rm -rf ".deps" | |
| rm -f CMakeCache.txt cmake_install.cmake CMakeFiles/ | |
| - name: Create build directory | |
| run: mkdir -p "${{ steps.build-env.outputs.build-output-dir }}" | |
| - name: Configure CMake for testing | |
| run: | | |
| cmake -B "${{ steps.build-env.outputs.build-output-dir }}" \ | |
| -DCMAKE_BUILD_TYPE=Debug \ | |
| -DBUILD_TESTS=ON \ | |
| -DBUILD_BENCHMARKS=ON \ | |
| -DENABLE_COVERAGE=OFF \ | |
| -DENABLE_WARNINGS=ON \ | |
| -DENABLE_SANITIZERS=OFF \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DENABLE_DEV_TOOLS=ON \ | |
| -DENABLE_DEBUG_INFO=ON \ | |
| -S "${{ github.workspace }}" | |
| - name: Build tests and benchmarks | |
| run: | | |
| cmake --build "${{ steps.build-env.outputs.build-output-dir }}" \ | |
| --config Debug \ | |
| --target ChainedDecos ChainedDecosMapEditor ChainedDecosTests benchmarks \ | |
| --parallel $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4) | |
| - name: Run smoke tests | |
| run: | | |
| echo "🧪 Running smoke tests..." | |
| # Test that executables exist and are runnable | |
| if [ "${{ matrix.os }}" = "windows-2022" ]; then | |
| if [ -f "${{ steps.build-env.outputs.build-output-dir }}/bin/Debug/ChainedDecos.exe" ]; then | |
| echo "✅ Main executable built successfully" | |
| else | |
| echo "❌ Main executable not found" | |
| exit 1 | |
| fi | |
| if [ -f "${{ steps.build-env.outputs.build-output-dir }}/bin/Debug/ChainedDecosMapEditor.exe" ]; then | |
| echo "✅ Map editor executable built successfully" | |
| else | |
| echo "❌ Map editor executable not found" | |
| exit 1 | |
| fi | |
| else | |
| if [ -f "${{ steps.build-env.outputs.build-output-dir }}/bin/ChainedDecos" ]; then | |
| echo "✅ Main executable built successfully" | |
| else | |
| echo "❌ Main executable not found" | |
| exit 1 | |
| fi | |
| if [ -f "${{ steps.build-env.outputs.build-output-dir }}/bin/ChainedDecosMapEditor" ]; then | |
| echo "✅ Map editor executable built successfully" | |
| else | |
| echo "❌ Map editor executable not found" | |
| exit 1 | |
| fi | |
| fi | |
| - name: Run static analysis | |
| run: | | |
| echo "🔍 Running static analysis..." | |
| # Check for common issues in source files | |
| if [ "${{ matrix.os }}" != "windows-2022" ]; then | |
| # Count warnings in build output | |
| echo "📊 Build completed successfully" | |
| # Check for potential memory leaks or issues | |
| echo "🔍 Checking for common C++ issues..." | |
| find src -name "*.cpp" -o -name "*.h" | wc -l | xargs echo "Found files to analyze:" | |
| fi | |
| - name: Generate coverage report (Ubuntu only) | |
| if: startsWith(matrix.os, 'ubuntu') && matrix.compiler == 'gcc' | |
| run: | | |
| echo "📊 Generating coverage report..." | |
| # Coverage would be generated here if we had tests with coverage instrumentation | |
| echo "ℹ️ Coverage report generation skipped (no tests with coverage)" | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }}-${{ matrix.compiler }} | |
| path: | | |
| ${{ steps.build-env.outputs.build-output-dir }}/Testing/ | |
| ${{ steps.build-env.outputs.build-output-dir }}/compile_commands.json | |
| retention-days: 7 | |
| - name: Upload coverage report (Ubuntu GCC only) | |
| uses: actions/upload-artifact@v4 | |
| if: startsWith(matrix.os, 'ubuntu') && matrix.compiler == 'gcc' && always() | |
| with: | |
| name: coverage-report-${{ matrix.os }}-${{ matrix.compiler }} | |
| path: | | |
| ${{ steps.build-env.outputs.build-output-dir }}/coverage/ | |
| retention-days: 30 |