From 28c0550a75ce81205ee81940c623ae7282c49f5c Mon Sep 17 00:00:00 2001 From: Elie Bariche <33458222+ebariche@users.noreply.github.com> Date: Fri, 29 May 2020 11:13:24 -0400 Subject: [PATCH] ci: Add dotnet templates integration tests --- .vsts-ci.yml | 4 + .../.azure-devops-project-template-tests.yml | 26 +++++++ build/run-template-tests.ps1 | 74 +++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 build/ci/.azure-devops-project-template-tests.yml create mode 100644 build/run-template-tests.ps1 diff --git a/.vsts-ci.yml b/.vsts-ci.yml index cc9dbbc7f22e..bfcee6135390 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -29,6 +29,10 @@ jobs: parameters: vmImage: '$(windowsVMImage)' +- template: build/ci/.azure-devops-project-template-tests.yml + parameters: + vmImage: $(windowsVMImage) + - template: build/ci/.azure-devops-uap.yml parameters: vmImage: '$(windowsVMImage)' diff --git a/build/ci/.azure-devops-project-template-tests.yml b/build/ci/.azure-devops-project-template-tests.yml new file mode 100644 index 000000000000..36d82bd5715c --- /dev/null +++ b/build/ci/.azure-devops-project-template-tests.yml @@ -0,0 +1,26 @@ +parameters: + vmImage: '' + +jobs: +- job: Dotnet_Template_Tests + + pool: + vmImage: ${{ parameters.vmImage }} + + dependsOn: VS_Latest + + steps: + - task: DownloadBuildArtifacts@0 + inputs: + artifactName: NugetPackages + + - script: copy $(System.ArtifactsDirectory)\NugetPackages\vslatest\*.nupkg $(Build.SourcesDirectory)\src\PackageCache + displayName: Copy Artifacts to PackageCache + + - script: dotnet new -i $(System.ArtifactsDirectory)\NugetPackages\vslatest\Uno.ProjectTemplates.Dotnet*.nupkg + displayName: Install Project Templates + + - powershell: build\run-template-tests.ps1 + displayName: Run Project Templates Tests + env: + NUGET_CI_CONFIG: $(Build.SourcesDirectory)\src\nuget.ci.config diff --git a/build/run-template-tests.ps1 b/build/run-template-tests.ps1 new file mode 100644 index 000000000000..f2d0e647aa0a --- /dev/null +++ b/build/run-template-tests.ps1 @@ -0,0 +1,74 @@ +$ErrorActionPreference = 'Stop' + +function Get-TemplateConfiguration( + [bool]$uwp = $false, + [bool]$android = $false, + [bool]$iOS = $false, + [bool]$macOS = $false, + [bool]$wasm = $false, + [bool]$wasmVsCode = $false) +{ + $uwpFlag = '-uwp' + $androidFlag = '-android' + $iOSFlag = '-ios' + $macOSFlag = '-macos' + $wasmFlag = '-wasm' + $wasmVsCodeFlag = '--vscodeWasm' + + $a = If ($uwp) { $uwpFlag } Else { $uwpFlag + '=false' } + $b = If ($android) { $androidFlag } Else { $androidFlag + '=false' } + $c = If ($iOS) { $iOSFlag } Else { $iOSFlag + '=false' } + $d = If ($macOS) { $macOSFlag } Else { $macOSFlag + '=false' } + $e = If ($wasm) { $wasmFlag } Else { $wasmFlag + '=false' } + $f = If ($wasmVsCode) { $wasmVsCodeFlag } Else { $wasmVsCodeFlag + '=false' } + + @($a, $b, $c, $d, $e, $f) +} + +$msbuild = vswhere -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe + +$default = @('/ds', '/r', "/p:RestoreConfigFile=$env:NUGET_CI_CONFIG", '/p:PackageCertificateKeyFile=') + +$debug = $default + '/p:Configuration=Debug' + +$release = $default + '/p:AotAssemblies=false' + '/p:Configuration=Release' +$releaseX64 = $release + '/p:Platform=x64' +$releaseIPhone = $release + '/p:Platform=iPhone' +$releaseIPhoneSimulator = $release + '/p:Platform=iPhoneSimulator' + +$templateConfigurations = +@( + (Get-TemplateConfiguration -uwp 1), + (Get-TemplateConfiguration -android 1), + (Get-TemplateConfiguration -iOS 1), + (Get-TemplateConfiguration -macOS 1), + (Get-TemplateConfiguration -wasm 1) +) + +$configurations = +@( + @($templateConfigurations[0], $releaseX64), + @($templateConfigurations[1], $release), + @($templateConfigurations[2], $releaseIPhone), + @($templateConfigurations[3], $releaseIPhoneSimulator), + @($templateConfigurations[4], $release) +) + +# Default +dotnet new unoapp -n UnoAppAll +& $msbuild $debug UnoAppAll\UnoAppAll.sln + +# Heads - Release +for($i = 0; $i -lt $configurations.Length; $i++) +{ + dotnet new unoapp -n "UnoApp$i" $configurations[$i][0] + & $msbuild $configurations[$i][1] "UnoApp$i\UnoApp$i.sln" +} + +# VS Code +dotnet new unoapp -n UnoAppVsCode (Get-TemplateConfiguration -wasm 1 -wasmVsCode 1) +dotnet build -p:RestoreConfigFile=$env:NUGET_CI_CONFIG UnoAppVsCode\UnoAppVsCode.sln + +# WinUI - Release +# dotnet new unoapp-winui -n UnoAppWinUI +# & $msbuild $release UnoAppWinUI\UnoAppWinUI.sln