Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 2086 (#21867)
Browse files Browse the repository at this point in the history
* Use the latest get-codeowner scripts

* Update Update-DocsMsMetadata.ps1

* Update version

* Update Update-DocsMsMetadata.ps1

* Update Update-DocsMsMetadata.ps1

Co-authored-by: sima-zhu <[email protected]>
Co-authored-by: Sima Zhu <[email protected]>
  • Loading branch information
3 people authored Nov 24, 2021
1 parent 5e6d3c3 commit a0f7f61
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 61 deletions.
54 changes: 0 additions & 54 deletions eng/common/pipelines/templates/steps/get-pr-owners.yml

This file was deleted.

19 changes: 16 additions & 3 deletions eng/common/scripts/Update-DocsMsMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down Expand Up @@ -78,12 +78,25 @@ function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata
$ReadmeContent = $ReadmeContent -replace $releaseReplaceRegex, $replacementPattern
}

# 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.
}
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
Expand Down
8 changes: 4 additions & 4 deletions eng/common/scripts/get-codeowners.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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]$ToolVersion = "1.0.0-dev.20211122.14", # Placeholder. Will update in next PR
[string]$CodeOwnerFileLocation = (Resolve-Path $PSScriptRoot/../../../.github/CODEOWNERS), # The absolute path of CODEOWNERS file.
[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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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")
Expand Down

0 comments on commit a0f7f61

Please sign in to comment.