diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml new file mode 100644 index 000000000..31cc53512 --- /dev/null +++ b/.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" diff --git a/.gitignore b/.gitignore index 39ccd342c..9493fdad5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,10 +8,11 @@ *.nupkg test*.xml test*_results.txt +test_failures.txt build packages Debug Release Generated Files obj -vsix/LICENSE \ No newline at end of file +vsix/LICENSE diff --git a/run_tests.cmd b/run_tests.cmd index 86ec520e1..cde12b1ec 100644 --- a/run_tests.cmd +++ b/run_tests.cmd @@ -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