fix workflow : update for windows dll #94
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 MinGW DLLs | |
| if: matrix.os == 'windows-2022' && matrix.compiler != 'msvc' | |
| shell: bash | |
| run: | | |
| echo "🔧 Copying MinGW DLLs for runtime dependencies..." | |
| # Create tests directory if it doesn't exist | |
| mkdir -p "${{ steps.build-env.outputs.build-output-dir }}/bin/tests" | |
| # Copy all DLLs from MinGW bin directory to test directory | |
| if [ -d "/c/mingw64/bin" ]; then | |
| cp /c/mingw64/bin/*.dll "${{ steps.build-env.outputs.build-output-dir }}/bin/tests/" || echo "ℹ️ No DLLs found in /c/mingw64/bin or copy failed" | |
| else | |
| echo "ℹ️ MinGW directory not found at /c/mingw64/bin" | |
| fi | |
| # List copied DLLs for verification | |
| echo "📋 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 }}/tests" ]; then | |
| echo "🧪 Running tests..." | |
| # Find and run test executables | |
| find "${{ steps.build-env.outputs.build-output-dir }}/tests" -type f -executable -name "*test*" | while read -r test_exe; do | |
| echo "🔍 Running test: $(basename "$test_exe")" | |
| if [ "${{ matrix.os }}" = "windows-2022" ]; then | |
| # On Windows, run from the directory containing the DLLs | |
| test_dir=$(dirname "$test_exe") | |
| test_name=$(basename "$test_exe") | |
| cd "$test_dir" | |
| "./$test_name" || echo "⚠️ Test failed: $test_name" | |
| else | |
| "$test_exe" || echo "⚠️ Test failed: $(basename "$test_exe")" | |
| fi | |
| done | |
| else | |
| echo "ℹ️ No tests directory found - skipping tests" | |
| 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 |