Skip to content

Build Windows

Build Windows #111

Workflow file for this run

---
name: Build Windows
on:
workflow_dispatch:
workflow_call:
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: powershell
env:
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}\.github\.environment\vcpkg\archives
VCPKG_DOWNLOADS: ${{ github.workspace }}\.github\.environment\vcpkg\downloads
VCPKG_FEATURE_FLAGS: manifests,binarycaching
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\.github\.environment\vcpkg\archives,readwrite
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Bump version in header
run: |
$version = "dev"
if ( "${{ github.event_name }}" -eq "pull_request" ){
$version="${{ github.sha }}"
}
if ("${{ github.event_name }}" -eq "workflow_dispatch" ){
$version="${{ github.sha }}"
}
if ( ("${{github.event_name}}" -eq "push") -and ("${{github.ref_type}}" -eq "tag" )){
$ref="${{ github.ref }}"
$version=$ref.Split("/")[-1]
}
Write-Host "Setting version to $version"
$path = "Cell2Fire\Cell2Fire.h"
(Get-Content $path) -replace 'C2FW_VERSION\s*=\s*".*?"', "C2FW_VERSION = `"$version`"" | Set-Content $path
Select-String 'C2FW_VERSION' $path
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v3
- name: Prepare vcpkg workspace dirs
run: |
New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\.github\.environment\vcpkg\archives" | Out-Null
New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\.github\.environment\vcpkg\downloads" | Out-Null
- name: Cache vcpkg (archives, downloads, installed)
uses: actions/cache@v5
with:
path: |
${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
${{ env.VCPKG_DOWNLOADS }}
Cell2Fire\vcpkg_installed
key: vcpkg-${{ vars.CACHE_EPOCH }}-cache-key-${{ hashFiles('Cell2Fire/vcpkg.json') }}
- name: Show vcpkg paths (pre-build)
if: ${{ false }}
run: |
cd Cell2Fire
$archives = $env:VCPKG_DEFAULT_BINARY_CACHE
$downloads = $env:VCPKG_DOWNLOADS
$installed = Join-Path $PWD "vcpkg_installed"
Write-Host "Archives path=$archives"
Write-Host "Downloads path=$downloads"
Write-Host "Install root (project)=$installed"
function Show-DirSummary($label, $path) {
if (Test-Path $path) {
$count = (Get-ChildItem $path -Recurse -File -ErrorAction SilentlyContinue | Measure-Object).Count
Write-Host "$label exists, files=$count"
} else {
Write-Host "$label does not exist"
}
}
Show-DirSummary "Archives" $archives
Show-DirSummary "Downloads" $downloads
Show-DirSummary "Installed" $installed
- name: Ensure vcpkg registry has required baseline
run: |
$root = $env:VCPKG_INSTALLATION_ROOT
Write-Host "VCPKG_INSTALLATION_ROOT=$root"
if (Test-Path (Join-Path $root ".git")) {
Write-Host "Ensuring baseline commit exists in vcpkg registry (assuming complete repo)..."
$manifest = Get-Content "$env:GITHUB_WORKSPACE\Cell2Fire\vcpkg.json" | ConvertFrom-Json
$baseline = $manifest."builtin-baseline"
Write-Host "Pinned baseline=$baseline"
git -C $root fetch --prune --tags
git -C $root fetch origin $baseline
git -C $root show -s --format=%H $baseline
} else {
Write-Host "vcpkg root is not a git repo; skipping registry fetch."
}
- name: Build Solution
run: |
cd Cell2Fire
vcpkg integrate install
msbuild Cell2Fire.sln /m /t:Clean,Build /p:Configuration=Release /p:Platform=x64 /p:VcpkgEnableManifest=true
- name: Show vcpkg paths (post-build)
if: ${{ false }}
run: |
cd Cell2Fire
$archives = $env:VCPKG_DEFAULT_BINARY_CACHE
$downloads = $env:VCPKG_DOWNLOADS
$installed = Join-Path $PWD "vcpkg_installed"
Write-Host "Archives path=$archives"
Write-Host "Downloads path=$downloads"
Write-Host "Install root (project)=$installed"
function Show-DirSummary($label, $path) {
if (Test-Path $path) {
$count = (Get-ChildItem $path -Recurse -File -ErrorAction SilentlyContinue | Measure-Object).Count
Write-Host "$label exists, files=$count"
} else {
Write-Host "$label does not exist"
}
}
Show-DirSummary "Archives" $archives
Show-DirSummary "Downloads" $downloads
Show-DirSummary "Installed" $installed
- name: Run Unit Tests
if: ${{ vars.RUN_UNIT_TESTS == 'true' }}
run: |
& "Cell2Fire\x64\Release\WindowsTests.exe"
$exitCode = $LASTEXITCODE
exit $exitCode
- name: Gather output
run: |
mkdir binaries
copy Cell2Fire\x64\Release\*.dll binaries
copy Cell2Fire\x64\Release\Cell2Fire.exe binaries
- name: Upload artifact (real or placeholder)
uses: actions/upload-artifact@v7
with:
name: binaries-Windows-x86_64
path: binaries
regression_tests:
needs: build
if: ${{ vars.RUN_REGRESSION_TESTS == 'true' }}
runs-on: windows-latest
steps:
- name: Checkout tests only
uses: actions/checkout@v6
with:
sparse-checkout: |
test/
sparse-checkout-cone-mode: false
- name: Download Artifacts
uses: actions/download-artifact@v8
with:
name: binaries-Windows-x86_64
path: Cell2Fire
- name: Run Regression Test
run: |-
cd test
./test.ps1 ../Cell2Fire/Cell2Fire.exe