[vcpkg] Add disk space report to Windows PR/CI (#12113)

* [vcpkg] Add disk space report to PR/CI

Example output:
```
Disk Label           Size     Free Space
---- -----           ----     ----------
C:   Sabrent         1907 GiB 1239 GiB
D:   Dev             447 GiB  383 GiB
E:   Samsung 960 Pro 1908 GiB 1084 GiB
H:   Rocket          3815 GiB 863 GiB
R:                   0 B      0 B
S:                   0 B      0 B
```
This commit is contained in:
Billy O'Neal 2020-06-25 16:38:13 -07:00 committed by GitHub
parent 0d37525d75
commit f10c49281a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 0 deletions

View File

@ -15,6 +15,11 @@ jobs:
displayName: 'Initialize Environment' displayName: 'Initialize Environment'
inputs: inputs:
filePath: 'scripts/azure-pipelines/windows/initialize-environment.ps1' filePath: 'scripts/azure-pipelines/windows/initialize-environment.ps1'
- task: PowerShell@2
displayName: 'Report on Disk Space'
condition: always()
inputs:
filePath: 'scripts/azure-pipelines/windows/disk-space.ps1'
# Note: D: is the Azure machines' temporary disk. # Note: D: is the Azure machines' temporary disk.
- task: CmdLine@2 - task: CmdLine@2
displayName: 'Build vcpkg' displayName: 'Build vcpkg'
@ -48,6 +53,11 @@ jobs:
inputs: inputs:
testResultsFiles: '$(System.ArtifactsDirectory)/xml-results/${{ parameters.triplet }}.xml' testResultsFiles: '$(System.ArtifactsDirectory)/xml-results/${{ parameters.triplet }}.xml'
condition: always() condition: always()
- task: PowerShell@2
displayName: 'Report on Disk Space After Build'
condition: always()
inputs:
filePath: 'scripts/azure-pipelines/windows/disk-space.ps1'
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: ${{ parameters.triplet }} port build failure logs' displayName: 'Publish Artifact: ${{ parameters.triplet }} port build failure logs'
inputs: inputs:

View File

@ -0,0 +1,35 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
<#
.SYNOPSIS
Prints total and free disk space for each disk on the system
#>
Function Format-Size {
[CmdletBinding()]
Param([long]$Size)
if ($Size -lt 1024) {
$Size = [int]$Size
return "$Size B"
}
$Size = $Size / 1024
if ($Size -lt 1024) {
$Size = [int]$Size
return "$Size KiB"
}
$Size = $Size / 1024
if ($Size -lt 1024) {
$Size = [int]$Size
return "$Size MiB"
}
$Size = [int]($Size / 1024)
return "$Size GiB"
}
Get-CimInstance -ClassName Win32_LogicalDisk | Format-Table -Property @{Label="Disk"; Expression={ $_.DeviceID }},@{Label="Label"; Expression={ $_.VolumeName }},@{Label="Size"; Expression={ Format-Size($_.Size) }},@{Label="Free Space"; Expression={ Format-Size($_.FreeSpace) }}