Skip to content

Commit

Permalink
Add GitHub Action build and test workflow for MSVC (#1201)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinhochun committed Oct 14, 2022
1 parent 3d83c67 commit 3ff6631
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/msvc.yml
@@ -0,0 +1,70 @@
name: MSVC Tests
on:
push:
pull_request:
branches:
- master

jobs:
test-cppwinrt:
strategy:
matrix:
arch: [x86, x64, arm64]
config: [Debug, Release]
exclude:
- arch: arm64
config: Debug
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Test all
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { return 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
cmd /c "${VSDevCmd}" "&" build_test_all.cmd ${{ matrix.arch }} ${{ matrix.config }}
- name: Upload test log
if: matrix.arch != 'arm64'
uses: actions/upload-artifact@v3
with:
name: test-output-${{ matrix.arch }}-${{ matrix.config }}
path: "*_results.txt"

- name: Check test failure
if: matrix.arch != 'arm64'
run: |
if (Test-Path "test_failures.txt") {
Get-Content "test_failures.txt" | ForEach-Object {
Write-Error "error: Test '$_' failed!"
}
return 1
}
if (!(Test-Path "*_results.txt")) {
Write-Error "error: No test output found!"
return 1
}
build-nuget:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Package
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { return 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
cmd /c "${VSDevCmd}" "&" nuget.exe restore cppwinrt.sln
cmd /c "${VSDevCmd}" "&" build_nuget.cmd
if (!(Test-Path "*.nupkg")) {
Write-Error "error: Output nuget package not found!"
return 1
}
- name: Upload nuget package artifact
uses: actions/upload-artifact@v3
with:
name: package
path: "*.nupkg"
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -8,10 +8,11 @@
*.nupkg
test*.xml
test*_results.txt
test_failures.txt
build
packages
Debug
Release
Generated Files
obj
vsix/LICENSE
vsix/LICENSE
8 changes: 7 additions & 1 deletion run_tests.cmd
Expand Up @@ -21,5 +21,11 @@ goto :eof
:run_test
if not "%target_version%"=="" set args=-o %1-%target_version%.xml -r junit
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.
_build\%target_platform%\%target_configuration%\%1.exe %args% > %1_results.txt && type %1_results.txt || type %1_results.txt >&2
_build\%target_platform%\%target_configuration%\%1.exe %args% > %1_results.txt
if %ERRORLEVEL% EQU 0 (
type %1_results.txt
) else (
type %1_results.txt >&2
echo %1 >> test_failures.txt
)
goto :eof

0 comments on commit 3ff6631

Please sign in to comment.