Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document environment variables of linux images #2498

Merged
merged 11 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 13 additions & 1 deletion images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,16 @@ function Get-AndroidNDKVersions {
$ndkFolderPath = Join-Path (Get-AndroidSDKRoot) "ndk"
$versions = Get-ChildItem -Path $ndkFolderPath -Name
return ($versions -Join "<br>")
}
}

function Build-AndroidEnvironmentTable {
$androidVersions = Get-Item env:ANDROID_*
dsame marked this conversation as resolved.
Show resolved Hide resolved

$shouldResolveLink = 'ANDROID_NDK_PATH', 'ANDROID_NDK_HOME', 'ANDROID_NDK_ROOT', 'ANDROID_NDK_LATEST_HOME'
return $androidVersions | Sort-Object -Property Name | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
"Value" = if ($shouldResolveLink.Contains($_.Name )) { Get-PathWithLink($_.Value) } else {$_.Value}
}
}
}
20 changes: 19 additions & 1 deletion images/linux/scripts/SoftwareReport/SoftwareReport.Browsers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,22 @@ function Get-GeckodriverVersion {
function Get-ChromiumVersion {
$chromiumVersion = chromium --version | Take-OutputPart -Part 0,1
return $chromiumVersion
}
}

function Build-BrowserWebdriversEnvironmentTable {
return @(
@{
"Name" = "CHROMEWEBDRIVER"
"Value" = $env:CHROMEWEBDRIVER
},
@{
"Name" = "GECKOWEBDRIVER"
"Value" = $env:GECKOWEBDRIVER
}
) | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
"Value" = $_.Value
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ function Get-ToolcacheGoVersions {
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
}

function Build-GoEnvironmentTable {
dsame marked this conversation as resolved.
Show resolved Hide resolved
return Get-CachedToolInstances -Name "go" -VersionCommand "version" | ForEach-Object {
$Version = [System.Version]($_.Version -Split(" "))[0]
$Name = "GOROOT_$($Version.major)_$($Version.minor)_X64"
$Value = (Get-Item env:\$Name).Value
[PSCustomObject] @{
"Name" = $Name
"Value" = (Get-Item env:\$Name).Value
"Architecture" = $_. Architecture
}
}
}

function Get-ToolcacheBoostVersions {
$Name = "Boost"
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "boost"
Expand Down Expand Up @@ -82,4 +95,4 @@ function Build-CachedToolsSection {
$output += New-MDList -Lines (Get-ToolcacheRubyVersions) -Style Unordered

return $output
}
}
18 changes: 18 additions & 0 deletions images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,21 @@ function Build-GraalVMTable {
"Environment variables" = $envVariables
}
}

function Build-PackageManagementEnvironmentTable {
return @(
@{
"Name" = "CONDA"
"Value" = $env:CONDA
},
@{
"Name" = "VCPKG_INSTALLATION_ROOT"
"Value" = $env:VCPKG_INSTALLATION_ROOT
}
) | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
"Value" = $_.Value
}
}
}
14 changes: 14 additions & 0 deletions images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ $packageManagementList = @(
(Get-Pip3Version),
(Get-VcpkgVersion)
)
$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-PackageManagementEnvironmentTable | New-MDTable
$markdown += New-MDNewLine

if (-not (Test-IsUbuntu16)) {
$packageManagementList += @(
Expand Down Expand Up @@ -215,6 +218,10 @@ if (Test-IsUbuntu20) {
}

$markdown += New-MDList -Style Unordered -Lines $browsersAndDriversList
$markdown += New-MDNewLine
$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-BrowserWebdriversEnvironmentTable | New-MDTable
$markdown += New-MDNewLine

$markdown += New-MDHeader ".NET Core SDK" -Level 3
$markdown += New-MDList -Style Unordered -Lines @(
Expand All @@ -240,6 +247,10 @@ $markdown += Build-MSSQLToolsSection
$markdown += New-MDHeader "Cached Tools" -Level 3
$markdown += Build-CachedToolsSection

$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-GoEnvironmentTable | New-MDTable
$markdown += New-MDNewLine

$markdown += New-MDHeader "PowerShell Tools" -Level 3
$markdown += New-MDList -Lines (Get-PowershellVersion) -Style Unordered

Expand All @@ -252,6 +263,9 @@ $markdown += Build-WebServersSection
$markdown += New-MDHeader "Android" -Level 3
$markdown += Build-AndroidTable | New-MDTable
$markdown += New-MDNewLine
$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-AndroidEnvironmentTable | New-MDTable
$markdown += New-MDNewLine

$markdown += New-MDHeader "Cached Docker images" -Level 3
$markdown += Get-CachedDockerImagesTableData | New-MDTable
Expand Down
92 changes: 91 additions & 1 deletion images/linux/scripts/helpers/SoftwareReport.Helpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,94 @@ function New-MDNewLine {

function Restore-UserOwner {
sudo chown -R ${env:USER}: $env:HOME
}
}

function Get-LinkTarget {
param (
[string] $inputPath
)
$link = Get-Item $inputPath | Select-Object -ExpandProperty Target
if ($link) {
return " -> $link"
}
return ""
}

function Get-PathWithLink {
param (
[string] $inputPath
)
$link = Get-LinkTarget($inputPath)
return "${inputPath}${link}"
}

function Get-CachedToolInstances
{
<#
.SYNOPSIS
Returns hastable of installed cached tools.

.DESCRIPTION
Return hastable that contains versions and architectures for selected cached tool.

.PARAMETER Name
Name of cached tool.

.PARAMETER VersionCommand
Optional parameter. Command to return version of system default tool.

.EXAMPLE
Get-CachedToolInstances -Name "Python" -VersionCommand "--version"

#>

param
(
[String] $Name,
[String] $VersionCommand
)

$toolInstances = @()
$toolPath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $Name

# Get all installed versions from TOOLSDIRECTORY folder
$versions = Get-ChildItem $toolPath | Sort-Object { [System.Version]$_.Name }
foreach ($version in $versions)
{
$instanceInfo = @{}

# Create instance hashtable
[string]$instanceInfo.Path = Join-Path -Path $toolPath -ChildPath $version.Name
[string]$instanceInfo.Version = $version.Name

### Temporary workaround. Currently Boost instances don't have architecture subfolders.
if ($Name -eq "Boost")
{
[string]$instanceInfo.Architecture = "x64, x86"
$toolInstances += $instanceInfo
continue
}

# Get all architectures for current version
[array]$instanceInfo.Architecture_Array = Get-ChildItem $version.FullName -Name -Directory | Where-Object { $_ -match "^x[0-9]{2}$" }
[string]$instanceInfo.Architecture = $instanceInfo.Architecture_Array -Join ", "

# Add (default) postfix to version name, in case if current version is in environment path
if (-not ([string]::IsNullOrEmpty($VersionCommand)))
{
$defaultVersion = $(& ($Name.ToLower()) $VersionCommand 2>&1)
$defaultToolVersion = $defaultVersion | Select-String -Pattern "\d+\.\d+\.\d+" -AllMatches `
| ForEach-Object { $_.Matches.Value }

if ([version]$version.Name -eq [version]$defaultToolVersion)
{
$instanceInfo.Version += " (Default)"
}
}

$toolInstances += $instanceInfo
}

return $toolInstances
}