Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 7459 (#22222)
Browse files Browse the repository at this point in the history
* check for the presence of a compatible powershell. ensure that we always return a list of tags

* allow the script to require pshell6+

* remove the en-us from the link

---------

Co-authored-by: Scott Beddall (from Dev Box) <[email protected]>
  • Loading branch information
azure-sdk and scbedd authored Jan 9, 2024
1 parent 46b3614 commit 0fbeb23
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions eng/common/testproxy/scripts/tag-merge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This script merely allows the abstraction of some of this "combination" work.

### PreReqs

- Must have []`pshell 6+`](https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows)
- Must have `git` available on your PATH
- Must have the `test-proxy` available on your PATH
- `test-proxy` is honored when the proxy is installed as a `dotnet tool`
Expand Down
28 changes: 22 additions & 6 deletions eng/common/testproxy/scripts/tag-merge/merge-proxy-tags.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#Requires -Version 6.0
#Requires -PSEdition Core

<#
.SYNOPSIS
Merge multiple asset tagss worth of content into a single asset tag.
Expand Down Expand Up @@ -66,9 +69,6 @@ function Git-Command($CommandString, $WorkingDirectory, $HardExit=$true) {
}

function Resolve-Proxy {
# this script requires the presence of git
Test-Exe-In-Path -ExeToLookFor "git" | Out-Null

$testProxyExe = "test-proxy"
# this script requires the presence of the test-proxy on the PATH
$proxyToolPresent = Test-Exe-In-Path -ExeToLookFor "test-proxy" -ExitOnError $false
Expand Down Expand Up @@ -184,7 +184,13 @@ function Start-Message($AssetsJson, $TargetTags, $AssetsRepoLocation, $MountDire
function Finish-Message($AssetsJson, $TargetTags, $AssetsRepoLocation, $MountDirectory) {
$len = $TargetTags.Length

Write-Host "`nSuccessfully combined $len tags. Invoke `"test-proxy push " -NoNewLine
if ($TargetTags.GetType().Name -eq "String") {
$len = 1
}

$suffix = if ($len -gt 1) { "s" } else { "" }

Write-Host "`nSuccessfully combined $len tag$suffix. Invoke `"test-proxy push " -NoNewLine
Write-Host $AssetsJson -ForegroundColor Green -NoNewLine
Write-Host "`" to push the results as a new tag."
}
Expand Down Expand Up @@ -270,12 +276,22 @@ function Combine-Tags($RemainingTags, $AssetsRepoLocation, $MountDirectory){
# if we have successfully gotten to the end without any non-zero exit codes...delete the mergeprogress file, we're g2g
Cleanup-Incomplete-Progress $MountDirectory

return $pushedTags
return @($pushedTags)
}

$ErrorActionPreference = "Stop"

# resolve the proxy location so that we can invoke it easily
# this script requires the presence of git
Test-Exe-In-Path -ExeToLookFor "git" | Out-Null

# this script expects at least powershell 6 (core)

if ($PSVersionTable["PSVersion"].Major -lt 6) {
Write-Error "This script requires a version of powershell newer than 6. See http://aka.ms/powershell for resolution."
exit 1
}

# resolve the proxy location so that we can invoke it easily, if not present we exit here.
$proxyExe = Resolve-Proxy

$AssetsJson = Resolve-Path $AssetsJson
Expand Down

0 comments on commit 0fbeb23

Please sign in to comment.