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

Sync eng/common directory with azure-sdk-tools for PR 916 #13374

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
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