2019-12-13 09:48:00 -05:00
################################################################################
## File: Validate-ToolCache.ps1
## Desc: Validate Tool Cache
################################################################################
# Helpers
function GetChildFolders {
param (
[ Parameter ( Mandatory = $True )]
[ string ] $Path
)
return Get-ChildItem -Path $Path -Directory -Name
}
function ToolcacheTest {
param (
[ Parameter ( Mandatory = $True )]
[ string ] $SoftwareName ,
[ Parameter ( Mandatory = $True )]
2019-12-18 17:35:47 -05:00
[ string[] ] $ExecTests ,
[ Parameter ( Mandatory = $True )]
[ string ] $Note
2019-12-13 09:48:00 -05:00
)
if ( Test-Path " $env:AGENT_TOOLSDIRECTORY \ $SoftwareName " )
{
$description = ""
[ array ] $versions = GetChildFolders -Path " $env:AGENT_TOOLSDIRECTORY \ $SoftwareName "
if ( $versions . count -gt 0 ){
foreach ( $version in $versions )
{
$architectures = GetChildFolders -Path " $env:AGENT_TOOLSDIRECTORY \ $SoftwareName \ $version "
Write-Host " $SoftwareName version - $version : $([ system.String ]:: Join ( "," , $architectures )) "
foreach ( $arch in $architectures )
{
$path = " $env:AGENT_TOOLSDIRECTORY \ $SoftwareName \ $version \ $arch "
foreach ( $test in $ExecTests )
{
if ( Test-Path " $path \ $test " )
{
Write-Host " $SoftwareName ( $test ) $version ( $arch ) is successfully installed:"
Write-Host (& " $path \ $test " - -version )
}
else
{
Write-Host " $SoftwareName ( $test ) $version ( $arch ) is not installed"
exit 1
}
}
$description += "_Version:_ $version ( $arch )<br/>"
}
}
2019-12-18 17:35:47 -05:00
$description += $Note
2019-12-13 09:48:00 -05:00
Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $description
}
else
{
Write-Host " $env:AGENT_TOOLSDIRECTORY \ $SoftwareName does not include any folders"
exit 1
}
}
else
{
Write-Host " $env:AGENT_TOOLSDIRECTORY \ $SoftwareName does not exist"
exit 1
}
}
# Python test
2019-12-18 17:35:47 -05:00
$PythonNote += @"
<br/>
> Note: These versions of Python are available through the [Use Python Version](https://go.microsoft.com/fwlink/?linkid=871498) task.
"@
2019-12-13 09:48:00 -05:00
$PythonTests = @ ( "python.exe" , "Scripts\pip.exe" )
2019-12-18 17:35:47 -05:00
ToolcacheTest -SoftwareName "Python" -ExecTests $PythonTests -Note $PythonNote
2019-12-13 09:48:00 -05:00
# PyPy test
2019-12-18 17:35:47 -05:00
$PyPyNote += @"
<br/>
> Note: These versions of PyPy are available through the [Use Python Version](https://go.microsoft.com/fwlink/?linkid=871498) task.
"@
2019-12-13 09:48:00 -05:00
$PyPyTests = @ ( "python.exe" , "bin\pip.exe" )
2019-12-18 17:35:47 -05:00
ToolcacheTest -SoftwareName "PyPy" -ExecTests $PyPyTests -Note $PyPyNote
2019-12-13 09:48:00 -05:00
# Ruby test
2019-12-18 17:35:47 -05:00
$RubyNote += @"
<br/>
> Note: These versions of Ruby are available through the [Use Ruby Version](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/use-ruby-version) task.
"@
2019-12-13 09:48:00 -05:00
$RubyTests = @ ( "bin\ruby.exe" )
2019-12-18 17:35:47 -05:00
ToolcacheTest -SoftwareName "Ruby" -ExecTests $RubyTests -Note $RubyNote