From 9f429f02067e57648886e3aced0c32c44a4b17ea Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Fri, 26 Apr 2019 15:41:07 -0700 Subject: [PATCH] Build test packages for windows, linux-x64, linux-arm, linux-arm64 and macOS (#9476) --- build.psm1 | 17 ++++-- tools/releaseBuild/azureDevOps/diagram.puml | 2 + tools/releaseBuild/azureDevOps/diagram.svg | 10 ++-- .../releaseBuild/azureDevOps/releaseBuild.yml | 13 ----- .../azureDevOps/templates/testartifacts.yml | 55 ++++++++++--------- 5 files changed, 51 insertions(+), 46 deletions(-) diff --git a/build.psm1 b/build.psm1 index 6e173b246f..9a14f5f8c2 100644 --- a/build.psm1 +++ b/build.psm1 @@ -842,7 +842,10 @@ function Get-PesterTag { function Publish-PSTestTools { [CmdletBinding()] - param() + param( + [string] + $runtime + ) Find-Dotnet @@ -859,7 +862,12 @@ function Publish-PSTestTools { { Push-Location $tool.Path try { - dotnet publish --output bin --configuration $Options.Configuration --framework $Options.Framework --runtime $Options.Runtime + if (-not $runtime) { + dotnet publish --output bin --configuration $Options.Configuration --framework $Options.Framework --runtime $Options.Runtime + } else { + dotnet publish --output bin --configuration $Options.Configuration --framework $Options.Framework --runtime $runtime + } + $toolPath = Join-Path -Path $tool.Path -ChildPath "bin" if ( -not $env:PATH.Contains($toolPath) ) { @@ -2974,7 +2982,8 @@ function New-TestPackage [CmdletBinding()] param( [Parameter(Mandatory = $true)] - [string] $Destination + [string] $Destination, + [string] $Runtime ) if (Test-Path $Destination -PathType Leaf) @@ -3002,7 +3011,7 @@ function New-TestPackage Write-Verbose -Verbose "PackagePath: $packagePath" # Build test tools so they are placed in appropriate folders under 'test' then copy to package root. - $null = Publish-PSTestTools + $null = Publish-PSTestTools -runtime $Runtime $powerShellTestRoot = Join-Path $PSScriptRoot 'test' Copy-Item $powerShellTestRoot -Recurse -Destination $packageRoot -Force Write-Verbose -Message "Copied test directory" diff --git a/tools/releaseBuild/azureDevOps/diagram.puml b/tools/releaseBuild/azureDevOps/diagram.puml index b72312ae50..ade53b11b9 100644 --- a/tools/releaseBuild/azureDevOps/diagram.puml +++ b/tools/releaseBuild/azureDevOps/diagram.puml @@ -39,6 +39,8 @@ folder "Package Signing and Upload" as PkgSignUpload { folder "Build Test Artifacts" as TestArtifacts { agent "Windows" as WinTest agent "Linux" as LinuxTest + agent "Linux-ARM" as LinuxArmTest + agent "Linux-ARM64" as LinuxArm64Test } agent "Compliance" as Compliance diff --git a/tools/releaseBuild/azureDevOps/diagram.svg b/tools/releaseBuild/azureDevOps/diagram.svg index 5d1b162f1a..024128bf98 100644 --- a/tools/releaseBuild/azureDevOps/diagram.svg +++ b/tools/releaseBuild/azureDevOps/diagram.svg @@ -1,4 +1,4 @@ -Linux BuildsWindows BuildsLinux Package Scanning and UploadPackage Signing and UploadBuild Test ArtifactsDEBRPMAlpineLinux-FxDependentx64x86arm32arm64FxDependentDEBRPMAlpineLinux-FxDependentmacOSWindowsWindowsLinuxmacOS BuildUpload build metadataComponentRegistrationComplianceCreate SDK and Global Tool and UploadFinishStartLinux BuildsWindows BuildsLinux Package Scanning and UploadPackage Signing and UploadBuild Test ArtifactsDEBRPMAlpineLinux-FxDependentx64x86arm32arm64FxDependentDEBRPMAlpineLinux-FxDependentmacOSWindowsWindowsLinuxLinux-ARMLinux-ARM64macOS BuildUpload build metadataComponentRegistrationComplianceCreate SDK and Global Tool and UploadFinishStart \ No newline at end of file diff --git a/tools/releaseBuild/azureDevOps/releaseBuild.yml b/tools/releaseBuild/azureDevOps/releaseBuild.yml index 481341d093..be7714dd13 100644 --- a/tools/releaseBuild/azureDevOps/releaseBuild.yml +++ b/tools/releaseBuild/azureDevOps/releaseBuild.yml @@ -88,19 +88,6 @@ jobs: - build_macOS - template: templates/testartifacts.yml - parameters: - buildName: windows - pool: Hosted VS2017 - -- template: templates/testartifacts.yml - parameters: - buildName: linux - pool: Hosted Ubuntu 1604 - -- template: templates/testartifacts.yml - parameters: - buildName: macOS - pool: Hosted Mac Internal - job: release_json displayName: Create and Upload release.json diff --git a/tools/releaseBuild/azureDevOps/templates/testartifacts.yml b/tools/releaseBuild/azureDevOps/templates/testartifacts.yml index 8ebe18b0bb..3e72ed7038 100644 --- a/tools/releaseBuild/azureDevOps/templates/testartifacts.yml +++ b/tools/releaseBuild/azureDevOps/templates/testartifacts.yml @@ -1,12 +1,8 @@ -parameters: - buildName: 'linux' - pool: 'Hosted Ubuntu 1604' - jobs: -- job: build_testartifacts_${{ parameters.buildName }} - displayName: Build test artifacts ${{ parameters.buildName }} +- job: build_testartifacts + displayName: Build test artifacts condition: succeeded() - pool: ${{ parameters.pool }} + pool: 'Hosted Ubuntu 1604' steps: - pwsh: | @@ -16,26 +12,35 @@ jobs: - pwsh: | Import-Module ./build.psm1 - New-TestPackage -Destination $(System.ArtifactsDirectory) - displayName: Build test package - - pwsh: | - if (-not (Test-Path $(System.ArtifactsDirectory)/TestPackage.zip)) + function BuildTestPackage([string] $runtime) { - throw "Test Package was not found at: $(System.ArtifactsDirectory)" + Write-Verbose -Verbose "Starting to build package for $runtime" + + New-TestPackage -Destination $(System.ArtifactsDirectory) -Runtime $runtime + + if (-not (Test-Path $(System.ArtifactsDirectory)/TestPackage.zip)) + { + throw "Test Package was not found at: $(System.ArtifactsDirectory)" + } + + switch ($runtime) + { + win7-x64 { $packageName = "TestPackage-win.zip" } + linux-x64 { $packageName = "TestPackage-linux-x64.zip" } + linux-arm { $packageName = "TestPackage-linux-arm.zip" } + linux-arm64 { $packageName = "TestPackage-linux-arm64.zip" } + osx-x64 { $packageName = "TestPackage-macOS.zip" } + } + + Rename-Item $(System.ArtifactsDirectory)/TestPackage.zip $packageName + Write-Host "##vso[artifact.upload containerfolder=testArtifacts;artifactname=testArtifacts]$(System.ArtifactsDirectory)/$packageName" } - $packageName = if ($IsWindows) { - "TestPackage-win.zip" - } - elseif ($IsLinux) { - "TestPackage-linux.zip" - } - else { - "TestPackage-macOS.zip" - } + BuildTestPackage -runtime win7-x64 + BuildTestPackage -runtime linux-x64 + BuildTestPackage -runtime linux-arm + BuildTestPackage -runtime linux-arm64 + BuildTestPackage -runtime osx-x64 - Rename-Item $(System.ArtifactsDirectory)/TestPackage.zip $packageName - - Write-Host "##vso[artifact.upload containerfolder=testArtifacts;artifactname=testArtifacts]$(System.ArtifactsDirectory)/$packageName" - displayName: Upload to build artifacts + displayName: Build test package and upload