Skip to content

Commit 9c6174d

Browse files
committed
Add windows job to CI build & test
1 parent 5d05a2b commit 9c6174d

File tree

2 files changed

+63
-7
lines changed

2 files changed

+63
-7
lines changed

.github/workflows/build_test.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,31 @@ jobs:
2727
run: git diff --exit-code
2828
- name: Checking code style
2929
run: ./scripts/run-clang-tidy.sh
30+
3031
build:
31-
runs-on: ubuntu-latest
32+
strategy:
33+
matrix:
34+
os: [ubuntu-latest, windows-latest]
35+
include:
36+
- os: ubuntu-latest
37+
setup-script: ./scripts/setup-ubuntu.sh
38+
- os: windows-latest
39+
setup-script: ./scripts/find_vs.ps1
40+
runs-on: ${{ matrix.os }}
3241

3342
steps:
3443
- uses: actions/checkout@v3
3544
with:
3645
submodules: recursive
37-
- name: Setup Ubuntu
46+
47+
- name: Build
3848
run: |
39-
./scripts/setup-ubuntu.sh
49+
${{ matrix.setup-script }}
4050
mkdir build
41-
- name: Run cmake
42-
run: |
4351
cmake --version
4452
cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TZ_LIB=ON
45-
- name: Build
46-
run: ninja -C build
53+
ninja -C build
54+
4755
- name: Test
4856
run: ctest --test-dir build --output-on-failure --timeout 30
4957

scripts/find_vs.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Find and enter a Visual Studio development environment.
2+
# Required to use Ninja instead of msbuild on our build agents.
3+
function Enter-VsDevEnv {
4+
[CmdletBinding()]
5+
param(
6+
[Parameter()]
7+
[switch]$Prerelease,
8+
[Parameter()]
9+
[string]$architecture = "x64"
10+
)
11+
12+
$ErrorActionPreference = 'Stop'
13+
14+
if ($null -eq (Get-InstalledModule -name 'VSSetup' -ErrorAction SilentlyContinue)) {
15+
Install-Module -Name 'VSSetup' -Scope CurrentUser -SkipPublisherCheck -Force
16+
}
17+
Import-Module -Name 'VSSetup'
18+
19+
Write-Verbose 'Searching for VC++ instances'
20+
$vsinfo = `
21+
Get-VSSetupInstance -All -Prerelease:$Prerelease `
22+
| Select-VSSetupInstance `
23+
-Latest -Product * `
24+
-Require 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64'
25+
26+
$vspath = $vsinfo.InstallationPath
27+
28+
switch ($env:PROCESSOR_ARCHITECTURE) {
29+
"amd64" { $hostarch = "x64" }
30+
"x86" { $hostarch = "x86" }
31+
"arm64" { $hostarch = "arm64" }
32+
default { throw "Unknown architecture: $switch" }
33+
}
34+
35+
$devShellModule = "$vspath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
36+
37+
Import-Module -Global -Name $devShellModule
38+
39+
Write-Verbose 'Setting up environment variables'
40+
Enter-VsDevShell -VsInstanceId $vsinfo.InstanceId -SkipAutomaticLocation `
41+
-devCmdArguments "-arch=$architecture -host_arch=$hostarch"
42+
43+
Set-Item -Force -path "Env:\Platform" -Value $architecture
44+
45+
remove-Module Microsoft.VisualStudio.DevShell, VSSetup
46+
}
47+
48+
Enter-VsDevEnv

0 commit comments

Comments
 (0)