From 732cdb69ef6584de1de6c62994cdd0f5a7b39763 Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Sat, 15 Oct 2022 01:03:45 +0800 Subject: [PATCH 1/5] Add GitHub Action workflow to test with MSVC build --- .github/workflows/msvc.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/msvc.yml diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml new file mode 100644 index 000000000..99123647c --- /dev/null +++ b/.github/workflows/msvc.yml @@ -0,0 +1,26 @@ +name: MSVC Tests +on: + push: + +jobs: + test-cppwinrt: + strategy: + matrix: + arch: [x86, x64] + config: [Debug, Release] + 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 + uses: actions/upload-artifact@v3 + with: + name: test-output-${{ matrix.arch }}-${{ matrix.config }} + path: ${{ matrix.arch }}_results.txt From e600383d7c2ba04c409e634bafbff16e05dca770 Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Sat, 15 Oct 2022 02:11:35 +0800 Subject: [PATCH 2/5] Check for failed tests --- .github/workflows/msvc.yml | 15 ++++++++++++++- .gitignore | 3 ++- run_tests.cmd | 8 +++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 99123647c..3fda859ed 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -23,4 +23,17 @@ jobs: uses: actions/upload-artifact@v3 with: name: test-output-${{ matrix.arch }}-${{ matrix.config }} - path: ${{ matrix.arch }}_results.txt + path: "*_results.txt" + + - name: Check test failure + 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 + } 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 From adbed350ea34bf313f2fc0775c29c60869a204d7 Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Sat, 15 Oct 2022 02:53:22 +0800 Subject: [PATCH 3/5] Add workflow to build nuget package --- .github/workflows/msvc.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 3fda859ed..c77e5b168 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -37,3 +37,26 @@ jobs: 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" From 5a801a12f10c450bc984492c03929907629233e8 Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Sat, 15 Oct 2022 03:20:19 +0800 Subject: [PATCH 4/5] Enable MSVC workflow on pull requests --- .github/workflows/msvc.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index c77e5b168..67b08132a 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -1,6 +1,9 @@ name: MSVC Tests on: push: + pull_request: + branches: + - master jobs: test-cppwinrt: From b8bf2be959d6bed5294674da54948a8baa22fc53 Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Sat, 15 Oct 2022 04:54:46 +0800 Subject: [PATCH 5/5] Enable arm64 test too which only builds cppwinrt without running --- .github/workflows/msvc.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 67b08132a..31cc53512 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -9,8 +9,11 @@ jobs: test-cppwinrt: strategy: matrix: - arch: [x86, x64] + arch: [x86, x64, arm64] config: [Debug, Release] + exclude: + - arch: arm64 + config: Debug runs-on: windows-latest steps: - uses: actions/checkout@v3 @@ -23,12 +26,14 @@ jobs: 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 {