From 16e41f1985495a52c23ffb1c6ae3847774a26d62 Mon Sep 17 00:00:00 2001 From: sima-zhu Date: Tue, 23 Nov 2021 11:55:45 -0800 Subject: [PATCH 1/5] Use the latest get-codeowner scripts --- .../templates/steps/get-pr-owners.yml | 54 ------------------- eng/common/scripts/Update-DocsMsMetadata.ps1 | 18 +++++-- eng/common/scripts/get-codeowners.ps1 | 6 +-- 3 files changed, 18 insertions(+), 60 deletions(-) delete mode 100644 eng/common/pipelines/templates/steps/get-pr-owners.yml diff --git a/eng/common/pipelines/templates/steps/get-pr-owners.yml b/eng/common/pipelines/templates/steps/get-pr-owners.yml deleted file mode 100644 index 1ea87e856..000000000 --- a/eng/common/pipelines/templates/steps/get-pr-owners.yml +++ /dev/null @@ -1,54 +0,0 @@ -parameters: - TargetVariable: '' - TargetUserVariable: 'notspecified' - TargetTeamVariable: 'notspecified' - TargetLabelVariable: 'notspecified' - ServiceDirectory: '' - DevOpsFeed: "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json" - -steps: - - task: DotNetCoreCLI@2 - displayName: 'Install Identity Resolver' - inputs: - command: custom - custom: 'tool' - arguments: 'install --global --add-source "${{ parameters.DevOpsFeed }}" --version "1.0.0-dev.20211018.1" "Azure.Sdk.Tools.IdentityResolver"' - workingDirectory: '$(Agent.BuildDirectory)' - - - task: DotNetCoreCLI@2 - displayName: 'Install CodeOwners Retriever' - inputs: - command: custom - custom: 'tool' - arguments: 'install --global --add-source "${{ parameters.DevOpsFeed }}" --version "1.0.0-dev.20211019.1" "Azure.Sdk.Tools.RetrieveCodeOwners"' - workingDirectory: '$(Agent.BuildDirectory)' - - - pwsh: | - identity-resolver ` - --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-name "$(Build.QueuedBy)" ` - --identity-email "$(Build.RequestedForEmail)" ` - --targetvar "${{ coalesce(parameters.TargetVariable, parameters.TargetUserVariable) }}" - displayName: 'Resolving Queuing User' - continueOnError: true - env: - APP_ID: $(notification-aad-app-id) - APP_SECRET: $(notification-aad-secret) - AAD_TENANT: $(notification-aad-tenant) - KUSTO_URL: $(notification-kusto-url) - KUSTO_DB: $(notification-kusto-db) - KUSTO_TABLE: $(notification-kusto-table) - - - pwsh: | - retrieve-codeowners ` - --target-directory "/sdk/${{ parameters.ServiceDirectory }}/" ` - --root-directory "$(Build.SourcesDirectory)" ` - --vso-owning-users "${{ coalesce(parameters.TargetVariable, parameters.TargetUserVariable) }}" ` - --vso-owning-teams "${{ parameters.TargetTeamVariable }}" ` - --vso-owning-labels "${{ parameters.TargetLabelVariable }}" - displayName: 'Add CodeOwners if Present' \ No newline at end of file diff --git a/eng/common/scripts/Update-DocsMsMetadata.ps1 b/eng/common/scripts/Update-DocsMsMetadata.ps1 index 774d2b0a6..007f087a5 100644 --- a/eng/common/scripts/Update-DocsMsMetadata.ps1 +++ b/eng/common/scripts/Update-DocsMsMetadata.ps1 @@ -33,7 +33,7 @@ GitHub repository ID of the SDK. Typically of the form: 'Azure/azure-sdk-for-js' param( [Parameter(Mandatory = $true)] [array]$PackageInfoJsonLocations, - + [Parameter(Mandatory = $true)] [string]$DocRepoLocation, @@ -78,12 +78,24 @@ function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata $ReadmeContent = $ReadmeContent -replace $releaseReplaceRegex, $replacementPattern } + # Get the first code owners of the package. + $author = "ramya-rao-a" + $msauthor = "ramyar" + $codeOwnerArray = ."$PSScriptRoot/get-codeowners.ps1" ` + -TargetDirectory "sd" + #-TargetDirectory $PackageInfo.DirectoryPath + if ($codeOwnerArray) { + $author = $codeOwnerArray[0] + $msauthor = $author # This is a placeholder for now. Will change to the right ms alias. + } + Write-Host "The author of package: $author" + Write-Host "The ms author of package: $msauthor" $header = @" --- title: $foundTitle keywords: Azure, $Language, SDK, API, $($PackageInfo.Name), $service -author: maggiepint -ms.author: magpint +author: $author +ms.author: $msauthor ms.date: $date ms.topic: reference ms.prod: azure diff --git a/eng/common/scripts/get-codeowners.ps1 b/eng/common/scripts/get-codeowners.ps1 index dff01ecab..488586b8d 100644 --- a/eng/common/scripts/get-codeowners.ps1 +++ b/eng/common/scripts/get-codeowners.ps1 @@ -1,6 +1,6 @@ param ( [string]$TargetDirectory = "", # Code path to code owners. e.g sdk/core/azure-amqp - [string]$CodeOwnerFileLocation = "$PSSCriptRoot/../../../.github/CODEOWNERS", # The absolute path of CODEOWNERS file. + [string]$CodeOwnerFileLocation = (Resolve-Path $PSScriptRoot/../../../.github/CODEOWNERS), # The absolute path of CODEOWNERS file. [string]$ToolVersion = "1.0.0-dev.20211122.14", # Placeholder. Will update in next PR [string]$ToolPath = (Join-Path ([System.IO.Path]::GetTempPath()) "codeowners-tool-path"), # The place to check the tool existence. Put temp path as default [string]$DevOpsFeed = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json", # DevOp tool feeds. @@ -34,7 +34,6 @@ function Get-CodeOwners ([string]$targetDirectory, [string]$codeOwnerFileLocatio { $command = Get-CodeOwnersTool # Filter out the non user alias from code owner list. - Write-Host "Testing on $targetDirectory..." if($includeNonUserAliases) { $codeOwnersString = & $command --target-directory $targetDirectory --code-owner-file-path $codeOwnerFileLocation 2>&1 } @@ -62,6 +61,7 @@ function Get-CodeOwners ([string]$targetDirectory, [string]$codeOwnerFileLocatio } function TestGetCodeOwner([string]$targetDirectory, [string]$codeOwnerFileLocation, [bool]$includeNonUserAliases = $false, [string[]]$expectReturn) { + Write-Host "Testing on $targetDirectory..." $actualReturn = Get-CodeOwners -targetDirectory $targetDirectory -codeOwnerFileLocation $codeOwnerFileLocation -includeNonUserAliases $IncludeNonUserAliases if ($actualReturn.Count -ne $expectReturn.Count) { @@ -77,7 +77,7 @@ function TestGetCodeOwner([string]$targetDirectory, [string]$codeOwnerFileLocati } if($Test) { - $testFile = "$PSSCriptRoot/../../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/CODEOWNERS" + $testFile = (Resolve-Path $PSScriptRoot/../../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/CODEOWNERS) TestGetCodeOwner -targetDirectory "sdk" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2") TestGetCodeOwner -targetDirectory "sdk/noPath" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2") TestGetCodeOwner -targetDirectory "/sdk/azconfig" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person3", "person4") From 3838a8da7292b63b6725731b5e76f1270d86cc4a Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Tue, 23 Nov 2021 14:03:59 -0800 Subject: [PATCH 2/5] Update Update-DocsMsMetadata.ps1 --- eng/common/scripts/Update-DocsMsMetadata.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eng/common/scripts/Update-DocsMsMetadata.ps1 b/eng/common/scripts/Update-DocsMsMetadata.ps1 index 007f087a5..2ace8cb45 100644 --- a/eng/common/scripts/Update-DocsMsMetadata.ps1 +++ b/eng/common/scripts/Update-DocsMsMetadata.ps1 @@ -82,8 +82,7 @@ function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata $author = "ramya-rao-a" $msauthor = "ramyar" $codeOwnerArray = ."$PSScriptRoot/get-codeowners.ps1" ` - -TargetDirectory "sd" - #-TargetDirectory $PackageInfo.DirectoryPath + -TargetDirectory $PackageInfo.DirectoryPath if ($codeOwnerArray) { $author = $codeOwnerArray[0] $msauthor = $author # This is a placeholder for now. Will change to the right ms alias. From 474cd8279667f455bd2555e9207bea5aea4717cb Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Tue, 23 Nov 2021 14:23:03 -0800 Subject: [PATCH 3/5] Update version --- eng/common/scripts/get-codeowners.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/get-codeowners.ps1 b/eng/common/scripts/get-codeowners.ps1 index 488586b8d..d36a78e6f 100644 --- a/eng/common/scripts/get-codeowners.ps1 +++ b/eng/common/scripts/get-codeowners.ps1 @@ -1,7 +1,7 @@ param ( [string]$TargetDirectory = "", # Code path to code owners. e.g sdk/core/azure-amqp [string]$CodeOwnerFileLocation = (Resolve-Path $PSScriptRoot/../../../.github/CODEOWNERS), # The absolute path of CODEOWNERS file. - [string]$ToolVersion = "1.0.0-dev.20211122.14", # Placeholder. Will update in next PR + [string]$ToolVersion = "1.0.0-dev.20211123.13", # Placeholder. Will update in next PR [string]$ToolPath = (Join-Path ([System.IO.Path]::GetTempPath()) "codeowners-tool-path"), # The place to check the tool existence. Put temp path as default [string]$DevOpsFeed = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json", # DevOp tool feeds. [string]$VsoVariable = "", # Option of write code owners into devop variable From 127e427ce72a4596b4ce95e3eed660548dcaa2be Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Tue, 23 Nov 2021 15:20:00 -0800 Subject: [PATCH 4/5] Update Update-DocsMsMetadata.ps1 --- eng/common/scripts/Update-DocsMsMetadata.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eng/common/scripts/Update-DocsMsMetadata.ps1 b/eng/common/scripts/Update-DocsMsMetadata.ps1 index 2ace8cb45..13209f0c2 100644 --- a/eng/common/scripts/Update-DocsMsMetadata.ps1 +++ b/eng/common/scripts/Update-DocsMsMetadata.ps1 @@ -81,9 +81,11 @@ function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata # Get the first code owners of the package. $author = "ramya-rao-a" $msauthor = "ramyar" + Write-Host "Retrieve the code owner from $PackageInfo.DirectoryPath." $codeOwnerArray = ."$PSScriptRoot/get-codeowners.ps1" ` -TargetDirectory $PackageInfo.DirectoryPath if ($codeOwnerArray) { + Write-Host "Code Owners are $($codeOwnerArray -join ",")" $author = $codeOwnerArray[0] $msauthor = $author # This is a placeholder for now. Will change to the right ms alias. } From 1cced93f0ca9f26c5ddc531e5c79ad90bc62401b Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Tue, 23 Nov 2021 16:05:37 -0800 Subject: [PATCH 5/5] Update Update-DocsMsMetadata.ps1 --- eng/common/scripts/Update-DocsMsMetadata.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/Update-DocsMsMetadata.ps1 b/eng/common/scripts/Update-DocsMsMetadata.ps1 index 13209f0c2..fcb175608 100644 --- a/eng/common/scripts/Update-DocsMsMetadata.ps1 +++ b/eng/common/scripts/Update-DocsMsMetadata.ps1 @@ -81,7 +81,7 @@ function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata # Get the first code owners of the package. $author = "ramya-rao-a" $msauthor = "ramyar" - Write-Host "Retrieve the code owner from $PackageInfo.DirectoryPath." + Write-Host "Retrieve the code owner from $($PackageInfo.DirectoryPath)." $codeOwnerArray = ."$PSScriptRoot/get-codeowners.ps1" ` -TargetDirectory $PackageInfo.DirectoryPath if ($codeOwnerArray) {