update workflow and added option for MapEditor #98
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 }}, ${{ matrix.build_type }}) | |
| 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" | |
| cmake_options: "" | |
| # Ubuntu with Clang | |
| - os: ubuntu-22.04 | |
| compiler: clang | |
| version: 14 | |
| build_type: Release | |
| generator: "Unix Makefiles" | |
| cmake_options: "" | |
| # Windows with MSVC | |
| - os: windows-2022 | |
| compiler: msvc | |
| version: 2022 | |
| build_type: Release | |
| generator: "Ninja" | |
| cmake_options: "" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup ccache | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.ccache | |
| C:\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 | |
| - 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 zip --no-progress | |
| # ---------------- Common build steps ---------------- | |
| - name: Clear CMake cache | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.os }}" = "windows-2022" ]; then | |
| # Windows commands | |
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}" 2>/dev/null || echo "Build dir not found or already clean" | |
| rm -rf ".deps" 2>/dev/null || echo "Deps dir not found or already clean" | |
| rm -f CMakeCache.txt cmake_install.cmake 2>/dev/null || echo "Cache files not found or already clean" | |
| # Remove any remaining CMakeFiles directories | |
| find . -name "CMakeFiles" -type d -exec rm -rf {} + 2>/dev/null || echo "No CMakeFiles dirs found" | |
| else | |
| # Unix/Linux commands | |
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}" | |
| rm -rf ".deps" | |
| rm -f CMakeCache.txt cmake_install.cmake CMakeFiles/ | |
| fi | |
| - name: Create build directory | |
| run: | | |
| mkdir -p "${{ steps.build-env.outputs.build-output-dir }}" | |
| mkdir -p "${{ steps.build-env.outputs.install-prefix }}" | |
| - name: Configure CMake | |
| shell: bash | |
| run: | | |
| 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 \ | |
| ${{ matrix.cmake_options }} \ | |
| -S "${{ github.workspace }}" | |
| - name: Build project | |
| shell: bash | |
| run: | | |
| cmake --build "${{ steps.build-env.outputs.build-output-dir }}" \ | |
| --config ${{ matrix.build_type }} \ | |
| --target ChainedDecos ChainedDecosMapEditor ChainedDecosTests \ | |
| --parallel $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 8) | |
| - name: Install project | |
| shell: bash | |
| run: | | |
| cmake --install "${{ steps.build-env.outputs.build-output-dir }}" \ | |
| --config ${{ matrix.build_type }} | |
| - name: Copy runtime DLLs | |
| if: matrix.os == 'windows-2022' | |
| shell: bash | |
| run: | | |
| echo "🔧 Copying runtime DLLs for Windows builds..." | |
| # Create tests directory if it doesn't exist | |
| mkdir -p "${{ steps.build-env.outputs.build-output-dir }}/bin/tests" | |
| # Copy MSVC runtime DLLs from system directory | |
| echo "📋 Copying MSVC runtime DLLs..." | |
| for dll in "vcruntime140.dll" "msvcp140.dll" "concrt140.dll" "vcruntime140_1.dll" "msvcp140_1.dll"; do | |
| if [ -f "C:/Windows/System32/$dll" ]; then | |
| cp "C:/Windows/System32/$dll" "${{ steps.build-env.outputs.build-output-dir }}/bin/tests/" 2>/dev/null && echo "✅ Copied $dll" || echo "ℹ️ Could not copy $dll" | |
| else | |
| echo "⚠️ $dll not found in System32" | |
| fi | |
| done | |
| # Copy raylib and other dependency DLLs if they exist in build directory | |
| echo "📋 Looking for dependency DLLs in build directory..." | |
| if [ -d "${{ steps.build-env.outputs.build-output-dir }}/bin" ]; then | |
| find "${{ steps.build-env.outputs.build-output-dir }}/bin" -name "*.dll" -exec cp {} "${{ steps.build-env.outputs.build-output-dir }}/bin/tests/" \; 2>/dev/null || echo "ℹ️ No DLLs found in build/bin" | |
| fi | |
| # Copy from deps directory if it exists | |
| if [ -d ".deps" ]; then | |
| echo "📋 Looking for DLLs in deps directory..." | |
| find ".deps" -name "*.dll" -exec cp {} "${{ steps.build-env.outputs.build-output-dir }}/bin/tests/" \; 2>/dev/null || echo "ℹ️ No DLLs found in .deps" | |
| fi | |
| # List all copied DLLs for verification | |
| echo "📋 Final DLLs in test directory:" | |
| ls -la "${{ steps.build-env.outputs.build-output-dir }}/bin/tests/"*.dll 2>/dev/null || echo "ℹ️ No DLLs found in test directory" | |
| - name: Run tests | |
| shell: bash | |
| run: | | |
| # Run tests if they exist | |
| if [ -d "${{ steps.build-env.outputs.build-output-dir }}/bin/tests" ]; then | |
| echo "🧪 Running tests from: ${{ steps.build-env.outputs.build-output-dir }}/bin/tests" | |
| cd "${{ steps.build-env.outputs.build-output-dir }}/bin/tests" | |
| # List test directory contents for debugging | |
| echo "📋 Test directory contents:" | |
| ls -la | |
| # Find and run test executables | |
| echo "🔍 Looking for test executables..." | |
| if [ "${{ matrix.os }}" = "windows-2022" ]; then | |
| # On Windows, use cmd to handle paths properly | |
| echo "🪟 Running tests on Windows..." | |
| # Use find with cmd-compatible paths | |
| for test_exe in *.exe; do | |
| if [[ "$test_exe" == *test* ]]; then | |
| echo "🔍 Running test: $test_exe" | |
| echo "📋 Current directory: $(pwd)" | |
| echo "📋 DLLs available:" | |
| ls -la *.dll 2>/dev/null || echo "ℹ️ No DLLs found" | |
| "./$test_exe" || echo "⚠️ Test failed: $test_exe (exit code: $?)" | |
| fi | |
| done | |
| else | |
| # Unix systems | |
| find . -type f -executable -name "*test*" | while read -r test_exe; do | |
| echo "🔍 Running test: $(basename "$test_exe")" | |
| "$test_exe" || echo "⚠️ Test failed: $(basename "$test_exe")" | |
| done | |
| fi | |
| else | |
| echo "ℹ️ No tests directory found at ${{ steps.build-env.outputs.build-output-dir }}/bin/tests - skipping tests" | |
| echo "📋 Available directories:" | |
| find "${{ steps.build-env.outputs.build-output-dir }}" -type d 2>/dev/null | head -10 || echo "ℹ️ No directories found" | |
| fi | |
| - name: Run tests (if available) | |
| shell: bash | |
| run: | | |
| # Check if tests directory exists and has test executables | |
| if [ -d "${{ steps.build-env.outputs.build-output-dir }}/tests" ]; then | |
| echo "🔍 Tests directory found, looking for test executables..." | |
| find "${{ steps.build-env.outputs.build-output-dir }}/tests" -type f -executable -name "*test*" | head -3 || echo "ℹ️ No test executables found" | |
| else | |
| echo "ℹ️ No tests directory found - skipping tests" | |
| fi | |
| # Run basic executable validation (only for Ubuntu with GCC to save time) | |
| if [ "${{ matrix.os }}" = "ubuntu-22.04" ] && [ "${{ matrix.compiler }}" = "gcc" ]; then | |
| echo "🔍 Validating executables..." | |
| if [ -n "$EXECUTABLE_PATH" ]; then | |
| "$EXECUTABLE_PATH" --help 2>&1 | head -5 || echo "ℹ️ Help not available or executable not working" | |
| else | |
| echo "ℹ️ No executable path available for validation" | |
| 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 | |
| - name: Upload logs on failure | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: build-logs-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }} | |
| path: | | |
| ${{ steps.build-env.outputs.build-output-dir }}/CMakeFiles/*.log | |
| ${{ steps.build-env.outputs.build-output-dir }}/**/*.log | |
| retention-days: 3 |