-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (83 loc) · 3.28 KB
/
build.yml
File metadata and controls
96 lines (83 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Build Check
on: [pull_request, push]
permissions:
contents: read
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
include:
- arch: x64
runner: windows-latest
vcvars_arch: x64
- arch: x86
runner: windows-latest
vcvars_arch: x64_x86
- arch: arm64
runner: windows-11-arm
vcvars_arch: arm64
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Compile for ${{ matrix.arch }}
shell: cmd
run: |
REM Find vcvarsall.bat dynamically - check both possible vswhere.exe locations
set "VSWHERE_LEGACY=C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
set "VSWHERE_NATIVE=C:\Program Files\Microsoft Visual Studio\Installer\vswhere.exe"
if exist "%VSWHERE_LEGACY%" (
set "VSWHERE_PATH=%VSWHERE_LEGACY%"
) else if exist "%VSWHERE_NATIVE%" (
set "VSWHERE_PATH=%VSWHERE_NATIVE%"
) else (
echo Error: vswhere.exe not found in either location.
exit /b 1
)
for /f "usebackq tokens=*" %%i in (`"%VSWHERE_PATH%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set "VS_PATH=%%i"
)
if not exist "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" (
echo Error: vcvarsall.bat not found.
exit /b 1
)
REM Initialize environment for the target architecture
call "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.vcvars_arch }}
set outName=win-witr-${{ matrix.arch }}.exe
echo Compiling %outName%...
cl /O2 /GL /std:c++20 /EHsc main.cpp /DUNICODE /D_UNICODE /Fe:%outName%
if errorlevel 1 exit /b 1
- name: Run Tests for ${{ matrix.arch }}
shell: pwsh
run: |
# Add the current directory (where win-witr-${{ matrix.arch }}.exe was compiled) to PATH
$env:PATH = "$PWD;$env:PATH"
# Copy the architecture-specific exe to the generic name for tests
Copy-Item "win-witr-${{ matrix.arch }}.exe" "win-witr.exe"
# Verify the exe is accessible
Write-Host "Checking win-witr.exe availability..."
win-witr --version
if ($LASTEXITCODE -ne 0) {
Write-Error "it's broken 💥"
exit 1
}
# Run all test .bat and .ps1 files
$env:force_ansi = 1
# Run .bat files
Get-ChildItem -Path tests -Recurse -Filter *.bat | ForEach-Object {
Write-Host "Running test: $($_.FullName)"
& $_.FullName
if ($LASTEXITCODE -ne 0) {
Write-Error "Test failed: $($_.FullName)"
exit 1
}
}
# Run .ps1 files
Get-ChildItem -Path tests -Recurse -Filter *.ps1 | ForEach-Object {
Write-Host "Running test: $($_.FullName)"
& $_.FullName
if ($LASTEXITCODE -ne 0) {
Write-Error "Test failed: $($_.FullName)"
exit 1
}
}