Fix raylib dependency issue in CI workflow #110
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: | | |
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}" | |
| rm -rf ".deps" | |
| rm -rf "${{ github.workspace }}/.deps" | |
| rm -f CMakeCache.txt cmake_install.cmake CMakeFiles/ | |
| - 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 \ | |
| -DENABLE_WARNINGS=OFF \ | |
| -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 ChainedDecosTests \ | |
| --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 }}" | |
| # Run CTest if available | |
| 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..." | |
| # Look for test executables in build directory | |
| 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 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 |