Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
11f40f4
Try running format validation as its own stage
cbezault Apr 3, 2020
2cf5e02
Try to improve naming
cbezault Apr 3, 2020
6970cd9
Make value of agentPool a string
cbezault Apr 3, 2020
641a3ae
Try with the curly braces
cbezault Apr 3, 2020
c6446e7
Azure YAML examples are bad and should feel bad
cbezault Apr 3, 2020
bf844e9
Change Run to Run Validation
cbezault Apr 3, 2020
0a0c91c
Run the tests without vcpkg
cbezault Apr 4, 2020
28536ed
enable the /BE tests
cbezault Apr 4, 2020
509d78d
Make temp path generation consistent.
BillyONeal Mar 31, 2020
94221ff
Typos and WorkLoads.
BillyONeal Mar 31, 2020
5998f51
Consistently Get-TempFilePath and download quietly
BillyONeal Apr 3, 2020
2a743f9
Insert a restart VM step before sysprep to improve reliability after …
BillyONeal Apr 4, 2020
be15eca
Update CUDA.
BillyONeal Apr 4, 2020
3515187
Apply @AdamBucior 's suggestion
cbezault Apr 4, 2020
608f647
point to new pool
cbezault Apr 4, 2020
62ba383
Point to the newest pool
cbezault Apr 5, 2020
957c967
Remove debugging statements
cbezault Apr 5, 2020
9de4691
don't get submodules for tools
cbezault Apr 5, 2020
6e3f796
Resolve EDG failures in the feature test macros test.
cbezault Apr 5, 2020
c445602
Skip a test because of compiler bug
cbezault Apr 5, 2020
3c74a35
Add another /BE test to the skip list
cbezault Apr 5, 2020
b800c5b
Resolve some comments and revert test changes for now
cbezault Apr 8, 2020
2a0e006
Update feature test macro test for new EDG
cbezault Apr 8, 2020
d2254ce
Clang format
cbezault Apr 8, 2020
4b953f6
Skip failing tests
cbezault Apr 9, 2020
075b9e6
drop a comment line
cbezault Apr 9, 2020
fc3c5fd
I don't know where these changes came from
cbezault Apr 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions azure-devops/create-new-agent-image.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $LiveVMPrefix = 'BUILD'
$WindowsServerSku = '2019-Datacenter'

$ProgressActivity = 'Creating Scale Set'
$TotalProgress = 8
$TotalProgress = 10
$CurrentProgress = 1

function Find-ResourceGroupNameCollision {
Expand Down Expand Up @@ -190,18 +190,36 @@ New-AzVm `
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Running provisioning script in VM' `
-Status 'Running provisioning script provision-image.ps1 in VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)

$VM = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
$PrototypeOSDiskName = $VM.StorageProfile.OsDisk.Name
Invoke-AzVMRunCommand `
-ResourceGroupName $ResourceGroupName `
-VMName $ProtoVMName `
-CommandId 'RunPowerShellScript' `
-ScriptPath "$PSScriptRoot\provision-image.ps1" `
-Parameter @{AdminUserPassword = $AdminPW }

####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Restarting VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would 100 * $CurrentProgress++ / $TotalProgress be clearer? Ditto below. Actually, this appears to be repeated for each step - should it be extracted as a PowerShell function so only the status string needs to be passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know it's a pretty simple expression. I also find the way it is written to be more obvious than your suggestion.


Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context for other reviewers: I added this restart step after the installs because it seemed to make the subsequent sysprep step more reliable.


####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Running provisioning script sysprep.ps1 in VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)

Invoke-AzVMRunCommand `
-ResourceGroupName $ResourceGroupName `
-VMName $ProtoVMName `
-CommandId 'RunPowerShellScript' `
-ScriptPath "$PSScriptRoot\sysprep.ps1"

####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
Expand All @@ -226,6 +244,8 @@ Set-AzVM `
-Name $ProtoVMName `
-Generalized

$VM = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
$PrototypeOSDiskName = $VM.StorageProfile.OsDisk.Name
$ImageConfig = New-AzImageConfig -Location $Location -SourceVirtualMachineId $VM.ID
$Image = New-AzImage -Image $ImageConfig -ImageName $ProtoVMName -ResourceGroupName $ResourceGroupName

Expand Down Expand Up @@ -278,8 +298,7 @@ $Vmss = Set-AzVmssStorageProfile `
-VirtualMachineScaleSet $Vmss `
-OsDiskCreateOption 'FromImage' `
-OsDiskCaching ReadWrite `
-ImageReferenceId $Image.Id `
-ManagedDisk Premium_LRS
-ImageReferenceId $Image.Id

New-AzVmss `
-ResourceGroupName $ResourceGroupName `
Expand Down
151 changes: 107 additions & 44 deletions azure-devops/provision-image.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ param(
[string]$AdminUserPassword = $null
)

Function Get-TempFilePath {
Param(
[String]$Extension
)

if ([String]::IsNullOrWhiteSpace($Extension)) {
throw 'Missing Extension'
}

$tempPath = [System.IO.Path]::GetTempPath()
$tempName = [System.IO.Path]::GetRandomFileName() + '.' + $Extension
return Join-Path $tempPath $tempName
}

if (-not [string]::IsNullOrEmpty($AdminUserPassword)) {
Write-Output "AdminUser password supplied; switching to AdminUser"
$PsExecPath = $env:TEMP + "\psexec.exe"
$PsExecPath = Get-TempFilePath -Extension 'exe'
Write-Output "Downloading psexec to $PsExecPath"
& curl.exe -L -o $PsExecPath -s -S https://live.sysinternals.com/PsExec64.exe
$PsExecArgs = @(
Expand All @@ -25,16 +39,23 @@ if (-not [string]::IsNullOrEmpty($AdminUserPassword)) {
'-File',
$PSCommandPath
)
Write-Output "Executing $PsExecPath @PsExecArgs"
& $PsExecPath @PsExecArgs
exit $?

Write-Output "Executing $PsExecPath " + @PsExecArgs

$proc = Start-Process -FilePath $PsExecPath -ArgumentList $PsExecArgs -Wait -PassThru
Write-Output 'Cleaning up...'
Remove-Item $PsExecPath
exit $proc.ExitCode
}

$WorkLoads = '--add Microsoft.VisualStudio.Component.VC.CLI.Support ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.ARM ' + `
'--add Microsoft.VisualStudio.Component.Windows10SDK.18362 '
$Workloads = @(
'Microsoft.VisualStudio.Component.VC.CLI.Support',
'Microsoft.VisualStudio.Component.VC.CoreIde',
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
'Microsoft.VisualStudio.Component.VC.Tools.ARM64',
'Microsoft.VisualStudio.Component.VC.Tools.ARM',
'Microsoft.VisualStudio.Component.Windows10SDK.18362'
)

$ReleaseInPath = 'Preview'
$Sku = 'Enterprise'
Expand All @@ -44,6 +65,13 @@ $LlvmUrl = 'https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.
$NinjaUrl = 'https://github.com/ninja-build/ninja/releases/download/v1.10.0/ninja-win.zip'
$PythonUrl = 'https://www.python.org/ftp/python/3.8.2/python-3.8.2-amd64.exe'

$CudaUrl = 'https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_426.00_win10.exe'
$CudaFeatures = 'nvcc_10.1 cuobjdump_10.1 nvprune_10.1 cupti_10.1 gpu_library_advisor_10.1 memcheck_10.1 ' + `
'nvdisasm_10.1 nvprof_10.1 visual_profiler_10.1 visual_studio_integration_10.1 cublas_10.1 cublas_dev_10.1 ' + `
'cudart_10.1 cufft_10.1 cufft_dev_10.1 curand_10.1 curand_dev_10.1 cusolver_10.1 cusolver_dev_10.1 cusparse_10.1 ' + `
'cusparse_dev_10.1 nvgraph_10.1 nvgraph_dev_10.1 npp_10.1 npp_dev_10.1 nvrtc_10.1 nvrtc_dev_10.1 nvml_dev_10.1 ' + `
'occupancy_calculator_10.1 fortran_examples_10.1'

$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'

Expand All @@ -63,19 +91,33 @@ Function PrintMsiExitCodeMessage {

Function InstallVisualStudio {
Param(
[String]$WorkLoads,
[String]$Sku,
[String]$BootstrapperUrl
[String[]]$Workloads,
[String]$BootstrapperUrl,
[String]$InstallPath = $null,
[String]$Nickname = $null
)

try {
Write-Output 'Downloading Visual Studio...'
[string]$bootstrapperExe = Join-Path ([System.IO.Path]::GetTempPath()) `
([System.IO.Path]::GetRandomFileName() + '.exe')
curl.exe -L -o $bootstrapperExe $BootstrapperUrl

[string]$bootstrapperExe = Get-TempFilePath -Extension 'exe'
curl.exe -L -o $bootstrapperExe -s -S $BootstrapperUrl
Write-Output "Installing Visual Studio..."
$args = ('/c', $bootstrapperExe, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache')
$args = @('/c', $bootstrapperExe, '--quiet', '--norestart', '--wait', '--nocache')
foreach ($workload in $Workloads) {
$args += '--add'
$args += $workload
}

if (-not ([String]::IsNullOrWhiteSpace($InstallPath))) {
$args += '--installpath'
$args += $InstallPath
}

if (-not ([String]::IsNullOrWhiteSpace($Nickname))) {
$args += '--nickname'
$args += $Nickname
}

$proc = Start-Process -FilePath cmd.exe -ArgumentList $args -Wait -PassThru
PrintMsiExitCodeMessage $proc.ExitCode
}
Expand All @@ -94,10 +136,8 @@ Function InstallMSI {

try {
Write-Output "Downloading $Name..."
[string]$randomRoot = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
[string]$msiPath = $randomRoot + '.msi'
curl.exe -L -o $msiPath $Url

[string]$msiPath = Get-TempFilePath -Extension 'msi'
curl.exe -L -o $msiPath -s -S $Url
Write-Output "Installing $Name..."
$args = @('/i', $msiPath, '/norestart', '/quiet', '/qn')
$proc = Start-Process -FilePath 'msiexec.exe' -ArgumentList $args -Wait -PassThru
Expand All @@ -119,10 +159,8 @@ Function InstallZip {

try {
Write-Output "Downloading $Name..."
[string]$randomRoot = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
[string]$zipPath = $randomRoot + '.zip'
curl.exe -L -o $zipPath $Url

[string]$zipPath = Get-TempFilePath -Extension 'zip'
curl.exe -L -o $zipPath -s -S $Url
Write-Output "Installing $Name..."
Expand-Archive -Path $zipPath -DestinationPath $Dir -Force
}
Expand All @@ -140,10 +178,8 @@ Function InstallLLVM {

try {
Write-Output 'Downloading LLVM...'
[string]$randomRoot = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
[string]$installerPath = $randomRoot + '.exe'
curl.exe -L -o $installerPath $Url

[string]$installerPath = Get-TempFilePath -Extension 'exe'
curl.exe -L -o $installerPath -s -S $Url
Write-Output 'Installing LLVM...'
$proc = Start-Process -FilePath $installerPath -ArgumentList @('/S') -NoNewWindow -Wait -PassThru
PrintMsiExitCodeMessage $proc.ExitCode
Expand All @@ -161,10 +197,8 @@ Function InstallPython {
)

Write-Output 'Downloading Python...'
[string]$randomRoot = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
[string]$installerPath = $randomRoot + '.exe'
curl.exe -L -o $installerPath $Url

[string]$installerPath = Get-TempFilePath -Extension 'exe'
curl.exe -L -o $installerPath -s -S $Url
Write-Output 'Installing Python...'
$proc = Start-Process -FilePath $installerPath -ArgumentList `
@('/passive', 'InstallAllUsers=1', 'PrependPath=1', 'CompileAll=1') -Wait -PassThru
Expand All @@ -178,19 +212,38 @@ Function InstallPython {
}
}

Function InstallCuda {
Param(
[String]$Url,
[String]$Features
)

try {
Write-Output 'Downloading CUDA...'
[string]$installerPath = Get-TempFilePath -Extension 'exe'
curl.exe -L -o $installerPath -s -S $Url
Write-Output 'Installing CUDA...'
$proc = Start-Process -FilePath $installerPath -ArgumentList @('-s ' + $Features) -Wait -PassThru
$exitCode = $proc.ExitCode
if ($exitCode -eq 0) {
Write-Output 'Installation successful!'
}
else {
Write-Output "Installation failed! Exited with $exitCode."
exit $exitCode
}
}
catch {
Write-Output "Failed to install CUDA!"
Write-Output $_.Exception.Message
exit -1
}
}


Write-Output "AdminUser password not supplied; assuming already running as AdminUser"
InstallMSI 'CMake' $CMakeUrl
InstallZip 'Ninja' $NinjaUrl 'C:\Program Files\CMake\bin'
InstallLLVM $LlvmUrl
InstallPython $PythonUrl
InstallVisualStudio -WorkLoads $WorkLoads -Sku $Sku -BootstrapperUrl $VisualStudioBootstrapperUrl
Write-Output 'Updating PATH...'
$environmentKey = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' `
-Name Path `
-Value "$($environmentKey.Path);C:\Program Files\CMake\bin;C:\Program Files\LLVM\bin"

Write-Host 'Configuring AntiVirus exclusions...'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is "AntiVirus" PascalCased here? PowerShell-ism leaking into the output?

Add-MPPreference -ExclusionPath C:\agent
Add-MPPreference -ExclusionPath D:\
Add-MPPreference -ExclusionProcess ninja.exe
Expand All @@ -199,4 +252,14 @@ Add-MPPreference -ExclusionProcess cl.exe
Add-MPPreference -ExclusionProcess link.exe
Add-MPPreference -ExclusionProcess python.exe

C:\Windows\system32\sysprep\sysprep.exe /oobe /generalize /shutdown
InstallMSI 'CMake' $CMakeUrl
InstallZip 'Ninja' $NinjaUrl 'C:\Program Files\CMake\bin'
InstallLLVM $LlvmUrl
InstallPython $PythonUrl
InstallVisualStudio -Workloads $Workloads -BootstrapperUrl $VisualStudioBootstrapperUrl
InstallCuda -Url $CudaUrl -Features $CudaFeatures
Write-Output 'Updating PATH...'
$environmentKey = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' `
-Name Path `
-Value "$($environmentKey.Path);C:\Program Files\CMake\bin;C:\Program Files\LLVM\bin"
41 changes: 6 additions & 35 deletions azure-devops/run-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ jobs:
- job: ${{ parameters.targetPlatform }}
timeoutInMinutes: 360
pool:
name: StlBuild-2020-03-28
name: $(agentPool)

variables:
vcpkgLocation: '$(Build.SourcesDirectory)/vcpkg'
steps:
- checkout: self
clean: true
submodules: recursive
submodules: true
- task: Cache@2
displayName: Cache vcpkg
timeoutInMinutes: 10
Expand All @@ -35,31 +35,6 @@ jobs:
vcpkgArguments: 'boost-math'
vcpkgDirectory: '$(vcpkgLocation)'
vcpkgTriplet: '${{ parameters.targetPlatform }}-windows'
- task: run-cmake@0
displayName: 'Build Support Tools'
timeoutInMinutes: 2
condition: eq('${{ parameters.targetPlatform }}', 'x64')
inputs:
cmakeListsTxtPath: 'tools/CMakeSettings.json'
useVcpkgToolchainFile: true
configurationRegexFilter: '.*x64-Release.*'
buildDirectory: $(Build.ArtifactStagingDirectory)/tools
- task: BatchScript@1
displayName: 'Enforce clang-format'
timeoutInMinutes: 60
condition: eq('${{ parameters.targetPlatform }}', 'x64')
inputs:
filename: 'azure-devops/enforce-clang-format.cmd'
failOnStandardError: true
arguments: '$(Build.ArtifactStagingDirectory)/tools/parallelize/parallelize.exe'
- task: BatchScript@1
displayName: 'Validate Files'
timeoutInMinutes: 2
condition: eq('${{ parameters.targetPlatform }}', 'x64')
inputs:
filename: 'azure-devops/validate-files.cmd'
failOnStandardError: true
arguments: '$(Build.ArtifactStagingDirectory)/tools/validate/validate.exe'
- task: PowerShell@2
displayName: 'Get Test Parallelism'
timeoutInMinutes: 2
Expand All @@ -78,20 +53,16 @@ jobs:
useVcpkgToolchainFile: true
cmakeAppendedArgs: |
-G Ninja -DBUILD_TESTING=TRUE -DENABLE_XUNIT_OUTPUT=TRUE -DADDITIONAL_LIT_FLAGS=-j$(testParallelism)
- task: PowerShell@2
- task: CmdLine@2
displayName: 'Run Tests'
timeoutInMinutes: 120
condition: in('${{ parameters.targetPlatform }}', 'x64', 'x86')
inputs:
workingDirectory: $(Build.ArtifactStagingDirectory)/${{ parameters.targetPlatform }}
targetType: inline
script: |
Add-Content -Path ./run-tests.cmd -Value "set PATH=$(split-path (get-command ctest).source);%PATH%"
Add-Content -Path ./run-tests.cmd -Value "set PATH=$(split-path (get-command clang-cl).source);%PATH%"
$currentDir = "$((Get-Item -Path "./").FullName)"
Add-Content -Path ./run-tests.cmd -Value "cd $currentDir"
Add-Content -Path ./run-tests.cmd -Value "ctest -V"
$(vcpkgLocation)/vcpkg.exe env --triplet ${{ parameters.targetPlatform }}-windows "$currentDir/run-tests.cmd"
call "%PROGRAMFILES(X86)%\Microsoft Visual Studio\2019\Preview\Common7\Tools\VsDevCmd.bat" ^
-host_arch=${{ parameters.vsDevCmdArch }} -arch=${{ parameters.vsDevCmdArch }} -no_logo
ctest -V
- task: PublishTestResults@2
displayName: 'Publish libcxx Tests'
timeoutInMinutes: 10
Expand Down
5 changes: 5 additions & 0 deletions azure-devops/sysprep.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

Write-Output 'Running sysprep'
& C:\Windows\system32\sysprep\sysprep.exe /oobe /generalize /shutdown
Loading