Skip to content

Commit 3ff6631

Browse files
authored
Add GitHub Action build and test workflow for MSVC (#1201)
1 parent 3d83c67 commit 3ff6631

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

.github/workflows/msvc.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: MSVC Tests
2+
on:
3+
push:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
test-cppwinrt:
10+
strategy:
11+
matrix:
12+
arch: [x86, x64, arm64]
13+
config: [Debug, Release]
14+
exclude:
15+
- arch: arm64
16+
config: Debug
17+
runs-on: windows-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Test all
22+
run: |
23+
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
24+
if (!$VSDevCmd) { return 1 }
25+
echo "Using VSDevCmd: ${VSDevCmd}"
26+
cmd /c "${VSDevCmd}" "&" build_test_all.cmd ${{ matrix.arch }} ${{ matrix.config }}
27+
28+
- name: Upload test log
29+
if: matrix.arch != 'arm64'
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: test-output-${{ matrix.arch }}-${{ matrix.config }}
33+
path: "*_results.txt"
34+
35+
- name: Check test failure
36+
if: matrix.arch != 'arm64'
37+
run: |
38+
if (Test-Path "test_failures.txt") {
39+
Get-Content "test_failures.txt" | ForEach-Object {
40+
Write-Error "error: Test '$_' failed!"
41+
}
42+
return 1
43+
}
44+
if (!(Test-Path "*_results.txt")) {
45+
Write-Error "error: No test output found!"
46+
return 1
47+
}
48+
49+
build-nuget:
50+
runs-on: windows-latest
51+
steps:
52+
- uses: actions/checkout@v3
53+
54+
- name: Package
55+
run: |
56+
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
57+
if (!$VSDevCmd) { return 1 }
58+
echo "Using VSDevCmd: ${VSDevCmd}"
59+
cmd /c "${VSDevCmd}" "&" nuget.exe restore cppwinrt.sln
60+
cmd /c "${VSDevCmd}" "&" build_nuget.cmd
61+
if (!(Test-Path "*.nupkg")) {
62+
Write-Error "error: Output nuget package not found!"
63+
return 1
64+
}
65+
66+
- name: Upload nuget package artifact
67+
uses: actions/upload-artifact@v3
68+
with:
69+
name: package
70+
path: "*.nupkg"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
*.nupkg
99
test*.xml
1010
test*_results.txt
11+
test_failures.txt
1112
build
1213
packages
1314
Debug
1415
Release
1516
Generated Files
1617
obj
17-
vsix/LICENSE
18+
vsix/LICENSE

run_tests.cmd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,11 @@ goto :eof
2121
:run_test
2222
if not "%target_version%"=="" set args=-o %1-%target_version%.xml -r junit
2323
rem Buffer output and redirect to stdout/stderr depending whether the test executable exits successfully. Pipeline will fail if there's any output to stderr.
24-
_build\%target_platform%\%target_configuration%\%1.exe %args% > %1_results.txt && type %1_results.txt || type %1_results.txt >&2
24+
_build\%target_platform%\%target_configuration%\%1.exe %args% > %1_results.txt
25+
if %ERRORLEVEL% EQU 0 (
26+
type %1_results.txt
27+
) else (
28+
type %1_results.txt >&2
29+
echo %1 >> test_failures.txt
30+
)
2531
goto :eof

0 commit comments

Comments
 (0)