fix workflow : problem with CMakeCache.txt - Windows #113
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 | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| env: | |
| CI: true | |
| jobs: | |
| test: | |
| name: Tests (${{ matrix.os }}, ${{ matrix.compiler }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| compiler: gcc | |
| version: 11 | |
| build_type: Debug | |
| generator: "Unix Makefiles" | |
| - os: ubuntu-22.04 | |
| compiler: clang | |
| version: 14 | |
| build_type: Debug | |
| generator: "Unix Makefiles" | |
| - os: windows-2022 | |
| compiler: msvc | |
| version: 2022 | |
| build_type: Debug | |
| 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" | |
| # ---------------- 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 | |
| - name: Clear CMake cache | |
| shell: bash | |
| run: | | |
| echo "🧹 Starting comprehensive cache cleanup..." | |
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}" | |
| rm -rf ".deps" | |
| rm -rf "${{ github.workspace }}/.deps" | |
| rm -rf "${{ github.workspace }}/build" | |
| 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 | |
| if [[ "${{ matrix.os }}" == "windows-2022" ]]; then | |
| echo "🪟 Performing Windows-specific cleanup..." | |
| find "${{ github.workspace }}" -name "*.vcxproj" -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 | |
| fi | |
| echo "✅ CMake cache cleared completely" | |
| - name: Create build directory | |
| run: | | |
| mkdir -p "${{ steps.build-env.outputs.build-output-dir }}" | |
| - name: Download dependencies | |
| shell: bash | |
| run: | | |
| echo "📥 Downloading external dependencies..." | |
| cd "${{ steps.build-env.outputs.build-output-dir }}" | |
| 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 .. | |
| echo "✅ Dependencies downloaded successfully" | |
| - name: Clean FetchContent subprojects | |
| shell: bash | |
| 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: 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: Configure CMake | |
| shell: bash | |
| run: | | |
| echo "🔧 Configuring CMake for tests with the following settings:" | |
| echo " Build type: ${{ matrix.build_type }}" | |
| echo " Generator: ${{ matrix.generator }}" | |
| echo " Compiler: ${{ matrix.compiler }}" | |
| echo " OS: ${{ matrix.os }}" | |
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}/CMakeCache.txt" | |
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}/CMakeFiles" | |
| cmake --fresh -B "${{ steps.build-env.outputs.build-output-dir }}" \ | |
| -G "${{ matrix.generator }}" \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
| -DBUILD_TESTS=ON \ | |
| -DBUILD_BENCHMARKS=ON \ | |
| -DDISABLE_ALL_WARNINGS=ON \ | |
| -DENABLE_OPTIMIZATIONS=OFF \ | |
| -DENABLE_UNITY_BUILD=OFF \ | |
| -DENABLE_DEV_TOOLS=ON \ | |
| -DENABLE_DEBUG_INFO=ON \ | |
| -DFETCHCONTENT_VERBOSE=ON \ | |
| -S "${{ github.workspace }}" | |
| echo "✅ CMake configuration completed" | |
| - name: Build project | |
| shell: bash | |
| run: | | |
| 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 ChainedDecosTests \ | |
| --parallel "$PARALLEL_JOBS" | |
| - name: Run tests | |
| shell: bash | |
| run: | | |
| cd "${{ steps.build-env.outputs.build-output-dir }}" | |
| if command -v ctest &> /dev/null; then | |
| echo "🧪 Running tests with CTest..." | |
| ctest --output-on-failure --build-config ${{ matrix.build_type }} || echo "⚠️ Some tests failed" | |
| else | |
| echo "ℹ️ CTest not available, looking for test executables..." | |
| if [[ "${{ matrix.os }}" == "windows-2022" ]]; then | |
| find . -name "*test*.exe" -type f | head -5 | while read -r test_exe; do | |
| echo "🔍 Running test: $(basename "$test_exe")" | |
| "$test_exe" || echo "⚠️ Test failed: $(basename "$test_exe")" | |
| done | |
| else | |
| find . -name "*test*" -type f -executable | head -5 | while read -r test_exe; do | |
| echo "🔍 Running test: $(basename "$test_exe")" | |
| "$test_exe" || echo "⚠️ Test failed: $(basename "$test_exe")" | |
| done | |
| fi | |
| fi | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }} | |
| path: | | |
| ${{ steps.build-env.outputs.build-output-dir }}/Testing/ | |
| ${{ steps.build-env.outputs.build-output-dir }}/**/*.log | |
| retention-days: 7 |