Add Windows Build Fallback Workflow for Enhanced CI/CD

This commit is contained in:
scawful
2025-09-27 21:21:04 -04:00
parent b5d908d39d
commit 6639d5b078
3 changed files with 261 additions and 16 deletions

View File

@@ -0,0 +1,151 @@
name: Windows Build Fallback
on:
workflow_call:
inputs:
build_type:
description: 'Build type (Debug/Release)'
required: true
type: string
default: 'Release'
platform:
description: 'Platform (x64/x86)'
required: true
type: string
default: 'x64'
env:
BUILD_TYPE: ${{ inputs.build_type }}
PLATFORM: ${{ inputs.platform }}
jobs:
build-windows-fallback:
name: Windows ${{ inputs.platform }} ${{ inputs.build_type }} (Fallback)
runs-on: windows-2022
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
# Try vcpkg first
- name: Set up vcpkg (Primary)
id: vcpkg_primary
uses: lukka/run-vcpkg@v11
continue-on-error: true
with:
vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00'
runVcpkgInstall: true
vcpkgJsonGlob: '**/vcpkg.json'
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgTriplet: '${{ inputs.platform }}-windows'
vcpkgArguments: '--x-install-root="${{ github.workspace }}/vcpkg_installed"'
env:
VCPKG_FORCE_SYSTEM_BINARIES: 1
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
# Fallback to newer baseline if primary fails
- name: Set up vcpkg (Fallback)
if: steps.vcpkg_primary.outcome == 'failure'
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: '2024.01.12'
runVcpkgInstall: true
vcpkgJsonGlob: '**/vcpkg.json.backup'
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgTriplet: '${{ inputs.platform }}-windows'
vcpkgArguments: '--x-install-root="${{ github.workspace }}/vcpkg_installed"'
env:
VCPKG_FORCE_SYSTEM_BINARIES: 1
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
# Fallback to manual dependency installation if both vcpkg attempts fail
- name: Install dependencies manually
if: steps.vcpkg_primary.outcome == 'failure'
shell: pwsh
run: |
Write-Host "Installing dependencies manually using Chocolatey and pre-built libraries..."
# Install Chocolatey if not present
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
}
# Install basic dependencies
choco install -y cmake ninja
# Create a minimal build configuration
Write-Host "Creating minimal build configuration for CI..."
# Set up environment variables for minimal build
echo "YAZE_MINIMAL_BUILD=ON" >> $env:GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$env:GITHUB_WORKSPACE\vcpkg_installed\${{ inputs.platform }}-windows" >> $env:GITHUB_ENV
- name: Configure CMake
shell: cmd
run: |
if exist "${{ github.workspace }}\vcpkg_installed" (
echo "Using vcpkg installation..."
cmake -B build ^
-DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 ^
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" ^
-DYAZE_BUILD_TESTS=OFF ^
-DYAZE_BUILD_EMU=OFF ^
-DYAZE_BUILD_Z3ED=OFF ^
-DYAZE_ENABLE_ROM_TESTS=OFF ^
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF ^
-DYAZE_INSTALL_LIB=OFF ^
-DYAZE_MINIMAL_BUILD=ON ^
-G "Visual Studio 17 2022" ^
-A %PLATFORM%
) else (
echo "Using minimal build configuration..."
cmake -B build ^
-DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 ^
-DYAZE_BUILD_TESTS=OFF ^
-DYAZE_BUILD_EMU=OFF ^
-DYAZE_BUILD_Z3ED=OFF ^
-DYAZE_ENABLE_ROM_TESTS=OFF ^
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF ^
-DYAZE_INSTALL_LIB=OFF ^
-DYAZE_MINIMAL_BUILD=ON ^
-G "Visual Studio 17 2022" ^
-A %PLATFORM%
)
- name: Build
run: cmake --build build --config %BUILD_TYPE% --parallel
- name: Test executable
shell: pwsh
run: |
$exePath = "build\bin\$env:BUILD_TYPE\yaze.exe"
if (Test-Path $exePath) {
Write-Host "✓ Executable created: $exePath" -ForegroundColor Green
# Test that it's not the test main
$testResult = & $exePath --help 2>&1
if ($testResult -match "Google Test" -or $testResult -match "gtest") {
Write-Error "Executable is running test main instead of app main!"
exit 1
}
Write-Host "✓ Executable runs correctly" -ForegroundColor Green
} else {
Write-Error "Executable not found at: $exePath"
exit 1
}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: yaze-${{ inputs.platform }}-${{ inputs.build_type }}-fallback
path: |
build/bin/${{ inputs.build_type }}/
retention-days: 7

View File

@@ -250,34 +250,88 @@ jobs:
-DYAZE_INSTALL_LIB=OFF \
-GNinja
# Set up vcpkg for Windows builds
# Set up vcpkg for Windows builds with fallback
- name: Set up vcpkg (Windows)
id: vcpkg_setup
if: runner.os == 'Windows'
uses: lukka/run-vcpkg@v11
continue-on-error: true
with:
vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00'
runVcpkgInstall: true
vcpkgJsonGlob: '**/vcpkg.json'
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgTriplet: '${{ matrix.vcpkg_triplet }}'
env:
VCPKG_FORCE_SYSTEM_BINARIES: 1
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
# Fallback to newer baseline if primary vcpkg fails
- name: Set up vcpkg (Fallback)
if: runner.os == 'Windows' && steps.vcpkg_setup.outcome == 'failure'
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: '2024.01.12'
runVcpkgInstall: true
vcpkgJsonGlob: '**/vcpkg.json.backup'
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
env:
VCPKG_FORCE_SYSTEM_BINARIES: 1
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
# Install dependencies manually if vcpkg fails completely
- name: Install dependencies manually (Windows)
if: runner.os == 'Windows' && steps.vcpkg_setup.outcome == 'failure'
shell: pwsh
run: |
Write-Host "Installing dependencies manually using Chocolatey and pre-built libraries..."
# Install Chocolatey if not present
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
}
# Install basic dependencies
choco install -y cmake ninja
Write-Host "Creating minimal build configuration for CI..."
echo "YAZE_MINIMAL_BUILD=ON" >> $env:GITHUB_ENV
- name: Configure CMake (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
cmake -B build ^
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ^
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 ^
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" ^
-DYAZE_BUILD_TESTS=OFF ^
-DYAZE_BUILD_EMU=OFF ^
-DYAZE_BUILD_Z3ED=OFF ^
-DYAZE_ENABLE_ROM_TESTS=OFF ^
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF ^
-DYAZE_INSTALL_LIB=OFF ^
-DYAZE_MINIMAL_BUILD=OFF ^
-G "${{ matrix.cmake_generator }}" ^
-A ${{ matrix.cmake_generator_platform }}
if exist "${{ github.workspace }}\vcpkg_installed" (
echo "Using vcpkg installation..."
cmake -B build ^
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ^
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 ^
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" ^
-DYAZE_BUILD_TESTS=OFF ^
-DYAZE_BUILD_EMU=OFF ^
-DYAZE_BUILD_Z3ED=OFF ^
-DYAZE_ENABLE_ROM_TESTS=OFF ^
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF ^
-DYAZE_INSTALL_LIB=OFF ^
-DYAZE_MINIMAL_BUILD=OFF ^
-G "${{ matrix.cmake_generator }}" ^
-A ${{ matrix.cmake_generator_platform }}
) else (
echo "Using minimal build configuration (vcpkg failed)..."
cmake -B build ^
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ^
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 ^
-DYAZE_BUILD_TESTS=OFF ^
-DYAZE_BUILD_EMU=OFF ^
-DYAZE_BUILD_Z3ED=OFF ^
-DYAZE_ENABLE_ROM_TESTS=OFF ^
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF ^
-DYAZE_INSTALL_LIB=OFF ^
-DYAZE_MINIMAL_BUILD=ON ^
-G "${{ matrix.cmake_generator }}" ^
-A ${{ matrix.cmake_generator_platform }}
)
# Build
- name: Build
@@ -353,6 +407,44 @@ jobs:
Write-Host "✓ Visual Studio build validation PASSED" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Cyan
# Test executable functionality (all platforms)
- name: Test executable functionality
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
# Determine executable path based on platform
if (${{ runner.os }} -eq "Windows") {
$exePath = "build\bin\${{ env.BUILD_TYPE }}\yaze.exe"
} elseif (${{ runner.os }} -eq "macOS") {
$exePath = "build/bin/yaze"
} else {
$exePath = "build/bin/yaze"
}
if (Test-Path $exePath) {
Write-Host "✓ Executable found: $exePath" -ForegroundColor Green
# Test that it's not the test main
$testResult = & $exePath --help 2>&1
$exitCode = $LASTEXITCODE
if ($testResult -match "Google Test" -or $testResult -match "gtest") {
Write-Error "Executable is running test main instead of app main!"
Write-Host "Output: $testResult" -ForegroundColor Red
exit 1
}
Write-Host "✓ Executable runs correctly (exit code: $exitCode)" -ForegroundColor Green
# Display file info
$exeInfo = Get-Item $exePath
Write-Host "Executable size: $([math]::Round($exeInfo.Length / 1MB, 2)) MB" -ForegroundColor Cyan
} else {
Write-Error "Executable not found at: $exePath"
exit 1
}
# Package
- name: Package
shell: bash

View File

@@ -61,7 +61,9 @@ jobs:
runVcpkgInstall: true
vcpkgJsonGlob: '**/vcpkg.json'
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgTriplet: '${{ matrix.platform }}-windows'
env:
VCPKG_FORCE_SYSTEM_BINARIES: 1
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
- name: Validate Visual Studio Build
shell: pwsh