Log binary sizes (excl. UWP changes) (#3357)
* Output binary sizes (Get-BinarySizes.ps1 works for linux environment) * Add better support for Windows binary output * Update matrix to properly build Debug and Release on Windows * Add TEAMPROJECTID to spell check * Add extra labels * Ensure BuildArgs doesn't get duplicated * Log additional metrics * Add openssl to Win32Api_curl * SourceBranchName -> SourceBranch * Fix matrix entries * Document included * Review feedback for Get-BinarySizes.ps1 * Infer many metrics from the environment * Add issecret to cspell.json * Extra equal signs * Correct directory depth for $BuildDirectory * Correct casing for mac VM image
This commit is contained in:
parent
cd2e916296
commit
44310b635a
7
.vscode/cspell.json
vendored
7
.vscode/cspell.json
vendored
@ -138,6 +138,13 @@
|
||||
"mspremier"
|
||||
]
|
||||
},
|
||||
{
|
||||
"filename": "**/eng/**",
|
||||
"words": [
|
||||
"TEAMPROJECTID",
|
||||
"issecret"
|
||||
]
|
||||
},
|
||||
{
|
||||
"filename": "**/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/key_client_models.hpp",
|
||||
"words": [
|
||||
|
||||
@ -204,6 +204,24 @@ jobs:
|
||||
coverageThreshold: ${{ parameters.BranchCoverageTarget }}
|
||||
condition: and(succeededOrFailed(), eq(variables['CODE_COVERAGE'], 'enabled'), eq(variables['Skip.BranchCoverageEnforcement'], ''))
|
||||
|
||||
- task: Powershell@2
|
||||
inputs:
|
||||
filePath: $(Build.SourcesDirectory)/eng/scripts/Get-BinarySizes.ps1
|
||||
arguments: >-
|
||||
-ServiceDirectory ${{parameters.ServiceDirectory}}
|
||||
-OsVMImage '$(OSVmImage)'
|
||||
-CmakeEnvArg '$(CmakeEnvArg)'
|
||||
-BuildArgs '$(BuildArgs)'
|
||||
-Job '$(Agent.JobName)'
|
||||
-BuildReason '$(Build.Reason)'
|
||||
-SourceBranch '$(Build.SourceBranch)'
|
||||
-ExtraLabels @{
|
||||
MetricVersion = 1;
|
||||
}
|
||||
pwsh: true
|
||||
workingDirectory: $(Pipeline.Workspace)
|
||||
displayName: Report Binary Sizes
|
||||
|
||||
# Use the job name to create the artifact name for MAP file publishing.
|
||||
# Attempts are also noted starting with 1
|
||||
# "Validate Windows2019_UWP_debug_x86" -> "Windows2019_UWP_debug_x86_attempt_1"
|
||||
|
||||
@ -37,24 +37,25 @@
|
||||
"Windows2019": {
|
||||
"OSVmImage": "MMS2019",
|
||||
"Pool": "azsdk-pool-mms-win-2019-general",
|
||||
"BuildArgs": "--parallel 8",
|
||||
"CMAKE_GENERATOR": "Visual Studio 16 2019"
|
||||
}
|
||||
},
|
||||
"TargetPlatform": {
|
||||
"Win32Api_curl": {
|
||||
"VcpkgInstall": "curl[winssl] openssl",
|
||||
"CmakeArgs": " -DBUILD_TRANSPORT_CURL=ON"
|
||||
"CmakeArgs": " -DBUILD_TRANSPORT_CURL=ON",
|
||||
"BuildArgs": "--parallel 8"
|
||||
},
|
||||
"Win32Api_release_curl": {
|
||||
"VcpkgInstall": "curl[winssl] openssl",
|
||||
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON",
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"BuildArgs": "--parallel 8 --config Release",
|
||||
"PublishMapFiles": "true"
|
||||
},
|
||||
"Win32Api_debug_tests": {
|
||||
"VcpkgInstall": "curl[winssl] openssl",
|
||||
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON -DBUILD_TRANSPORT_WINHTTP=ON",
|
||||
"BuildArgs": "--parallel 8 --config Debug",
|
||||
"PublishMapFiles": "true"
|
||||
}
|
||||
},
|
||||
@ -74,7 +75,6 @@
|
||||
"Windows2019": {
|
||||
"OSVmImage": "MMS2019",
|
||||
"Pool": "azsdk-pool-mms-win-2019-general",
|
||||
"BuildArgs": "--parallel 8",
|
||||
"CMAKE_GENERATOR": "Visual Studio 16 2019",
|
||||
"CmakeArgs": " -DBUILD_TRANSPORT_WINHTTP=ON ",
|
||||
"PublishMapFiles": "true"
|
||||
@ -84,13 +84,14 @@
|
||||
"UWP_debug": {
|
||||
"VcpkgInstall": "openssl",
|
||||
"CMAKE_SYSTEM_NAME": "WindowsStore",
|
||||
"CMAKE_SYSTEM_VERSION": "10.0"
|
||||
"CMAKE_SYSTEM_VERSION": "10.0",
|
||||
"BuildArgs": "--parallel 8 --config Debug"
|
||||
},
|
||||
"UWP_release": {
|
||||
"VcpkgInstall": "openssl",
|
||||
"CMAKE_SYSTEM_NAME": "WindowsStore",
|
||||
"CMAKE_SYSTEM_VERSION": "10.0",
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
"BuildArgs": "--parallel 8 --config Release"
|
||||
}
|
||||
},
|
||||
"TargetArchitecture": {
|
||||
@ -135,7 +136,8 @@
|
||||
"CODE_COVERAGE": "enabled",
|
||||
"PublishMapFiles": "true"
|
||||
},
|
||||
"included": {},
|
||||
"included": {
|
||||
},
|
||||
"included_release": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON",
|
||||
|
||||
179
eng/scripts/Get-BinarySizes.ps1
Normal file
179
eng/scripts/Get-BinarySizes.ps1
Normal file
@ -0,0 +1,179 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter()]
|
||||
[string] $BuildDirectory = "$PSScriptRoot/../../build/",
|
||||
|
||||
[Parameter()]
|
||||
[string] $ServiceDirectory = "*",
|
||||
|
||||
[Parameter()]
|
||||
[string] $OsVMImage,
|
||||
|
||||
[Parameter()]
|
||||
[string] $CmakeArgs,
|
||||
|
||||
[Parameter()]
|
||||
[string] $CmakeEnvArg,
|
||||
|
||||
[Parameter()]
|
||||
[string] $BuildArgs,
|
||||
|
||||
[Parameter()]
|
||||
[string] $Job,
|
||||
|
||||
[Parameter()]
|
||||
[string] $BuildReason,
|
||||
|
||||
[Parameter()]
|
||||
[string] $SourceBranch,
|
||||
|
||||
[Parameter()]
|
||||
[switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID),
|
||||
|
||||
[Parameter()]
|
||||
[hashtable]$ExtraLabels = @{}
|
||||
)
|
||||
|
||||
. $PSScriptRoot/../common/scripts/common.ps1
|
||||
|
||||
function setEnvVar($key, $value) {
|
||||
Write-Host "##vso[task.setvariable variable=_$key;issecret=true;]$value"
|
||||
}
|
||||
|
||||
function getTargetOs {
|
||||
if ($OsVMImage.StartsWith('macOS')) {
|
||||
return $OsVMImage
|
||||
}
|
||||
|
||||
if ($OsVMImage -eq "MMS2019") {
|
||||
return "win-2019"
|
||||
}
|
||||
|
||||
if ($OsVMImage -eq "MMSUbuntu18.04") {
|
||||
return "ubuntu-18.04"
|
||||
}
|
||||
|
||||
if ($OsVMImage -eq "MMSUbuntu20.04") {
|
||||
return "ubuntu-20.04"
|
||||
}
|
||||
|
||||
LogError "Could not infer target OS"
|
||||
}
|
||||
|
||||
function getTargetArchitecture {
|
||||
if ($OSVmImage.StartsWith('macOS')) {
|
||||
return "x64"
|
||||
}
|
||||
|
||||
if ($env:CMAKE_GENERATOR_PLATFORM -and $env:CMAKE_GENERATOR_PLATFORM -eq "Win32") {
|
||||
return "x86"
|
||||
}
|
||||
|
||||
if ($env:CMAKE_GENERATOR_PLATFORM -and $env:CMAKE_GENERATOR_PLATFORM -eq "x64") {
|
||||
return "x64"
|
||||
}
|
||||
|
||||
# Most builds target x64 by default
|
||||
return "x64"
|
||||
}
|
||||
|
||||
function getToolChain {
|
||||
if ($OSVmImage.StartsWith('macOS')) {
|
||||
return "AppleClang 12"
|
||||
}
|
||||
|
||||
if ($OSVmImage -eq "MMS2019") {
|
||||
return "MSVC"
|
||||
}
|
||||
|
||||
if ($OSVmImage.Contains("Ubuntu")) {
|
||||
if ($CmakeEnvArg.Contains('g++-5')) {
|
||||
return 'g++-5'
|
||||
} elseif ($env:CXX -and $env:CXX.Contains("g++8")) {
|
||||
return 'g++-8'
|
||||
} elseif ($env:CXX -and $env:CXX.Contains("g++-9")) {
|
||||
return 'g++-9'
|
||||
} elseif ($env:CXX -and $env:CXX.Contains("clang-11")) {
|
||||
return 'clang-11'
|
||||
}
|
||||
return "g++-7"
|
||||
}
|
||||
LogError "Could not infer toolchain"
|
||||
}
|
||||
|
||||
function getTargetPlatform {
|
||||
if ($OSVmImage.StartsWith('macOS')) {
|
||||
return "macos"
|
||||
}
|
||||
|
||||
if ($OSVmImage -eq 'MMS2019') {
|
||||
if (!$env:CMAKE_SYSTEM_NAME -and !$CmakeArgs.Contains('WindowsStore')) {
|
||||
return 'win32'
|
||||
} elseif ($env:CMAKE_SYSTEM_NAME -eq 'WindowsStore' -or $CmakeArgs.Contains('WindowsStore')) {
|
||||
return 'uwp'
|
||||
}
|
||||
}
|
||||
|
||||
if ($OSVmImage.Contains("Ubuntu")) {
|
||||
return 'linux'
|
||||
}
|
||||
|
||||
LogError "Could not infer target platform"
|
||||
}
|
||||
|
||||
function getBuildConfiguration {
|
||||
if ($env:CMAKE_BUILD_TYPE) {
|
||||
return $env:CMAKE_BUILD_TYPE
|
||||
}
|
||||
|
||||
if ($BuildArgs.Contains("--config Debug")) {
|
||||
return "Debug"
|
||||
}
|
||||
|
||||
if ($BuildArgs.Contains("--config Release")) {
|
||||
return "Release"
|
||||
}
|
||||
|
||||
# Most builds default to Debug unless overridden by configuration variables
|
||||
return "Debug"
|
||||
}
|
||||
|
||||
$searchPath = "$BuildDirectory/sdk/$ServiceDirectory/*/*.a"
|
||||
if ($IsWindows) {
|
||||
$searchPath = "$BuildDirectory/sdk/$ServiceDirectory/*/*/*.lib"
|
||||
}
|
||||
|
||||
$binaries = Get-ChildItem -Path $searchPath
|
||||
|
||||
$buildLabels = @{
|
||||
TargetOs = getTargetOs;
|
||||
Toolchain = getToolChain;
|
||||
BuildConfig = getBuildConfiguration;
|
||||
TargetArchitecture = getTargetArchitecture;
|
||||
TargetPlatform = getTargetPlatform;
|
||||
}
|
||||
|
||||
if ($CI) {
|
||||
foreach ($binary in $binaries) {
|
||||
$metricLogObject = @{
|
||||
name = "BinarySize";
|
||||
value = $binary.Length
|
||||
timestamp = (Get-Date -AsUTC).ToString("o")
|
||||
labels = @{
|
||||
Job = $Job;
|
||||
BuildReason = $BuildReason;
|
||||
SourceBranch = $SourceBranch;
|
||||
BinaryName = $binary.Name;
|
||||
} + $buildLabels + $ExtraLabels
|
||||
}
|
||||
|
||||
$metricLogJson = ConvertTo-Json $metricLogObject -Compress
|
||||
Write-Host "logmetric: $metricLogJson"
|
||||
}
|
||||
}
|
||||
$binaries `
|
||||
| Format-Table -Property Name, @{Name="SizeInKB"; Expression={"{0:N2}" -f ($_.Length / 1KB)}; Alignment='right'} `
|
||||
| Out-String `
|
||||
| Write-Host
|
||||
|
||||
return $binaries
|
||||
Loading…
Reference in New Issue
Block a user