Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools repository for Tools P…
Browse files Browse the repository at this point in the history
…R 916 (#13374)
  • Loading branch information
azure-sdk authored Sep 1, 2020
1 parent 1c9980c commit a3ae936
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
35 changes: 13 additions & 22 deletions eng/common/pipelines/templates/steps/get-pr-owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,19 @@ steps:
- pwsh: |
git clone https://github.com/Azure/azure-sdk-tools.git $(Build.SourcesDirectory)/tools_repo
cd $(Build.SourcesDirectory)/tools_repo
git checkout 564ad63ae72d18422533fa1da9d396e7703c1cb5
git checkout 35ad98f821913eb0e8872f861ee60589b563c865
displayName: Setup Identity Resolver
- pwsh: |
$result = dotnet run -v q -- `
dotnet run -v q -- `
--aad-app-id-var APP_ID `
--aad-app-secret-var APP_SECRET `
--aad-tenant-var AAD_TENANT `
--kusto-url-var KUSTO_URL `
--kusto-database-var KUSTO_DB `
--kusto-table-var KUSTO_TABLE `
--identity "$(Build.QueuedBy)"
$resolvedIdentity = ""
try { $resolvedIdentity = $result[-1] | ConvertFrom-Json } catch {}
if($resolvedIdentity) {
Write-Host $resolvedIdentity
Write-Host "##vso[task.setvariable variable=${{ parameters.TargetVariable }}]$($resolvedIdentity.GithubUserName)"
}
else {
Write-Host "Unable to locate a github user for identity $(Build.QueuedBy)"
}
--identity "$(Build.QueuedBy)" `
--targetvar "${{ parameters.TargetVariable }}"
displayName: 'Resolving Queuing User'
continueOnError: true
workingDirectory: $(Build.SourcesDirectory)/tools_repo/tools/notification-configuration/identity-resolver
Expand All @@ -45,10 +34,12 @@ steps:
Remove-Item -Force -Recurse $(Build.SourcesDirectory)/tools_repo
displayName: Clean Up Cloned Tools Repo
- pwsh: |
$originalValue = "$(${{ parameters.TargetVariable }})"
$result = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 -TargetDirectory /sdk/${{ parameters.ServiceDirectory }}/ -RootDirectory $(Build.SourcesDirectory)
if ($result) {
Write-Host "##vso[task.setvariable variable=${{ parameters.TargetVariable }}]$originalValue,$result"
}
displayName: Add CodeOwners if Present
- task: PowerShell@2
displayName: Add CodeOwners if Present
inputs:
pwsh: true
filePath: $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1
arguments: >
-TargetDirectory "/sdk/${{ parameters.ServiceDirectory }}/"
-RootDirectory "$(Build.SourcesDirectory)"
-VsoVariable "${{ parameters.TargetVariable }}"
13 changes: 12 additions & 1 deletion eng/common/scripts/get-codeowners.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
param (
$TargetDirectory, # should be in relative form from root of repo. EG: sdk/servicebus
$RootDirectory # ideally $(Build.SourcesDirectory)
$RootDirectory, # ideally $(Build.SourcesDirectory)
$VsoVariable = "" # target devops output variable
)
$target = $TargetDirectory.ToLower().Trim("/")
$codeOwnersLocation = Join-Path $RootDirectory -ChildPath ".github/CODEOWNERS"
Expand Down Expand Up @@ -29,6 +30,16 @@ $results = $ownedFolders[$target]

if ($results) {
Write-Host "Found a folder $results to match $target"

if ($VsoVariable) {
$alreadyPresent = [System.Environment]::GetEnvironmentVariable($VsoVariable)

if ($alreadyPresent) {
$results += ",$alreadyPresent"
}
Write-Host "##vso[task.setvariable variable=$VsoVariable;]$results"
}

return $results
}
else {
Expand Down

0 comments on commit a3ae936

Please sign in to comment.