🚀 Add comprehensive benchmark integration system #9
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: Documentation Build and Deploy | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build-docs: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install Python dependencies | |
| run: | | |
| Write-Host "Installing Python dependencies..." | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| Write-Host "Python dependencies installed successfully" | |
| # Verify key packages are installed | |
| python -c "import pytest; print('pytest version:', pytest.__version__)" | |
| python -c "import numpy; print('numpy version:', numpy.__version__)" | |
| python -c "import matplotlib; print('matplotlib version:', matplotlib.__version__)" | |
| Write-Host "Package verification completed" | |
| - name: Install Doxygen and Graphviz | |
| run: | | |
| Write-Host "Installing Doxygen and Graphviz..." | |
| # Try chocolatey installation first | |
| try { | |
| Write-Host "Attempting chocolatey installation..." | |
| choco install doxygen.install -y --no-progress | |
| choco install graphviz -y --no-progress | |
| # Refresh environment variables | |
| $env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.." | |
| Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
| refreshenv | |
| Write-Host "Chocolatey installation completed" | |
| } catch { | |
| Write-Host "Chocolatey installation failed, trying direct download..." | |
| # Fallback: Download Doxygen directly | |
| $doxygenUrl = "https://www.doxygen.nl/files/doxygen-1.9.8.windows.x64.bin.zip" | |
| $doxygenZip = "doxygen.zip" | |
| $doxygenDir = "C:\doxygen" | |
| Write-Host "Downloading Doxygen from $doxygenUrl" | |
| Invoke-WebRequest -Uri $doxygenUrl -OutFile $doxygenZip | |
| Write-Host "Extracting Doxygen..." | |
| Expand-Archive -Path $doxygenZip -DestinationPath $doxygenDir -Force | |
| # Find the actual doxygen executable | |
| $doxygenExe = Get-ChildItem -Path $doxygenDir -Name "doxygen.exe" -Recurse | Select-Object -First 1 | |
| if ($doxygenExe) { | |
| $doxygenPath = Join-Path $doxygenDir $doxygenExe | |
| Write-Host "Found doxygen at: $doxygenPath" | |
| } | |
| } | |
| # Add to PATH explicitly | |
| $env:PATH += ";C:\Program Files\doxygen\bin" | |
| $env:PATH += ";C:\Program Files\Graphviz\bin" | |
| $env:PATH += ";C:\doxygen" | |
| Write-Host "Updated PATH for Doxygen and Graphviz" | |
| - name: Verify Documentation Tools | |
| run: | | |
| # Final verification with updated PATH | |
| $env:PATH += ";C:\Program Files\doxygen\bin" | |
| $env:PATH += ";C:\Program Files\Graphviz\bin" | |
| $env:PATH += ";C:\doxygen" | |
| Write-Host "=== Final Tool Verification ===" | |
| # Try multiple locations for Doxygen | |
| $doxygenFound = $false | |
| $doxygenPaths = @( | |
| "C:\Program Files\doxygen\bin\doxygen.exe", | |
| "C:\doxygen\doxygen.exe", | |
| "doxygen" | |
| ) | |
| foreach ($path in $doxygenPaths) { | |
| try { | |
| Write-Host "Trying Doxygen at: $path" | |
| if ($path -eq "doxygen") { | |
| $version = doxygen --version 2>&1 | |
| } else { | |
| $version = & $path --version 2>&1 | |
| } | |
| Write-Host "Doxygen found: $version" | |
| $doxygenFound = $true | |
| break | |
| } catch { | |
| Write-Host "Not found at $path" | |
| } | |
| } | |
| if (-not $doxygenFound) { | |
| Write-Host "Doxygen not found in any location!" | |
| exit 1 | |
| } | |
| # Try Graphviz (optional, continue if not found) | |
| try { | |
| $graphvizVersion = & "C:\Program Files\Graphviz\bin\dot.exe" -V 2>&1 | |
| Write-Host "Graphviz found: $graphvizVersion" | |
| } catch { | |
| try { | |
| $graphvizVersion = dot -V 2>&1 | |
| Write-Host "Graphviz found in PATH: $graphvizVersion" | |
| } catch { | |
| Write-Host "Warning: Graphviz not found - diagrams will be disabled" | |
| } | |
| } | |
| Write-Host "Tools verification completed" | |
| - name: Setup XMake | |
| uses: xmake-io/github-action-setup-xmake@v1 | |
| with: | |
| xmake-version: latest | |
| - name: Configure XMake | |
| run: | | |
| # Try to install benchmark library, but don't fail if it's not available | |
| Write-Host "Installing benchmark library..." | |
| try { | |
| xmake require benchmark | |
| Write-Host "Benchmark library installed successfully" | |
| xmake config --with-benchmarks=true --with-testing=true | |
| } catch { | |
| Write-Host "Benchmark library installation failed, building without benchmarks" | |
| xmake config --with-benchmarks=false --with-testing=true | |
| } | |
| - name: Build C++ library | |
| run: | | |
| Write-Host "Building C++ library..." | |
| # Build core library first | |
| xmake build zlayout | |
| if (-not $?) { | |
| Write-Host "Static library build failed" | |
| exit 1 | |
| } | |
| # Build shared library | |
| xmake build zlayout_shared | |
| if (-not $?) { | |
| Write-Host "Shared library build failed" | |
| exit 1 | |
| } | |
| # Build examples | |
| xmake build basic_example | |
| if (-not $?) { | |
| Write-Host "Examples build failed" | |
| exit 1 | |
| } | |
| Write-Host "C++ library build completed successfully" | |
| - name: Run C++ tests | |
| run: | | |
| Write-Host "Running C++ tests..." | |
| xmake test | |
| if (-not $?) { | |
| Write-Host "C++ tests failed" | |
| exit 1 | |
| } | |
| Write-Host "C++ tests completed successfully" | |
| - name: Run Python tests | |
| run: | | |
| python -m pytest tests/ -v --tb=short | |
| if (-not $?) { exit 1 } | |
| - name: Build benchmarks | |
| run: | | |
| Write-Host "Attempting to build benchmarks..." | |
| try { | |
| xmake build bench_geometry bench_quadtree | |
| Write-Host "Benchmarks built successfully" | |
| } catch { | |
| Write-Host "Benchmarks build failed - continuing without benchmarks" | |
| } | |
| continue-on-error: true | |
| - name: Run benchmarks | |
| run: | | |
| Write-Host "Attempting to run benchmarks..." | |
| try { | |
| if (Test-Path "build/windows/x64/release/bench_geometry.exe") { | |
| xmake run bench_geometry --benchmark_out=docs/benchmarks/geometry_results.json --benchmark_out_format=json | |
| Write-Host "Geometry benchmarks completed" | |
| } else { | |
| Write-Host "Geometry benchmark executable not found" | |
| } | |
| if (Test-Path "build/windows/x64/release/bench_quadtree.exe") { | |
| xmake run bench_quadtree --benchmark_out=docs/benchmarks/spatial_results.json --benchmark_out_format=json | |
| Write-Host "Quadtree benchmarks completed" | |
| } else { | |
| Write-Host "Quadtree benchmark executable not found" | |
| } | |
| } catch { | |
| Write-Host "Benchmark execution failed - continuing without benchmark results" | |
| } | |
| continue-on-error: true | |
| - name: Create performance visualization | |
| run: | | |
| if (Test-Path "docs/benchmarks/geometry_results.json") { | |
| Write-Host "Benchmark results found - creating visualization placeholder" | |
| mkdir -p docs/images | |
| # Create a simple text file as placeholder | |
| "Benchmark results generated on $(Get-Date)" | Out-File -FilePath "docs/images/benchmark_results.txt" | |
| } else { | |
| Write-Host "No benchmark results found" | |
| } | |
| continue-on-error: true | |
| - name: Copy examples to documentation | |
| run: | | |
| if (Test-Path "examples") { | |
| Copy-Item -Path "examples/*.py" -Destination "docs/examples/" -Force | |
| Write-Host "Copied Python examples to documentation" | |
| } | |
| - name: Build documentation with Doxygen | |
| run: | | |
| # Create output directory | |
| if (-not (Test-Path "docs/generated")) { | |
| New-Item -ItemType Directory -Path "docs/generated" -Force | |
| } | |
| # Update PATH for this step | |
| $env:PATH += ";C:\Program Files\doxygen\bin" | |
| $env:PATH += ";C:\Program Files\Graphviz\bin" | |
| $env:PATH += ";C:\doxygen" | |
| Write-Host "Building documentation with Doxygen..." | |
| # Find Doxygen and build documentation | |
| $doxygenBuilt = $false | |
| $doxygenPaths = @( | |
| "C:\Program Files\doxygen\bin\doxygen.exe", | |
| "C:\doxygen\doxygen.exe" | |
| ) | |
| foreach ($path in $doxygenPaths) { | |
| if (Test-Path $path) { | |
| try { | |
| Write-Host "Using Doxygen at: $path" | |
| & $path Doxyfile | |
| $doxygenBuilt = $true | |
| break | |
| } catch { | |
| Write-Host "Failed to run Doxygen at $path" | |
| } | |
| } | |
| } | |
| # Try PATH if explicit paths failed | |
| if (-not $doxygenBuilt) { | |
| try { | |
| Write-Host "Trying doxygen from PATH..." | |
| doxygen Doxyfile | |
| $doxygenBuilt = $true | |
| } catch { | |
| Write-Host "Failed to run doxygen from PATH" | |
| } | |
| } | |
| if (-not $doxygenBuilt) { | |
| Write-Host "Failed to run Doxygen from any location" | |
| exit 1 | |
| } | |
| # Verify documentation was generated | |
| if (Test-Path "docs/generated/html/index.html") { | |
| Write-Host "Documentation built successfully" | |
| Write-Host "Generated files:" | |
| Get-ChildItem "docs/generated/html" | Select-Object Name | Format-Table -AutoSize | |
| } else { | |
| Write-Host "Documentation build failed - index.html not found" | |
| Write-Host "Contents of docs/generated:" | |
| if (Test-Path "docs/generated") { | |
| Get-ChildItem "docs/generated" -Recurse | Select-Object FullName | |
| } | |
| exit 1 | |
| } | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| if: github.ref == 'refs/heads/main' | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| if: github.ref == 'refs/heads/main' | |
| with: | |
| path: docs/generated/html | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| if: github.ref == 'refs/heads/main' | |
| # Separate job for documentation validation | |
| validate-docs: | |
| runs-on: ubuntu-latest | |
| needs: build-docs | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Validate documentation structure | |
| run: | | |
| echo "Validating documentation structure..." | |
| find docs/ -name "*.md" -type f | head -10 | |
| echo "Documentation validation completed" | |
| # Build status notification | |
| notify-status: | |
| runs-on: ubuntu-latest | |
| needs: [build-docs] | |
| if: always() | |
| steps: | |
| - name: Documentation Build Status | |
| run: | | |
| if [[ "${{ needs.build-docs.result }}" == "success" ]]; then | |
| echo "Documentation build completed successfully" | |
| echo "Documentation will be available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/" | |
| else | |
| echo "Documentation build failed" | |
| exit 1 | |
| fi |