mirror of
https://github.com/actions/versions-package-tools.git
synced 2025-12-10 03:13:23 +00:00
* setup boost helpers * add ci for pull requests * pester for ci * resolving issue with pester 5 * remove Output flag * check tests with 4 version * try common tests variant * added requires * move to 5 version * try to add assert module * fix scope * use new regex for python * fix regex in tests * Pester 4.10.1 * EnableExit * fix synopsys * fix creating tar archive Co-authored-by: Dmitry Shibanov <v-dmshib@microsoft.com> Co-authored-by: Maxim Lobanov <v-malob@microsoft.com>
85 lines
2.3 KiB
PowerShell
85 lines
2.3 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
The execute command and print all output to the logs
|
|
#>
|
|
function Execute-Command {
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory=$true)][string] $Command
|
|
)
|
|
|
|
Write-Debug "Execute $Command"
|
|
|
|
try {
|
|
Invoke-Expression $Command | ForEach-Object { Write-Host $_ }
|
|
if ($LASTEXITCODE -ne 0) { throw "Exit code: $LASTEXITCODE"}
|
|
}
|
|
catch {
|
|
$errorMessage = "Error happened during command execution: $Command `n $_"
|
|
Write-Host $errorMessage
|
|
if ($ErrorActionPreference -ne "Continue") {
|
|
# avoid logging Azure DevOps issues in case of $ErrorActionPreference -eq Continue
|
|
Write-Host "##vso[task.logissue type=error;] $errorMessage"
|
|
}
|
|
}
|
|
}
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Download file from url and return local path to file
|
|
#>
|
|
function Download-File {
|
|
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[Uri]$Uri,
|
|
[Parameter(Mandatory=$true)]
|
|
[String]$OutputFolder
|
|
)
|
|
|
|
$targetFilename = [IO.Path]::GetFileName($Uri)
|
|
$targetFilepath = Join-Path $OutputFolder $targetFilename
|
|
|
|
Write-Debug "Download source from $Uri to $OutFile"
|
|
try {
|
|
(New-Object System.Net.WebClient).DownloadFile($Uri, $targetFilepath)
|
|
return $targetFilepath
|
|
} catch {
|
|
Write-Host "Error during downloading file from '$Uri'"
|
|
"$_"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Generate file that contains the list of all files in particular directory
|
|
#>
|
|
function New-ToolStructureDump {
|
|
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[String]$ToolPath,
|
|
[Parameter(Mandatory=$true)]
|
|
[String]$OutputFolder
|
|
)
|
|
|
|
$outputFile = Join-Path $OutputFolder "tools_structure.txt"
|
|
|
|
$folderContent = Get-ChildItem -Path $ToolPath -Recurse | Sort-Object | Select-Object -Property FullName, Length
|
|
$folderContent | ForEach-Object {
|
|
$relativePath = $_.FullName.Replace($ToolPath, "");
|
|
return "${relativePath}"
|
|
} | Out-File -FilePath $outputFile
|
|
}
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Check if it is macOS / Ubuntu platform
|
|
#>
|
|
function IsNixPlatform {
|
|
param(
|
|
[Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()]
|
|
[String]$Platform
|
|
)
|
|
|
|
return ($Platform -match "macos") -or ($Platform -match "ubuntu") -or ($Platform -match "linux")
|
|
} |