chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
name: Windows Build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
# Windows build and test matrix
|
||||
build-and-test-windows:
|
||||
name: Build & Test (${{ matrix.platform }})
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- platform: windows-2022
|
||||
- platform: windows-2025
|
||||
|
||||
env:
|
||||
SCCACHE_GHA_ENABLED: "true"
|
||||
|
||||
steps:
|
||||
- name: Show env info
|
||||
run: |
|
||||
Get-CimInstance -ClassName Win32_Processor
|
||||
where cl
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -all -products * -prerelease -format json
|
||||
shell: powershell
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Cleanup left marker files
|
||||
run: |
|
||||
git submodule foreach --recursive 'git reset --hard && git clean -ffdx'
|
||||
shell: powershell
|
||||
|
||||
- name: Setup sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.10
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.10'
|
||||
cache: 'pip'
|
||||
cache-dependency-path: 'pyproject.toml'
|
||||
|
||||
- name: Set up MSVC environment
|
||||
uses: ilammy/msvc-dev-cmd@v1.13.0
|
||||
with:
|
||||
arch: x64
|
||||
|
||||
- name: Set up environment variables
|
||||
run: |
|
||||
$nproc = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors
|
||||
echo "NPROC=$nproc" >> $env:GITHUB_ENV
|
||||
echo "Using $nproc parallel jobs for builds"
|
||||
shell: powershell
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip `
|
||||
pybind11==3.0 `
|
||||
cmake==3.30.0 `
|
||||
ninja==1.11.1 `
|
||||
pytest `
|
||||
pytest-xdist `
|
||||
scikit-build-core `
|
||||
setuptools_scm
|
||||
shell: powershell
|
||||
|
||||
- name: Build from source
|
||||
run: |
|
||||
cd "$env:GITHUB_WORKSPACE"
|
||||
$env:CMAKE_GENERATOR = "Ninja"
|
||||
$env:CMAKE_BUILD_PARALLEL_LEVEL = "$env:NPROC"
|
||||
python -m pip install -v . `
|
||||
--no-build-isolation `
|
||||
--config-settings='cmake.define.BUILD_TOOLS=ON' `
|
||||
--config-settings='cmake.define.ENABLE_WERROR=ON' `
|
||||
--config-settings='cmake.define.CMAKE_C_COMPILER_LAUNCHER=sccache' `
|
||||
--config-settings='cmake.define.CMAKE_CXX_COMPILER_LAUNCHER=sccache'
|
||||
shell: powershell
|
||||
|
||||
- name: Show sccache statistics after pip install
|
||||
if: always()
|
||||
run: sccache --show-stats
|
||||
shell: powershell
|
||||
|
||||
- name: Run C++ Tests
|
||||
run: |
|
||||
cd "$env:GITHUB_WORKSPACE\build"
|
||||
cmake --build . --target unittest --config Release --parallel $env:NPROC
|
||||
shell: powershell
|
||||
|
||||
- name: Show sccache statistics after tests
|
||||
if: always()
|
||||
run: sccache --show-stats
|
||||
shell: powershell
|
||||
|
||||
- name: Run Python Tests
|
||||
run: |
|
||||
cd "$env:GITHUB_WORKSPACE"
|
||||
python -m pytest python/tests/ --basetemp=./.pytest_tmp
|
||||
shell: powershell
|
||||
|
||||
- name: Run C++ Examples
|
||||
run: |
|
||||
cd "$env:GITHUB_WORKSPACE\examples\c++"
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=sccache `
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
|
||||
cmake --build . --config Release --parallel $env:NPROC
|
||||
|
||||
# Copy zvec DLLs next to the example executables so Windows can find them.
|
||||
# CMake places DLLs in bin/ (RUNTIME output) and import libs in lib/.
|
||||
$buildDir = "$env:GITHUB_WORKSPACE\build"
|
||||
foreach ($dllName in @("zvec.dll", "zvec_core.dll", "zvec_ailego.dll")) {
|
||||
$found = $false
|
||||
foreach ($sub in @("$buildDir\bin", "$buildDir\bin\Release", "$buildDir\lib", "$buildDir\lib\Release")) {
|
||||
$dllPath = Join-Path $sub $dllName
|
||||
if (Test-Path $dllPath) {
|
||||
Copy-Item $dllPath -Destination . -Force
|
||||
Write-Host "Copied $dllName from $sub"
|
||||
$found = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (-not $found) {
|
||||
Write-Host "WARNING: $dllName not found, searching recursively..."
|
||||
$dll = Get-ChildItem -Path $buildDir -Filter $dllName -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if ($dll) {
|
||||
Copy-Item $dll.FullName -Destination . -Force
|
||||
Write-Host "Copied $dllName from $($dll.DirectoryName)"
|
||||
} else {
|
||||
Write-Error "$dllName not found anywhere under $buildDir"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.\db-example.exe
|
||||
.\core-example.exe
|
||||
.\ailego-example.exe
|
||||
shell: powershell
|
||||
|
||||
- name: Show sccache statistics
|
||||
if: always()
|
||||
run: sccache --show-stats
|
||||
shell: powershell
|
||||
Reference in New Issue
Block a user