Add GitHub Action build and test workflow for MSVC (#1201)

This commit is contained in:
alvinhochun 2022-10-15 06:15:09 +08:00 коммит произвёл GitHub
Родитель 3d83c679ea
Коммит 3ff66312a9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 79 добавлений и 2 удалений

70
.github/workflows/msvc.yml поставляемый Normal file
Просмотреть файл

@ -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
.gitignore поставляемый
Просмотреть файл

@ -8,10 +8,11 @@
*.nupkg
test*.xml
test*_results.txt
test_failures.txt
build
packages
Debug
Release
Generated Files
obj
vsix/LICENSE
vsix/LICENSE

Просмотреть файл

@ -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