fix workflow : replace CTest #130
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: Build and Test ChainedDecos | ||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [ main, develop ] | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
| env: | ||
| CI: true | ||
| jobs: | ||
| build-and-test: | ||
| name: Build and Test (${{ matrix.os }}, ${{ matrix.compiler }}) | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| # Ubuntu with GCC | ||
| - os: ubuntu-22.04 | ||
| compiler: gcc | ||
| version: 11 | ||
| build_type: Release | ||
| generator: "Unix Makefiles" | ||
| # Ubuntu with Clang | ||
| - os: ubuntu-22.04 | ||
| compiler: clang | ||
| version: 14 | ||
| build_type: Release | ||
| generator: "Unix Makefiles" | ||
| # Windows with MSVC | ||
| - os: windows-2022 | ||
| compiler: msvc | ||
| version: 2022 | ||
| build_type: Release | ||
| generator: "Ninja" | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| - name: Setup ccache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: | | ||
| ~/.ccache | ||
| ${{ runner.os == 'Windows' && 'C:/ccache' || '~/.ccache' }} | ||
| key: ccache-${{ matrix.os }}-${{ matrix.compiler }}-${{ github.sha }} | ||
| restore-keys: | | ||
| ccache-${{ matrix.os }}-${{ matrix.compiler }}- | ||
| ccache-${{ matrix.os }}- | ||
| - name: Setup dependency cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: | | ||
| .deps | ||
| ~/.deps | ||
| key: deps-${{ matrix.os }}-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }} | ||
| restore-keys: | | ||
| deps-${{ matrix.os }}-${{ matrix.compiler }}- | ||
| deps-${{ matrix.os }}- | ||
| - name: Set up build environment | ||
| shell: bash | ||
| id: build-env | ||
| run: | | ||
| echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
| echo "install-prefix=${{ github.workspace }}/install" >> "$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 libgtk-3-dev libdrm-dev libgbm-dev \ | ||
| libxext-dev libxfixes-dev libxrender-dev libxcomposite-dev \ | ||
| libxdamage-dev libxtst-dev libxss-dev libgconf-2-4 | ||
| - 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: Install dependencies (Windows) | ||
| if: matrix.os == 'windows-2022' | ||
| run: | | ||
| choco install cmake ninja ccache --no-progress | ||
| # ---------------- Common build steps ---------------- | ||
| - name: Clear CMake cache | ||
| shell: bash | ||
| run: | | ||
| echo "🧹 Starting comprehensive cache cleanup..." | ||
| # Clear build directory completely | ||
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}" | ||
| rm -rf ".deps" | ||
| rm -rf "${{ github.workspace }}/.deps" | ||
| rm -rf "${{ github.workspace }}/build" | ||
| # Clear any leftover CMake cache files in workspace (with verbose output) | ||
| echo "📁 Searching for CMake cache files..." | ||
| find "${{ github.workspace }}" -name "CMakeCache.txt" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "CMakeFiles" -type d -exec rm -rf {} + -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "cmake_install.cmake" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "_deps" -type d -exec rm -rf {} + -print 2>/dev/null || true | ||
| # Windows-specific cleanup (Visual Studio files) | ||
| if [[ "${{ matrix.os }}" == "windows-2022" ]]; then | ||
| echo "🪟 Performing comprehensive Windows-specific cleanup..." | ||
| find "${{ github.workspace }}" -name "*.vcxproj" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.vcxproj.filters" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.sln" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name ".vs" -type d -exec rm -rf {} + -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "Debug" -type d -exec rm -rf {} + -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "Release" -type d -exec rm -rf {} + -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "x64" -type d -exec rm -rf {} + -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "Win32" -type d -exec rm -rf {} + -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.dir" -type d -exec rm -rf {} + -print 2>/dev/null || true | ||
| # Additional Windows-specific patterns | ||
| find "${{ github.workspace }}" -name "*.vcxproj.user" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.pdb" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.ilk" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.exe" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.obj" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.lib" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.exp" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.idb" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.ipdb" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.iobj" -delete -print 2>/dev/null || true | ||
| # Remove any Visual Studio solution user files | ||
| find "${{ github.workspace }}" -name "*.suo" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "*.user" -delete -print 2>/dev/null || true | ||
| # Remove CMake files that might contain generator information | ||
| find "${{ github.workspace }}" -name "CMakeCache.txt" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "cmake_install.cmake" -delete -print 2>/dev/null || true | ||
| find "${{ github.workspace }}" -name "compile_commands.json" -delete -print 2>/dev/null || true | ||
| # Remove any hidden CMake directories | ||
| find "${{ github.workspace }}" -type d -name "CMakeFiles" -exec rm -rf {} + -print 2>/dev/null || true | ||
| fi | ||
| # Clear any hidden CMake files | ||
| find "${{ github.workspace }}" -name ".cmake" -type d -exec rm -rf {} + 2>/dev/null || true | ||
| # Clear dependency cache directories that might contain cached generators | ||
| rm -rf "${{ github.workspace }}/cmake-build-*" | ||
| rm -rf "${{ github.workspace }}/build" | ||
| rm -rf "${{ github.workspace }}/.cache" | ||
| rm -rf "${{ github.workspace }}/CMakeFiles" | ||
| # Final verification - list any remaining CMake files | ||
| echo "🔍 Checking for any remaining CMake files..." | ||
| find "${{ github.workspace }}" -name "CMakeCache.txt" 2>/dev/null || echo "No CMakeCache.txt found" | ||
| find "${{ github.workspace }}" -name "CMakeFiles" -type d 2>/dev/null || echo "No CMakeFiles directories found" | ||
| echo "✅ CMake cache cleared completely" | ||
| - name: Clean FetchContent subprojects | ||
| shell: bash | ||
| if: matrix.os == 'windows-2022' | ||
| run: | | ||
| echo "🧹 Removing old FetchContent subprojects (raylib, etc.)..." | ||
| find "${{ github.workspace }}" -type d -name ".deps" -exec rm -rf {} + 2>/dev/null || true | ||
| echo "✅ .deps directories removed" | ||
| - name: Force clean all previous builds (Windows) | ||
| if: matrix.os == 'windows-2022' | ||
| shell: bash | ||
| run: | | ||
| echo "🧨 Full cleanup before new generator" | ||
| rm -rf "${{ github.workspace }}/build" | ||
| rm -rf "${{ github.workspace }}/.deps" | ||
| rm -rf "${{ github.workspace }}/_deps" | ||
| rm -rf "${{ github.workspace }}/CMakeFiles" | ||
| rm -f "${{ github.workspace }}/CMakeCache.txt" | ||
| find "${{ github.workspace }}" -type d -name "_deps" -exec rm -rf {} + | ||
| echo "✅ Fully cleaned old CMake and FetchContent directories" | ||
| - name: Extra clean Raylib subbuild (Windows) | ||
| if: matrix.os == 'windows-2022' | ||
| shell: bash | ||
| run: | | ||
| echo "🧹 Cleaning raylib subbuild..." | ||
| rm -rf "${{ github.workspace }}/.deps/raylib-subbuild" | ||
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}/_deps/raylib-subbuild" | ||
| echo "✅ raylib subbuild cleaned" | ||
| - name: Create build directory | ||
| run: | | ||
| mkdir -p "${{ steps.build-env.outputs.build-output-dir }}" | ||
| mkdir -p "${{ steps.build-env.outputs.install-prefix }}" | ||
| # Ensure raylib and other dependencies are properly downloaded | ||
| - name: Download dependencies | ||
| shell: bash | ||
| run: | | ||
| # Pre-download dependencies to ensure they're available | ||
| echo "📥 Downloading external dependencies..." | ||
| cd "${{ steps.build-env.outputs.build-output-dir }}" | ||
| # Configure with verbose output to see dependency download progress | ||
| cmake --fresh -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | ||
| -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF \ | ||
| -DENABLE_WARNINGS=OFF -DENABLE_DEV_TOOLS=OFF \ | ||
| -DFETCHCONTENT_QUIET=OFF \ | ||
| -DFETCHCONTENT_UPDATES_DISCONNECTED=OFF .. | ||
| # Verify that raylib was downloaded successfully | ||
| if [[ -d "${{ github.workspace }}/.deps/raylib-src" ]]; then | ||
| echo "✅ Raylib downloaded successfully" | ||
| else | ||
| echo "⚠️ Raylib not found in .deps, checking alternative locations..." | ||
| find . -name "raylib" -type d 2>/dev/null || echo "❌ Raylib not found" | ||
| fi | ||
| echo "✅ Dependencies downloaded successfully" | ||
| - name: Configure CMake | ||
| shell: bash | ||
| run: | | ||
| echo "🔧 Configuring CMake with the following settings:" | ||
| echo " Build type: ${{ matrix.build_type }}" | ||
| echo " Generator: ${{ matrix.generator }}" | ||
| echo " Compiler: ${{ matrix.compiler }}" | ||
| echo " OS: ${{ matrix.os }}" | ||
| # Configure CMake with verbose output for dependency issues | ||
| cmake -B "${{ steps.build-env.outputs.build-output-dir }}" \ | ||
| -G "${{ matrix.generator }}" \ | ||
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | ||
| -DCMAKE_INSTALL_PREFIX="${{ steps.build-env.outputs.install-prefix }}" \ | ||
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
| -DBUILD_TESTS=ON \ | ||
| -DBUILD_BENCHMARKS=ON \ | ||
| -DDISABLE_ALL_WARNINGS=ON \ | ||
| -DENABLE_OPTIMIZATIONS=ON \ | ||
| -DENABLE_UNITY_BUILD=OFF \ | ||
| -DENABLE_DEV_TOOLS=OFF \ | ||
| -DENABLE_DEBUG_INFO=ON \ | ||
| -DFETCHCONTENT_VERBOSE=ON \ | ||
| -S "${{ github.workspace }}" | ||
| echo "✅ CMake configuration completed" | ||
| - name: Build project | ||
| shell: bash | ||
| run: | | ||
| # Determine number of CPU cores for parallel builds | ||
| if [[ "${{ matrix.os }}" == "windows-2022" ]]; then | ||
| PARALLEL_JOBS=8 | ||
| else | ||
| PARALLEL_JOBS=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 8) | ||
| fi | ||
| cmake --build "${{ steps.build-env.outputs.build-output-dir }}" \ | ||
| --config ${{ matrix.build_type }} \ | ||
| --target ChainedDecos ChainedDecosMapEditor ChainedDecosUnitTests ChainedDecosIntegrationTests \ | ||
| --parallel "$PARALLEL_JOBS" | ||
| - name: Install project | ||
| shell: bash | ||
| run: | | ||
| cmake --install "${{ steps.build-env.outputs.build-output-dir }}" \ | ||
| --config ${{ matrix.build_type }} | ||
| - name: Run tests | ||
| shell: bash | ||
| run: | | ||
| cd "${{ steps.build-env.outputs.build-output-dir }}" | ||
| echo "🧪 Running unit tests..." | ||
| if [[ "${{ matrix.os }}" == "windows-2022" ]]; then | ||
| if [[ -f "tests/ChainedDecosUnitTests.exe" ]]; then | ||
| echo "Running ChainedDecosUnitTests.exe" | ||
| tests/ChainedDecosUnitTests.exe || echo "⚠️ Unit tests failed" | ||
| else | ||
| echo "❌ ChainedDecosUnitTests.exe not found" | ||
| find . -name "*test*.exe" -type f | ||
| fi | ||
| echo "🧪 Running integration tests..." | ||
| if [[ -f "tests/ChainedDecosIntegrationTests.exe" ]]; then | ||
| echo "Running ChainedDecosIntegrationTests.exe" | ||
| tests/ChainedDecosIntegrationTests.exe || echo "⚠️ Integration tests failed" | ||
| else | ||
| echo "❌ ChainedDecosIntegrationTests.exe not found" | ||
| find . -name "*test*.exe" -type f | ||
| fi | ||
| else | ||
| if [[ -f "tests/ChainedDecosUnitTests" ]]; then | ||
| echo "Running ChainedDecosUnitTests" | ||
| tests/ChainedDecosUnitTests || echo "⚠️ Unit tests failed" | ||
| else | ||
| echo "❌ ChainedDecosUnitTests not found" | ||
| find . -name "*test*" -type f -executable | ||
| fi | ||
| echo "🧪 Running integration tests..." | ||
| if [[ -f "tests/ChainedDecosIntegrationTests" ]]; then | ||
| echo "Running ChainedDecosIntegrationTests" | ||
| tests/ChainedDecosIntegrationTests || echo "⚠️ Integration tests failed" | ||
| else | ||
| echo "❌ ChainedDecosIntegrationTests not found" | ||
| find . -name "*test*" -type f -executable | ||
| fi | ||
| fi | ||
| - name: Upload build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: build-artifacts-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }} | ||
| path: | | ||
| ${{ steps.build-env.outputs.install-prefix }}/bin/ | ||
| ${{ steps.build-env.outputs.build-output-dir }}/compile_commands.json | ||
| retention-days: 7 | ||