Skip to content

Commit

Permalink
Improve CI jobs split (#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinhochun committed Oct 18, 2022
1 parent 956c8d2 commit d3aa5db
Show file tree
Hide file tree
Showing 13 changed files with 403 additions and 149 deletions.
234 changes: 219 additions & 15 deletions .github/workflows/ci.yml
Expand Up @@ -6,8 +6,8 @@ on:
- master

jobs:
test-msvc-cppwinrt:
name: 'MSVC: Tests'
test-msvc-cppwinrt-build:
name: 'MSVC: Build'
strategy:
matrix:
arch: [x86, x64, arm64]
Expand All @@ -19,33 +19,237 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Test all
- name: Download nuget
run: |
mkdir ".\.nuget"
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe"
- name: Find VsDevCmd.bat
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { exit 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
cmd /c "${VSDevCmd}" "&" build_test_all.cmd ${{ matrix.arch }} ${{ matrix.config }}
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd"
- name: Prepare build flags
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$target_version = "1.2.3.4"
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
- name: Restore nuget packages
run: |
cmd /c "$env:VSDevCmd" "&" nuget restore cppwinrt.sln
- name: Build fast_fwd
run: |
cmd /c "$env:VSDevCmd" "&" msbuild /m "$env:msbuild_config_props" cppwinrt.sln /t:fast_fwd
- name: Build cppwinrt
if: matrix.arch != 'arm64'
run: |
cmd /c "$env:VSDevCmd" "&" msbuild /m "$env:msbuild_config_props" cppwinrt.sln /t:cppwinrt
- name: Upload test log
- name: Upload built executables
if: matrix.arch != 'arm64'
uses: actions/upload-artifact@v3
with:
name: test-output-${{ matrix.arch }}-${{ matrix.config }}
path: "*_results.txt"
name: msvc-build-${{ matrix.arch }}-${{ matrix.config }}-bin
path: |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.exe
_build/${{ matrix.arch }}/${{ matrix.config }}/*.dll
_build/${{ matrix.arch }}/${{ matrix.config }}/*.winmd
_build/${{ matrix.arch }}/${{ matrix.config }}/*.lib
_build/${{ matrix.arch }}/${{ matrix.config }}/*.pdb
- name: Check test failure
- name: Run cppwinrt to build projection
if: matrix.arch != 'arm64'
run: |
if (Test-Path "test_failures.txt") {
Get-Content "test_failures.txt" | ForEach-Object {
echo "::error::Test '$_' failed!"
}
exit 1
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
& "_build\$target_platform\$target_configuration\cppwinrt.exe" -in local -out _build\$target_platform\$target_configuration -verbose
test-msvc-cppwinrt-test:
name: 'MSVC: Tests'
needs: test-msvc-cppwinrt-build
strategy:
fail-fast: false
matrix:
arch: [x86, x64]
config: [Debug, Release]
test_exe: [test, test_cpp20, test_win7, test_fast, test_slow, test_old, test_module_lock_custom, test_module_lock_none]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Fetch cppwinrt executables
uses: actions/download-artifact@v3
with:
name: msvc-build-${{ matrix.arch }}-${{ matrix.config }}-bin
path: _build/${{ matrix.arch }}/${{ matrix.config }}/

- name: Download nuget
run: |
mkdir ".\.nuget"
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe"
- name: Find VsDevCmd.bat
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { exit 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd"
- name: Prepare build flags
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$target_version = "1.2.3.4"
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
- name: Restore nuget packages
run: |
cmd /c "$env:VSDevCmd" "&" nuget restore cppwinrt.sln
- name: Remove cppwinrt dependency from all test projects
run: |
# HACK: We already have a built exe, so we want to avoid rebuilding cppwinrt
mv cppwinrt.sln cppwinrt.sln.orig
Get-Content cppwinrt.sln.orig |
Where-Object { -not $_.Contains("{D613FB39-5035-4043-91E2-BAB323908AF4} = {D613FB39-5035-4043-91E2-BAB323908AF4}") } |
Set-Content cppwinrt.sln
- name: Patch catch.hpp to make it build with ANSI colour
run: |
# HACK: Remove <unistd.h> include and the isatty call in catch.hpp to make ANSI colour build work
mv test/catch.hpp test/catch.hpp.orig
Get-Content test/catch.hpp.orig |
Where-Object { -not $_.Contains("#include <unistd.h>") } |
ForEach-Object {
$_.Replace("isatty(STDOUT_FILENO)", "false")
} |
Set-Content test/catch.hpp
- name: Run cppwinrt to build projection
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
& "_build\$target_platform\$target_configuration\cppwinrt.exe" -in local -out _build\$target_platform\$target_configuration -verbose
- name: Build test '${{ matrix.test_exe }}'
run: |
$test_proj = "${{ matrix.test_exe }}"
if ($test_proj -eq "test_old") {
$test_proj = "old_tests\test_old"
}
if (!(Test-Path "*_results.txt")) {
echo "::error::No test output found!"
cmd /c "$env:VSDevCmd" "&" msbuild /m /p:TestsUseAnsiColor=1 "$env:msbuild_config_props" cppwinrt.sln /t:test\$test_proj
- name: Run test '${{ matrix.test_exe }}'
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$test_exe = "${{ matrix.test_exe }}"
$test_path = "_build\$target_platform\$target_configuration\$test_exe.exe"
if (!(Test-Path $test_path)) {
echo "::error::Test $test_exe is missing."
exit 1
}
& $test_path --use-colour yes
build-msvc-natvis:
name: 'Build natvis'
strategy:
matrix:
arch: [x86, x64, arm64]
config: [Release]
Deployment: [Component, Standalone]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Download nuget
run: |
mkdir ".\.nuget"
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe"
- name: Find VsDevCmd.bat
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { exit 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd"
- name: Prepare build flags
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$target_version = "1.2.3.4"
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
- name: Restore nuget packages
run: |
cmd /c "$env:VSDevCmd" "&" nuget restore natvis\cppwinrtvisualizer.sln
- name: Build natvis
run: |
cmd /c "$env:VSDevCmd" "&" msbuild /m "$env:msbuild_config_props" /p:Deployment=${{ matrix.Deployment }} natvis\cppwinrtvisualizer.sln
build-msvc-nuget-test:
name: 'Build nuget test'
needs: test-msvc-cppwinrt-build
strategy:
matrix:
arch: [x86, x64]
config: [Release]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Fetch cppwinrt executables
uses: actions/download-artifact@v3
with:
name: msvc-build-${{ matrix.arch }}-${{ matrix.config }}-bin
path: _build/${{ matrix.arch }}/${{ matrix.config }}/

- name: Download nuget
run: |
mkdir ".\.nuget"
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe"
- name: Find VsDevCmd.bat
run: |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
if (!$VSDevCmd) { exit 1 }
echo "Using VSDevCmd: ${VSDevCmd}"
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd"
- name: Prepare build flags
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
$target_version = "1.2.3.4"
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version"
- name: Restore nuget packages
run: |
cmd /c "$env:VSDevCmd" "&" nuget restore test\nuget\NugetTest.sln
- name: Run cppwinrt to build projection
run: |
$target_configuration = "${{ matrix.config }}"
$target_platform = "${{ matrix.arch }}"
& "_build\$target_platform\$target_configuration\cppwinrt.exe" -in local -out _build\$target_platform\$target_configuration -verbose
- name: Run nuget test
run: |
cmd /c "$env:VSDevCmd" "&" msbuild /m "$env:msbuild_config_props" test\nuget\NugetTest.sln
if ($LastExitCode -ne 0) {
echo "::warning::nuget test failed"
}
# FIXME: This build was failing from the start
exit 0
build-nuget:
name: Build nuget package with MSVC
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.Props
Expand Up @@ -51,6 +51,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>CPPWINRT_VERSION_STRING="$(CppWinRTBuildVersion)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(TestsUseAnsiColor)'=='1'">CATCH_CONFIG_COLOUR_ANSI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalOptions>/bigobj</AdditionalOptions>
<AdditionalOptions Condition="'$(CppWinRTLanguageStandard)'==''">/await %(AdditionalOptions)</AdditionalOptions>
Expand Down
5 changes: 5 additions & 0 deletions test/old_tests/UnitTests/Main.cpp
@@ -1,3 +1,4 @@
#include <crtdbg.h>
#include "pch.h"

#define CATCH_CONFIG_RUNNER
Expand All @@ -9,6 +10,10 @@ int main(int argc, char * argv[])

init_apartment();
std::set_terminate([]{ reportFatal("Abnormal termination"); ExitProcess(1); });
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
int const result = Catch::Session().run(argc, argv);

// Completely unnecessary in an app, but useful for testing clear_factory_cache behavior.
Expand Down

0 comments on commit d3aa5db

Please sign in to comment.