From 52224f9055bb8134fad942fac2732f324cfa213d Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Fri, 29 Sep 2023 21:29:48 +0000 Subject: [PATCH 1/5] Remove codeowners resolution logic from docs scripts --- .../get-codeowners/get-codeowners.tests.ps1 | 46 -- .../scripts/Helpers/Metadata-Helpers.ps1 | 54 +- ...ervice-Level-Readme-Automation-Helpers.ps1 | 73 +- .../Service-Level-Readme-Automation.ps1 | 45 +- eng/common/scripts/Update-DocsMsMetadata.ps1 | 18 - eng/common/scripts/get-codeowners.lib.ps1 | 138 ---- eng/common/scripts/get-codeowners.ps1 | 18 - ....Sdk.Tools.RetrieveCodeOwners.Tests.csproj | 27 - .../CodeownersManualAnalysisTests.cs | 623 ------------------ .../ConsoleOutput.cs | 70 -- .../RetrieveCodeOwnersProgramTests.cs | 214 ------ .../TestData/InputDir/a.txt | 0 .../TestData/InputDir/b.txt | 12 - .../TestData/InputDir/baz/cor/c.txt | 0 .../TestData/InputDir/baz_.txt | 0 .../TestData/InputDir/cor.txt | 0 .../TestData/InputDir/cor/gra/a.txt | 0 .../TestData/InputDir/cor2/a.txt | 0 .../TestData/InputDir/foo/a.txt | 12 - .../TestData/InputDir/foo/b.txt | 12 - .../TestData/InputDir/foo/bar/a.txt | 0 .../TestData/InputDir/foo/bar/b.txt | 0 .../TestData/InputDir/qux/abc/d.txt | 0 .../TestData/test_CODEOWNERS | 16 - .../Azure.Sdk.Tools.RetrieveCodeOwners.csproj | 21 - .../Program.cs | 156 ----- tools/code-owners-parser/CodeOwnersParser.sln | 82 +-- tools/code-owners-parser/ci.yml | 33 - 28 files changed, 104 insertions(+), 1566 deletions(-) delete mode 100644 eng/common-tests/get-codeowners/get-codeowners.tests.ps1 delete mode 100644 eng/common/scripts/get-codeowners.lib.ps1 delete mode 100644 eng/common/scripts/get-codeowners.ps1 delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/Azure.Sdk.Tools.RetrieveCodeOwners.Tests.csproj delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/CodeownersManualAnalysisTests.cs delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/ConsoleOutput.cs delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/RetrieveCodeOwnersProgramTests.cs delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/a.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/b.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/baz/cor/c.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/baz_.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/cor.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/cor/gra/a.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/cor2/a.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/a.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/b.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/bar/a.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/bar/b.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/qux/abc/d.txt delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/test_CODEOWNERS delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Azure.Sdk.Tools.RetrieveCodeOwners.csproj delete mode 100644 tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Program.cs delete mode 100644 tools/code-owners-parser/ci.yml diff --git a/eng/common-tests/get-codeowners/get-codeowners.tests.ps1 b/eng/common-tests/get-codeowners/get-codeowners.tests.ps1 deleted file mode 100644 index 8ec82832fee..00000000000 --- a/eng/common-tests/get-codeowners/get-codeowners.tests.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -Import-Module Pester - -BeforeAll { - . $PSScriptRoot/../../common/scripts/get-codeowners.lib.ps1 - - function TestGetCodeowners( - [string] $TargetPath, - [string] $CodeownersFileLocation, - [string[]] $ExpectedOwners - ) - { - Write-Host "Test: Owners for path '$TargetPath' in CODEOWNERS file at path '$CodeownersFileLocation' should be '$ExpectedOwners'" - - $actualOwners = Get-Codeowners ` - -TargetPath $TargetPath ` - -CodeownersFileLocation $CodeownersFileLocation ` - - $actualOwners.Count | Should -Be $ExpectedOwners.Count - for ($i = 0; $i -lt $ExpectedOwners.Count; $i++) { - $ExpectedOwners[$i] | Should -Be $actualOwners[$i] - } - } -} - -Describe "Get Codeowners" -Tag "UnitTest" { - It "Should get Codeowners" -TestCases @( - @{ - # The $PSScriptRoot is assumed to be azure-sdk-tools/eng/common-tests/get-codeowners/get-codeowners.tests.ps1 - codeownersPath = "$PSScriptRoot/../../../.github/CODEOWNERS"; - targetPath = "eng/common/scripts/get-codeowners/get-codeowners.ps1"; - expectedOwners = @("konrad-jamrozik", "weshaggard", "benbp") - }, - @{ - # The $PSScriptRoot is assumed to be azure-sdk-tools/eng/common-tests/get-codeowners/get-codeowners.tests.ps1 - CodeownersPath = "$PSScriptRoot/../../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/test_CODEOWNERS"; - targetPath = "tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/a.txt"; - expectedOwners = @("2star") - } - ) { - $resolvedCodeownersPath = (Resolve-Path $codeownersPath) - TestGetCodeowners ` - -TargetPath $targetPath ` - -CodeownersFileLocation $resolvedCodeownersPath ` - -ExpectedOwners $expectedOwners - } -} \ No newline at end of file diff --git a/eng/common/scripts/Helpers/Metadata-Helpers.ps1 b/eng/common/scripts/Helpers/Metadata-Helpers.ps1 index bbc9eaa70c0..3df2c0684a7 100644 --- a/eng/common/scripts/Helpers/Metadata-Helpers.ps1 +++ b/eng/common/scripts/Helpers/Metadata-Helpers.ps1 @@ -17,36 +17,6 @@ function Generate-AadToken ($TenantId, $ClientId, $ClientSecret) return $resp.access_token } -function GetMsAliasFromGithub ([string]$TenantId, [string]$ClientId, [string]$ClientSecret, [string]$GithubUser) -{ - # API documentation (out of date): https://github.com/microsoft/opensource-management-portal/blob/main/docs/api.md - $OpensourceAPIBaseURI = "https://repos.opensource.microsoft.com/api/people/links/github/$GithubUser" - - $Headers = @{ - "Content-Type" = "application/json" - "api-version" = "2019-10-01" - } - - try { - $opsAuthToken = Generate-AadToken -TenantId $TenantId -ClientId $ClientId -ClientSecret $ClientSecret - $Headers["Authorization"] = "Bearer $opsAuthToken" - Write-Host "Fetching aad identity for github user: $GithubUser" - $resp = Invoke-RestMethod $OpensourceAPIBaseURI -Method 'GET' -Headers $Headers -MaximumRetryCount 3 - } catch { - Write-Warning $_ - return $null - } - - $resp | Write-Verbose - - if ($resp.aad) { - Write-Host "Fetched aad identity $($resp.aad.alias) for github user $GithubUser. " - return $resp.aad.alias - } - Write-Warning "Failed to retrieve the aad identity from given github user: $GithubName" - return $null -} - function GetAllGithubUsers ([string]$TenantId, [string]$ClientId, [string]$ClientSecret) { # API documentation (out of date): https://github.com/microsoft/opensource-management-portal/blob/main/docs/api.md @@ -70,17 +40,6 @@ function GetAllGithubUsers ([string]$TenantId, [string]$ClientId, [string]$Clien return $resp } -function GetPrimaryCodeOwner ([string]$TargetDirectory) -{ - $codeOwnerArray = &"$PSScriptRoot/../get-codeowners.ps1" -TargetDirectory $TargetDirectory - if ($codeOwnerArray) { - Write-Host "Code Owners are $codeOwnerArray." - return $codeOwnerArray[0] - } - Write-Warning "No code owner found in $TargetDirectory." - return $null -} - function GetDocsMsService($packageInfo, $serviceName) { $service = $serviceName.ToLower().Replace(' ', '').Replace('/', '-') @@ -109,8 +68,13 @@ function compare-and-merge-metadata ($original, $updated) { return $updateMetdata } -function GenerateDocsMsMetadata($originalMetadata, $language, $languageDisplayName, $serviceName, $author, $msAuthor, $msService) -{ +function GenerateDocsMsMetadata( + $originalMetadata, + $language, + $languageDisplayName, + $serviceName, + $msService +) { $langTitle = "Azure $serviceName SDK for $languageDisplayName" $langDescription = "Reference for Azure $serviceName SDK for $languageDisplayName" $date = Get-Date -Format "MM/dd/yyyy" @@ -118,9 +82,7 @@ function GenerateDocsMsMetadata($originalMetadata, $language, $languageDisplayNa $metadataTable = [ordered]@{ "title"= $langTitle "description"= $langDescription - "author"= $author - "ms.author"= $msauthor - "ms.data"= $date + "ms.date"= $date "ms.topic"= "reference" "ms.devlang"= $language "ms.service"= $msService diff --git a/eng/common/scripts/Helpers/Service-Level-Readme-Automation-Helpers.ps1 b/eng/common/scripts/Helpers/Service-Level-Readme-Automation-Helpers.ps1 index 75742426e91..4382b6159f1 100644 --- a/eng/common/scripts/Helpers/Service-Level-Readme-Automation-Helpers.ps1 +++ b/eng/common/scripts/Helpers/Service-Level-Readme-Automation-Helpers.ps1 @@ -1,8 +1,15 @@ -function create-service-readme($readmeFolder, $readmeName, $moniker, $msService, $indexTableLink, $serviceName, $author, $msAuthor) -{ +function create-service-readme( + $readmeFolder, + $readmeName, + $moniker, + $msService, + $indexTableLink, + $serviceName +) { + $readmePath = Join-Path $readmeFolder -ChildPath $readmeName - $content = "" + $content = "" if (Test-Path (Join-Path $readmeFolder -ChildPath $indexTableLink)) { $content = "## Packages - $moniker`r`n" $content += "[!INCLUDE [packages]($indexTableLink)]" @@ -13,8 +20,12 @@ function create-service-readme($readmeFolder, $readmeName, $moniker, $msService, } # Generate the front-matter for docs needs # $Language, $LanguageDisplayName are the variables globally defined in Language-Settings.ps1 - $metadataString = GenerateDocsMsMetadata -language $Language -languageDisplayName $LanguageDisplayName -serviceName $serviceName ` - -author $author -msAuthor $msAuthor -msService $msService + $metadataString = GenerateDocsMsMetadata ` + -language $Language ` + -languageDisplayName $LanguageDisplayName ` + -serviceName $serviceName ` + -msService $msService + Add-Content -Path $readmePath -Value $metadataString -NoNewline # Add tables, conbined client and mgmt together. @@ -34,14 +45,20 @@ function update-metadata-table($readmeFolder, $readmeName, $serviceName, $msServ $restContent = $Matches["content"].trim() $metadata = $Matches["metadata"].trim() } + # $Language, $LanguageDisplayName are the variables globally defined in Language-Settings.ps1 - $metadataString = GenerateDocsMsMetadata -originalMetadata $metadata -language $Language -languageDisplayName $LanguageDisplayName -serviceName $serviceName ` - -author $author -msAuthor $msAuthor -msService $msService + $metadataString = GenerateDocsMsMetadata ` + -originalMetadata $metadata ` + -language $Language ` + -languageDisplayName $LanguageDisplayName ` + -serviceName $serviceName ` + -msService $msService + Set-Content -Path $readmePath -Value "$metadataString$restContent" -NoNewline } function generate-markdown-table($readmeFolder, $readmeName, $packageInfos, $moniker) { - $tableHeader = "| Reference | Package | Source |`r`n|---|---|---|`r`n" + $tableHeader = "| Reference | Package | Source |`r`n|---|---|---|`r`n" $tableContent = "" $packageInfos = $packageInfos | Sort-Object -Property Type,Package # Here is the table, the versioned value will @@ -54,7 +71,7 @@ function generate-markdown-table($readmeFolder, $readmeName, $packageInfos, $mon if (Test-Path "Function:$GetPackageLevelReadmeFn") { $packageLevelReadme = &$GetPackageLevelReadmeFn -packageMetadata $pkg } - + $referenceLink = "[$($pkg.DisplayName)]($packageLevelReadme-readme.md)" if (!(Test-Path (Join-Path $readmeFolder -ChildPath "$packageLevelReadme-readme.md"))) { $referenceLink = $pkg.DisplayName @@ -72,19 +89,41 @@ function generate-markdown-table($readmeFolder, $readmeName, $packageInfos, $mon } } -function generate-service-level-readme($docRepoLocation, $readmeBaseName, $pathPrefix, $packageInfos, $serviceName, $moniker, $author, $msAuthor, $msService) { +function generate-service-level-readme( + $docRepoLocation, + $readmeBaseName, + $pathPrefix, + $packageInfos, + $serviceName, + $moniker, + $msService +) { $readmeFolder = "$docRepoLocation/$pathPrefix/$moniker/" $serviceReadme = "$readmeBaseName.md" $indexReadme = "$readmeBaseName-index.md" + if ($packageInfos) { - generate-markdown-table -readmeFolder $readmeFolder -readmeName $indexReadme -packageInfos $packageInfos -moniker $moniker + generate-markdown-table ` + -readmeFolder $readmeFolder ` + -readmeName $indexReadme ` + -packageInfos $packageInfos ` + -moniker $moniker } + if (!(Test-Path "$readmeFolder$serviceReadme") -and $packageInfos) { - create-service-readme -readmeFolder $readmeFolder -readmeName $serviceReadme -moniker $moniker -msService $msService ` - -indexTableLink $indexReadme -serviceName $serviceName -author $author -msAuthor $msAuthor - } - elseif (Test-Path "$readmeFolder$serviceReadme") { - update-metadata-table -readmeFolder $readmeFolder -readmeName $serviceReadme -serviceName $serviceName ` - -msService $msService -author $author -msAuthor $msAuthor + create-service-readme ` + -readmeFolder $readmeFolder ` + -readmeName $serviceReadme ` + -moniker $moniker ` + -msService $msService ` + -indexTableLink $indexReadme ` + -serviceName $serviceName + + } elseif (Test-Path "$readmeFolder$serviceReadme") { + update-metadata-table ` + -readmeFolder $readmeFolder ` + -readmeName $serviceReadme ` + -serviceName $serviceName ` + -msService $msService } } \ No newline at end of file diff --git a/eng/common/scripts/Service-Level-Readme-Automation.ps1 b/eng/common/scripts/Service-Level-Readme-Automation.ps1 index a03e78e4e22..10dbee36edf 100644 --- a/eng/common/scripts/Service-Level-Readme-Automation.ps1 +++ b/eng/common/scripts/Service-Level-Readme-Automation.ps1 @@ -13,15 +13,6 @@ Generate missing service level readme and updating metadata of the existing ones Location of the documentation repo. This repo may be sparsely checked out depending on the requirements for the domain -.PARAMETER TenantId -The aad tenant id/object id for ms.author. - -.PARAMETER ClientId -The add client id/application id for ms.author. - -.PARAMETER ClientSecret -The client secret of add app for ms.author. - .PARAMETER ReadmeFolderRoot The readme folder root path, use default value here for backward compability. E.g. docs-ref-services in Java, JS, Python, api/overview/azure #> @@ -30,15 +21,6 @@ param( [Parameter(Mandatory = $true)] [string] $DocRepoLocation, - [Parameter(Mandatory = $false)] - [string]$TenantId, - - [Parameter(Mandatory = $false)] - [string]$ClientId, - - [Parameter(Mandatory = $false)] - [string]$ClientSecret, - [Parameter(Mandatory = $false)] [string]$ReadmeFolderRoot = "docs-ref-services", @@ -132,26 +114,17 @@ foreach($moniker in $Monikers) { Write-Host "Building service: $service" $servicePackages = $packagesForService.Values.Where({ $_.ServiceName -eq $service }) $serviceReadmeBaseName = ServiceLevelReadmeNameStyle -serviceName $service - # Github url for source code: e.g. https://github.com/Azure/azure-sdk-for-js - $serviceBaseName = ServiceLevelReadmeNameStyle $service - $author = GetPrimaryCodeOwner -TargetDirectory "/sdk/$serviceBaseName/" - $msauthor = "" - if (!$author) { - LogError "Cannot fetch the author from CODEOWNER file." - $author = "" - } - elseif ($TenantId -and $ClientId -and $ClientSecret) { - $msauthor = GetMsAliasFromGithub -TenantId $tenantId -ClientId $clientId -ClientSecret $clientSecret -GithubUser $author - } - # Default value - if (!$msauthor) { - LogError "No ms.author found for $author. " - $msauthor = $author - } + # Add ability to override # Fetch the service readme name $msService = GetDocsMsService -packageInfo $servicePackages[0] -serviceName $service - generate-service-level-readme -docRepoLocation $DocRepoLocation -readmeBaseName $serviceReadmeBaseName -pathPrefix $ReadmeFolderRoot ` - -packageInfos $servicePackages -serviceName $service -moniker $moniker -author $author -msAuthor $msauthor -msService $msService + generate-service-level-readme ` + -docRepoLocation $DocRepoLocation ` + -readmeBaseName $serviceReadmeBaseName ` + -pathPrefix $ReadmeFolderRoot ` + -packageInfos $servicePackages ` + -serviceName $service ` + -moniker $moniker ` + -msService $msService } } diff --git a/eng/common/scripts/Update-DocsMsMetadata.ps1 b/eng/common/scripts/Update-DocsMsMetadata.ps1 index 9b665dbc98d..3dbaa12bb9b 100644 --- a/eng/common/scripts/Update-DocsMsMetadata.ps1 +++ b/eng/common/scripts/Update-DocsMsMetadata.ps1 @@ -105,28 +105,10 @@ function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata $ReadmeContent = $ReadmeContent -replace $releaseReplaceRegex, $replacementPattern } - # Get the first code owners of the package. - Write-Host "Retrieve the code owner from $($PackageInfo.DirectoryPath)." - $author = GetPrimaryCodeOwner -TargetDirectory $PackageInfo.DirectoryPath - if (!$author) { - $author = "ramya-rao-a" - $msauthor = "ramyar" - } - else { - $msauthor = GetMsAliasFromGithub -TenantId $TenantId -ClientId $ClientId -ClientSecret $ClientSecret -GithubUser $author - } - # Default value - if (!$msauthor) { - $msauthor = $author - } - 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: $author -ms.author: $msauthor ms.date: $date ms.topic: reference ms.devlang: $Language diff --git a/eng/common/scripts/get-codeowners.lib.ps1 b/eng/common/scripts/get-codeowners.lib.ps1 deleted file mode 100644 index 2fc31e3be09..00000000000 --- a/eng/common/scripts/get-codeowners.lib.ps1 +++ /dev/null @@ -1,138 +0,0 @@ -function Get-CodeownersTool([string] $ToolPath, [string] $DevOpsFeed, [string] $ToolVersion) -{ - $codeownersToolCommand = Join-Path $ToolPath "retrieve-codeowners" - Write-Host "Checking for retrieve-codeowners in $ToolPath ..." - # Check if the retrieve-codeowners tool exists or not. - if (Get-Command $codeownersToolCommand -errorAction SilentlyContinue) { - return $codeownersToolCommand - } - if (!(Test-Path $ToolPath)) { - New-Item -ItemType Directory -Path $ToolPath | Out-Null - } - Write-Host "Installing the retrieve-codeowners tool under tool path: $ToolPath ..." - - # Run command under tool path to avoid dotnet tool install command checking .csproj files. - # This is a bug for dotnet tool command. Issue: https://github.com/dotnet/sdk/issues/9623 - Push-Location $ToolPath - Write-Host "Executing: dotnet tool install --tool-path $ToolPath --add-source $DevOpsFeed --version $ToolVersion" - dotnet tool install --tool-path $ToolPath --add-source $DevOpsFeed --version $ToolVersion "Azure.Sdk.Tools.RetrieveCodeOwners" | Out-Null - Pop-Location - # Test to see if the tool properly installed. - if (!(Get-Command $codeownersToolCommand -errorAction SilentlyContinue)) { - Write-Error "The retrieve-codeowners tool is not properly installed. Please check your tool path: $ToolPath" - return - } - return $codeownersToolCommand -} - -<# -.SYNOPSIS -A function that given as input $TargetPath param, returns the owners -of that path, as determined by CODEOWNERS file passed in $CodeownersFileLocation -param. - -.PARAMETER TargetPath -Required*. Path to file or directory whose owners are to be determined from a -CODEOWNERS file. e.g. sdk/core/azure-amqp/ or sdk/core/foo.txt. - -*for backward compatibility, you might provide $TargetDirectory instead. - -.PARAMETER TargetDirectory -Obsolete. Replaced by $TargetPath. Kept for backward-compatibility. -If both $TargetPath and $TargetDirectory are provided, $TargetDirectory is -ignored. - -.PARAMETER CodeownersFileLocation -Optional. An absolute path to the CODEOWNERS file against which the $TargetPath param -will be checked to determine its owners. - -.PARAMETER ToolVersion -Optional. The NuGet package version of the package containing the "retrieve-codeowners" -tool, around which this script is a wrapper. - -.PARAMETER ToolPath -Optional. The place to check the "retrieve-codeowners" tool existence. - -.PARAMETER DevOpsFeed -Optional. The NuGet package feed from which the "retrieve-codeowners" tool is to be installed. - -NuGet feed: -https://dev.azure.com/azure-sdk/public/_artifacts/feed/azure-sdk-for-net/NuGet/Azure.Sdk.Tools.RetrieveCodeOwners - -Pipeline publishing the NuGet package to the feed, "tools - code-owners-parser": -https://dev.azure.com/azure-sdk/internal/_build?definitionId=3188 - -.PARAMETER VsoVariable -Optional. If provided, the determined owners, based on $TargetPath matched against CODEOWNERS file at $CodeownersFileLocation, -will be output to Azure DevOps pipeline log as variable named $VsoVariable. - -Reference: -https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch -https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#logging-command-format - -.PARAMETER IncludeNonUserAliases -Optional. Whether to include in the returned owners list aliases that are team aliases, e.g. Azure/azure-sdk-team - -.PARAMETER Test -Optional. Whether to run the script against hard-coded tests. - -#> -function Get-Codeowners( - [string] $TargetPath, - [string] $TargetDirectory, - [string] $ToolPath = (Join-Path ([System.IO.Path]::GetTempPath()) "codeowners-tool"), - [string] $DevOpsFeed = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json", - [string] $ToolVersion = "1.0.0-dev.20230629.2", - [string] $VsoVariable = "", - [string] $CodeownersFileLocation = "", - [switch] $IncludeNonUserAliases - ) -{ - if ([string]::IsNullOrWhiteSpace($CodeownersFileLocation)) { - # The $PSScriptRoot is assumed to be azure-sdk-tools/eng/common/scripts/get-codeowners.ps1 - $CodeownersFileLocation = (Resolve-Path $PSScriptRoot/../../../.github/CODEOWNERS) - } - - # Backward compatibility: if $TargetPath is not provided, fall-back to the legacy $TargetDirectory - if ([string]::IsNullOrWhiteSpace($TargetPath)) { - $TargetPath = $TargetDirectory - } - if ([string]::IsNullOrWhiteSpace($TargetPath)) { - Write-Error "TargetPath (or TargetDirectory) parameter must be neither null nor whitespace." - return ,@() - } - - $jsonOutputFile = New-TemporaryFile - $codeownersToolCommand = Get-CodeownersTool -ToolPath $ToolPath -DevOpsFeed $DevOpsFeed -ToolVersion $ToolVersion - Write-Host "Executing: & $codeownersToolCommand --target-path $TargetPath --codeowners-file-path-or-url $CodeownersFileLocation --exclude-non-user-aliases:$(!$IncludeNonUserAliases) --owners-data-output-file $jsonOutputFile" - $commandOutput = & $codeownersToolCommand ` - --target-path $TargetPath ` - --codeowners-file-path-or-url $CodeownersFileLocation ` - --exclude-non-user-aliases:$(!$IncludeNonUserAliases) ` - --owners-data-output-file $jsonOutputFile ` - 2>&1 - - if ($LASTEXITCODE -ne 0) { - Write-Host "Command $codeownersToolCommand execution failed (exit code = $LASTEXITCODE). Output string: $commandOutput" - return ,@() - } else - { - Write-Host "Command $codeownersToolCommand executed successfully (exit code = 0). Command output string length: $($commandOutput.length)" - } - - # Assert: $commandOutput is a valid JSON representing: - # - a single CodeownersEntry, if the $TargetPath was a single path - # - or a dictionary of CodeownerEntries, keyes by each path resolved from a $TargetPath glob path. - # - # For implementation details, see Azure.Sdk.Tools.RetrieveCodeOwners.Program.Main - - $fileContents = Get-Content $jsonOutputFile -Raw - $codeownersJson = ConvertFrom-Json -InputObject $fileContents - - if ($VsoVariable) { - $codeowners = $codeownersJson.Owners -join "," - Write-Host "##vso[task.setvariable variable=$VsoVariable;]$codeowners" - } - - return ,@($codeownersJson.Owners) -} \ No newline at end of file diff --git a/eng/common/scripts/get-codeowners.ps1 b/eng/common/scripts/get-codeowners.ps1 deleted file mode 100644 index b40f9b4fa29..00000000000 --- a/eng/common/scripts/get-codeowners.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -<# -.SYNOPSIS -Please see the comment on Get-Codeowners defined in ./get-codeowners.lib.ps1 -#> -param ( - [string] $TargetPath = "", - [string] $TargetDirectory = "", - [string] $CodeownersFileLocation = "", - [switch] $IncludeNonUserAliases -) - -. $PSScriptRoot/get-codeowners.lib.ps1 - -return Get-Codeowners ` - -TargetPath $TargetPath ` - -TargetDirectory $TargetDirectory ` - -CodeownersFileLocation $CodeownersFileLocation ` - -IncludeNonUserAliases:$IncludeNonUserAliases \ No newline at end of file diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/Azure.Sdk.Tools.RetrieveCodeOwners.Tests.csproj b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/Azure.Sdk.Tools.RetrieveCodeOwners.Tests.csproj deleted file mode 100644 index 8dbda797776..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/Azure.Sdk.Tools.RetrieveCodeOwners.Tests.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - net6.0 - enable - Nullable - false - - - - - - - - - - - - - - - - - PreserveNewest - - - diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/CodeownersManualAnalysisTests.cs b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/CodeownersManualAnalysisTests.cs deleted file mode 100644 index 1ce50113dad..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/CodeownersManualAnalysisTests.cs +++ /dev/null @@ -1,623 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text.Json; -using Azure.Sdk.Tools.CodeOwnersParser; -using NUnit.Framework; - -namespace Azure.Sdk.Tools.RetrieveCodeOwners.Tests; - -/// -/// A class containing a set of tools, implemented as unit tests, -/// allowing you to view and diff owners of files of locally cloned repositories, -/// by obtaining the owners based on specified CODEOWNERS files. -/// -/// These tools are to be run manually, locally, by a developer. -/// They do not participate in an automated regression test suite. -/// -/// To run these tools, you will have to first manually comment out the "Ignore" -/// property of the "TestFixture" annotation below. -/// Then run the desired tool as a unit test, either from your IDE, -/// or "dotnet test" command line tool. -/// -/// These tools assume you have made local repo clones of relevant repositories. -/// Ensure that the local repo clones you run these tools against are clean. -/// This is because these tools do not support .gitignore. -/// Hence if you do local builds you might add minutes to runtime, and get spurious results. -/// -/// For explanation how to interpret and work with the output .csv file produced by these -/// tools, see comment on -/// -/// WriteOwnersDiffToCsv -/// -/// Related work: -/// Enable the new, regex-based, wildcard-supporting CODEOWNERS matcher -/// https://github.com/Azure/azure-sdk-tools/pull/5088 -/// -[TestFixture(Ignore = "Tools to be used manually")] -public class CodeownersManualAnalysisTests -{ - private const string OwnersDiffOutputPathSuffix = "_owners_diff.csv"; - private const string OwnersDataOutputPathSuffix = "_owners.csv"; - - /// - /// Given name of the language langName, returns path to a local clone of "azure-sdk-for-langName" - /// repository. - /// - /// This method assumes you have ensured the local clone is present at appropriate path ahead of time. - /// - /// - private static string LangRepoTargetDirPathSuffix(string langName) => "/../azure-sdk-for-" + langName; - - private const string CodeownersFilePathSuffix = "/.github/CODEOWNERS"; - - /// - /// This file is expected to be manually created by you, in your local repo clone. - /// For details of usage of this file, see: - /// - /// WriteTwoCodeownersFilesOwnersDiffToCsv - /// - /// - private const string SecondaryCodeownersFilePathSuffix = "/.github/CODEOWNERS2"; - - // Current dir, ".", is expected to be a dir in local clone of Azure/azure-sdk-tools repo, - // where "." denotes "/artifacts/bin/Azure.Sdk.Tools.CodeOwnersParser.Tests/Debug/net6.0". - private const string CurrentDir = "/artifacts/bin/Azure.Sdk.Tools.CodeOwnersParser.Tests/Debug/net6.0"; - - #region Tests - Owners data - - [Test] // Runtime <1s - public void OwnersForAzureDev() - => WriteOwnersToCsv( - targetDirPathSuffix: "/../azure-dev", - outputFileNamePrefix: "azure-dev", - ignoredPathPrefixes: ".git|artifacts"); - - // @formatter:off - [Test] public void OwnersForAzureSdkForAndroid() => WriteLangRepoOwnersToCsv("android"); // Runtime <1s - [Test] public void OwnersForAzureSdkForC() => WriteLangRepoOwnersToCsv("c"); // Runtime <1s - [Test] public void OwnersForAzureSdkForCpp() => WriteLangRepoOwnersToCsv("cpp"); // Runtime <1s - [Test] public void OwnersForAzureSdkForGo() => WriteLangRepoOwnersToCsv("go"); // Runtime <1s - [Test] public void OwnersForAzureSdkForIos() => WriteLangRepoOwnersToCsv("ios"); // Runtime <1s - [Test] public void OwnersForAzureSdkForJava() => WriteLangRepoOwnersToCsv("java"); // Runtime ~1m 11s - [Test] public void OwnersForAzureSdkForJs() => WriteLangRepoOwnersToCsv("js"); // Runtime ~1m 53s - [Test] public void OwnersForAzureSdkForNet() => WriteLangRepoOwnersToCsv("net"); // Runtime ~30s - [Test] public void OwnersForAzureSdkForPython() => WriteLangRepoOwnersToCsv("python"); // Runtime ~30s - // @formatter:on - - [Test] // Runtime <1s - public void OwnersForAzureSdkTools() - => WriteOwnersToCsv( - targetDirPathSuffix: "", - outputFileNamePrefix: "azure-sdk-tools", - ignoredPathPrefixes: ".git|artifacts"); - - #endregion - - #region Tests - Owners diffs for differing CODEOWNERS contents. - - [Test] // Runtime <1s - public void OwnersDiffForAzureDev() - => WriteTwoCodeownersFilesOwnersDiffToCsv( - targetDirPathSuffix: "/../azure-dev", - outputFileNamePrefix: "azure-dev", - ignoredPathPrefixes: ".git|artifacts"); - - // https://github.com/Azure/azure-sdk-for-android/blob/main/.github/CODEOWNERS - // No build failure notifications are configured for this repo. - // Runtime: <1s - [Test] public void OwnersDiffForAzureSdkForAndroid() => WriteLangRepoOwnersDiffToCsv("android"); - - // https://github.com/Azure/azure-sdk-for-c/blob/main/.github/CODEOWNERS - // Runtime: <1s - [Test] public void OwnersDiffForAzureSdkForC() => WriteLangRepoOwnersDiffToCsv("c"); - - // https://github.com/Azure/azure-sdk-for-cpp/blob/main/.github/CODEOWNERS - // Runtime: <1s - [Test] public void OwnersDiffForAzureSdkForCpp() => WriteLangRepoOwnersDiffToCsv("cpp"); - - // https://github.com/Azure/azure-sdk-for-go/blob/main/.github/CODEOWNERS - // Runtime: ~2s - [Test] public void OwnersDiffForAzureSdkForGo() => WriteLangRepoOwnersDiffToCsv("go"); - - // https://github.com/Azure/azure-sdk-for-ios/blob/main/.github/CODEOWNERS - // No build failure notifications are configured for this repo. - // Runtime: <1s - [Test] public void OwnersDiffForAzureSdkForIos() => WriteLangRepoOwnersDiffToCsv("ios"); - - // https://github.com/Azure/azure-sdk-for-java/blob/main/.github/CODEOWNERS - // Runtime: ~2m 32s - [Test] public void OwnersDiffForAzureSdkForJava() => WriteLangRepoOwnersDiffToCsv("java"); - - // https://github.com/Azure/azure-sdk-for-js/blob/main/.github/CODEOWNERS - // Runtime: ~3m 49s - [Test] public void OwnersDiffForAzureSdkForJs() => WriteLangRepoOwnersDiffToCsv("js"); - - // https://github.com/Azure/azure-sdk-for-net/blob/main/.github/CODEOWNERS - // Runtime: ~1m 01s - [Test] public void OwnersDiffForAzureSdkForNet() => WriteLangRepoOwnersDiffToCsv("net"); - - // https://github.com/Azure/azure-sdk-for-python/blob/main/.github/CODEOWNERS - // Runtime: ~45s - [Test] public void OwnersDiffForAzureSdkForPython() => WriteLangRepoOwnersDiffToCsv("python"); - - #endregion - - #region Parameterized tests - Owners - - private void WriteLangRepoOwnersToCsv(string langName) - => WriteOwnersToCsv( - targetDirPathSuffix: LangRepoTargetDirPathSuffix(langName), - outputFileNamePrefix: $"azure-sdk-for-{langName}", - ignoredPathPrefixes: ".git|artifacts"); - - private void WriteOwnersToCsv( - string targetDirPathSuffix, - string outputFileNamePrefix, - string ignoredPathPrefixes = Program.DefaultIgnoredPrefixes) - { - string rootDir = PathNavigatingToRootDir(CurrentDir); - string targetDir = rootDir + targetDirPathSuffix; - Debug.Assert(Directory.Exists(targetDir), - $"Ensure you have cloned the repo into '{targetDir}'. " + - "See comments on CodeownersManualAnalysisTests and WriteOwnersToCsv for details."); - Debug.Assert(File.Exists(targetDir + CodeownersFilePathSuffix), - $"Ensure you have cloned the repo into '{targetDir}'. " + - "See comments on CodeownersManualAnalysisTests and WriteOwnersToCsv for details."); - WriteOwnersToCsv( - targetDirPathSuffix, - CodeownersFilePathSuffix, - ignoredPathPrefixes, - outputFileNamePrefix); - } - - #endregion - - #region Parameterized tests - Owners diff - - private void WriteLangRepoOwnersDiffToCsv(string langName) - => WriteTwoCodeownersFilesOwnersDiffToCsv( - targetDirPathSuffix: LangRepoTargetDirPathSuffix(langName), - outputFileNamePrefix: $"azure-sdk-for-{langName}", - ignoredPathPrefixes: ".git|artifacts"); - - /// - /// This method is an invocation of: - /// - /// WriteOwnersDiffToCsv - /// - /// with following meanings bound to LEFT and RIGHT: - /// - /// LEFT: RetrieveCodeowners configuration given input local repository clone CODEOWNERS file. - /// - /// RIGHT: RetrieveCodeowners configuration given input repository CODEOWNERS2 file, - /// located beside CODEOWNERS file. - /// - /// The CODEOWNERS2 file is expected to be created manually by you. This way you can diff CODEOWNERS - /// to whatever version of it you want to express in CODEOWNERS2. For example, CODEOWNERS2 could have - /// contents of CODEOWNERS as seen in an open PR pending being merged. - /// - /// Note that modifying or reordering existing paths may always impact which PR reviewers are auto-assigned, - /// but the build failure notification recipients changes apply only to paths that represent - /// build definition .yml files. - /// - private void WriteTwoCodeownersFilesOwnersDiffToCsv( - string targetDirPathSuffix, - string outputFileNamePrefix, - string ignoredPathPrefixes = Program.DefaultIgnoredPrefixes) - { - string rootDir = PathNavigatingToRootDir(CurrentDir); - string targetDir = rootDir + targetDirPathSuffix; - Debug.Assert(Directory.Exists(targetDir), - $"Ensure you have cloned the repo into '{targetDir}'. " + - "See comments on CodeownersManualAnalysisTests and WriteTwoCodeownersFilesOwnersDiffToCsv for details."); - Debug.Assert(File.Exists(targetDir + CodeownersFilePathSuffix), - $"Ensure you have cloned the repo into '{targetDir}'. " + - "See comments on CodeownersManualAnalysisTests and WriteTwoCodeownersFilesOwnersDiffToCsv for details."); - Debug.Assert(File.Exists(targetDir + SecondaryCodeownersFilePathSuffix), - $"Ensure you have created '{Path.GetFullPath(targetDir + SecondaryCodeownersFilePathSuffix)}'. " + - $"See comment on WriteTwoCodeownersFilesOwnersDiffToCsv for details."); - - WriteOwnersDiffToCsv( - new[] - { - (targetDirPathSuffix, CodeownersFilePathSuffix, ignoredPathPrefixes), - (targetDirPathSuffix, SecondaryCodeownersFilePathSuffix, ignoredPathPrefixes) - }, - outputFileNamePrefix); - } - - #endregion - - #region private static - - /// - /// This method is similar to: - /// - /// WriteOwnersDiffToCsv - /// - /// Except it is not doing any diffing: it just evaluates one invocation of - /// Azure.Sdk.Tools.RetrieveCodeOwners.Program.Main - /// and returns its information, in similar, but simplified table format. - /// - /// If given path, provided in column PATH, did not match any path in CODEOWNERS file, - /// the column PATH EXPRESSION will have a value of _____ . - /// - /// In addition, this method also does an validation of CODEOWNERS paths - /// and if it find a problem with given path, it returns output lines with ISSUE column - /// populated and PATH column empty, as there is no path to speak of - only CODEOWNERS path, - /// provided in PATH EXPRESSION column, is present. - /// - /// The ISSUE column has following codes: - /// - /// INVALID_PATH_CONTAINS_UNSUPPORTED_FRAGMENTS - /// All CODEOWNERS paths must not contain unsupported path fragments, as defined by: - /// Azure.Sdk.Tools.CodeOwnersParser.MatchedCodeownersEntry.ContainsUnsupportedFragments - /// - /// INVALID_PATH_SHOULD_START_WITH_SLASH - /// All CODEOWNERS paths must start with "/", but given path doesn't. - /// Such path will still be processed by our CODEOWNERS interpreter, but nevertheless it is - /// invalid and should be fixed. - /// - /// INVALID_PATH_MATCHES_DIR_EXACTLY - /// INVALID_PATH_MATCHES_DIR_EXACTLY_AND_NAME_PREFIX - /// INVALID_PATH_MATCHES_NAME_PREFIX - /// CODEOWNERS file contains a simple (i.e. without wildcards) path that is expected to match against - /// a file, as it does not end with "/". However, the repository contains one or more of the following: - /// - a directory with the same path - /// - a directory with such path being its name prefix: e.g. the path is /foobar and the dir is /foobarbaz/ - /// - a file with such path being its name prefix: e.g. the path is /foobar and the file is /foobarbaz.txt - /// - /// Such paths are invalid because they ambiguous and need to be disambiguated. - /// If the match is only to exact directory, then such CODEOWNERS path will never match any input path. - /// Usually the proper fix - /// is to add the missing suffix "/" to the path to make it correctly match against the existing directory. - /// If the match is to directory prefix, then this can be solved by appending "*/". This will match both - /// exact directories, and directory prefixes. - /// If the match is to file name prefix only, this can be fixed by appending "*". - /// If the match is both to directory and file name prefixes, possibly multiple paths need to be used, - /// one with "*/" suffix and one with "*" suffix. - /// - /// WILDCARD_FILE_PATH_NEEDS_MANUAL_EVAL - /// Same situation as above, but the CODEOWNERS path is a file path with a wildcard, hence current - /// validation implementation cannot yet determine if it should be a path to directory or not. - /// Hence, this needs to be checked manually by ensuring that the wildcard file path matches - /// at least one file in the repository. - /// - /// Known limitation: - /// If given CODEOWNERS path has no owners listed on its line, this method will not report such path as invalid. - /// - private static void WriteOwnersToCsv( - string targetDirPathSuffix, - string codeownersFilePathSuffix, - string ignoredPrefixes, - string outputFilePrefix) - { - var stopwatch = Stopwatch.StartNew(); - string rootDir = PathNavigatingToRootDir(CurrentDir); - string targetDir = rootDir + targetDirPathSuffix; - - Dictionary ownersData = RetrieveCodeowners( - targetDirPathSuffix, - codeownersFilePathSuffix, - ignoredPrefixes); - - List outputLines = - new List { "PATH | PATH EXPRESSION | OWNERS | ISSUE" }; - foreach (KeyValuePair kvp in ownersData) - { - string path = kvp.Key; - CodeownersEntry entry = kvp.Value; - outputLines.Add( - $"{path} " + - $"| {(entry.IsValid ? entry.PathExpression : "_____")} " + - $"| {string.Join(",", entry.Owners)}"); - } - - outputLines.AddRange(PathsWithIssues(targetDir, codeownersFilePathSuffix, paths: ownersData.Keys.ToArray())); - - var outputFilePath = outputFilePrefix + OwnersDataOutputPathSuffix; - File.WriteAllLines(outputFilePath, outputLines); - Console.WriteLine($"DONE writing out owners. " + - $"Output written out to {Path.GetFullPath(outputFilePath)}. " + - $"Time taken: {stopwatch.Elapsed}."); - } - - // Possible future work: - // instead of returning lines with issues, consider returning the modified & fixed CODEOWNERS file. - // It could work by reading all the lines, then replacing the wrong - // lines by using dict replacement. Need to be careful about retaining spaces to not misalign, - // e.g. - // "sdk/ @own1" --> "/sdk/ @own1" // space removed to keep alignment - // but also: - // "sdk/ @own1" --> "/sdk/ @own1" // space not removed, because it would be invalid. - private static List PathsWithIssues( - string targetDir, - string codeownersPathSuffix, - string[] paths) - { - List outputLines = new List(); - List entries = - CodeownersFile.GetCodeownersEntriesFromFileOrUrl(targetDir + codeownersPathSuffix) - .Where(entry => !entry.PathExpression.StartsWith("#")) - .ToList(); - - outputLines.AddRange(PathsWithMissingPrefixSlash(entries)); - outputLines.AddRange(PathsWithMissingSuffixSlash(targetDir, entries, paths)); - outputLines.AddRange(InvalidPaths(entries)); - // TODO: add a check here for CODEOWNERS paths that do not match any dir or file. - - return outputLines; - } - - private static List PathsWithMissingPrefixSlash(List entries) - => entries - .Where(entry => !entry.PathExpression.StartsWith("/")) - .Select(entry => - "|" + - $"{entry.PathExpression} " + - $"| {string.Join(",", entry.Owners)}" + - "| INVALID_PATH_SHOULD_START_WITH_SLASH") - .ToList(); - - private static List PathsWithMissingSuffixSlash( - string targetDir, - List entries, - string[] paths) - { - List outputLines = new List(); - foreach (CodeownersEntry entry in entries.Where(entry => !entry.PathExpression.EndsWith("/"))) - { - if (entry.ContainsWildcard) - { - // We do not support "the path is to file while it should be to directory" validation for paths - // with wildcards yet. To do that, we would first need to resolve the path and see if there exists - // a concrete path that includes the CODEOWNERS paths supposed-file-name as - // infix dir. - // For example, /a/**/b could match against /a/foo/b/c, meaning - // the path is invalid. - outputLines.Add( - "|" + - $"{entry.PathExpression} " + - $"| {string.Join(",", entry.Owners)}" + - "| WILDCARD_FILE_PATH_NEEDS_MANUAL_EVAL"); - } - else - { - string trimmedPathExpression = entry.PathExpression.TrimStart('/'); - - bool matchesDirExactly = MatchesDirExactly(targetDir, trimmedPathExpression); - bool matchesNamePrefix = MatchesNamePrefix(paths, trimmedPathExpression); - - if (matchesDirExactly || matchesNamePrefix) - { - string msgCode = matchesDirExactly && matchesNamePrefix ? "MATCHES_DIR_EXACTLY_AND_NAME_PREFIX" : - matchesDirExactly ? "MATCHES_DIR_EXACTLY" : "MATCHES_NAME_PREFIX"; - - outputLines.Add( - "|" + - $"{entry.PathExpression} " + - $"| {string.Join(",", entry.Owners)}" + - $"| INVALID_PATH_{msgCode}"); - } - } - } - return outputLines; - } - - private static bool MatchesNamePrefix(string[] paths, string trimmedPathExpression) - => paths.Any( - path => - { - string trimmedPath = path.TrimStart('/'); - bool pathIsChildDir = trimmedPath.Contains("/") - && trimmedPath.Length > trimmedPathExpression.Length - && trimmedPath.Substring(trimmedPathExpression.Length).StartsWith('/'); - return trimmedPath.StartsWith(trimmedPathExpression) - && trimmedPath.Length != trimmedPathExpression.Length - && !pathIsChildDir; - }); - - private static bool MatchesDirExactly(string targetDir, string trimmedPathExpression) - { - string pathToDir = Path.Combine( - targetDir, - trimmedPathExpression.Replace('/', Path.DirectorySeparatorChar)); - return Directory.Exists(pathToDir); - } - - private static List InvalidPaths(List entries) - => entries - .Where(entry => !MatchedCodeownersEntry.IsCodeownersPathValid(entry.PathExpression)) - .Select( - entry => - "|" + - $"{entry.PathExpression} " + - $"| {string.Join(",", entry.Owners)}" + - "| INVALID_PATH") - .ToList(); - - /// - /// Writes to .csv file the difference of owners for all paths in given repository, - /// between two invocations of Azure.Sdk.Tools.RetrieveCodeOwners.Program.Main, - /// denoted as LEFT and RIGHT. RetrieveCodeOwners.Program.Main method reads - /// all files in given input repository, and tries to find owners for them based on - /// CODEOWNERS matching configuration given as its parameters. - /// - /// You can import the test output into Excel, using .csv import wizard and - /// selecting "|" as column separator. - /// - /// The resulting .csv file has following headers: - /// - /// DIFF CODE | PATH | LEFT PATH EXPRESSION | RIGHT PATH EXPRESSION | LEFT OWNERS | RIGHT OWNERS - /// - /// where LEFT denotes the RetrieveCodeOwners.Program.Main configuration as provided by input[0]. - /// and RIGHT denotes the RetrieveCodeOwners.Program.Main configuration as provided by input[1]. - /// - /// The columns have following values and meanings: - /// - /// DIFF CODE: - /// PATH _____-RIGHT - /// A file with given path, given in the column PATH, was not matched to any CODEOWNERS - /// path when using the LEFT configuration but it was matched when using the RIGHT configuration. - /// - /// PATH LEFT -_____ - /// Analogous to the case described above, but LEFT configuration has matched, and RIGHT didn't. - /// - /// PATH _____-_____ - /// A file with given path did not match to any CODEOWNERS path, whether using the LEFT - /// configuration or RIGHT configuration. - /// Such file has effectively no owners assigned, no matter which configuration is used. - /// - /// OWNERS DIFF - /// A file with given path matched both when using LEFT and RIGHT configurations, but - /// the CODEOWNERS path to which it matched has different set of owners. - /// - /// PATH: - /// A path to the file being matched against CODEOWNERS path to determine owners. - /// - /// LEFT PATH EXPRESSION: - /// RIGHT PATH EXPRESSION: - /// A CODEOWNERS path that matched to PATH when using LEFT (or RIGHT, respectively) configuration. - /// - /// LEFT OWNERS: - /// RIGHT OWNERS: - /// The owners assigned to given LEFT PATH EXPRESSION (or RIGHT PATH EXPRESSION, respectively). - /// - private static void WriteOwnersDiffToCsv( - ( - string targetDirPathSuffix, - string codeownersFilePathSuffix, - string ignoredPrefixes - )[] input, - string outputFilePrefix) - { - var stopwatch = Stopwatch.StartNew(); - - Dictionary leftOwners = RetrieveCodeowners( - input[0].targetDirPathSuffix, - input[0].codeownersFilePathSuffix, - input[0].ignoredPrefixes); - Dictionary rightOwners = RetrieveCodeowners( - input[1].targetDirPathSuffix, - input[1].codeownersFilePathSuffix, - input[1].ignoredPrefixes); - - string[] diffLines = PathOwnersDiff(leftOwners, rightOwners); - - var outputFilePath = outputFilePrefix + OwnersDiffOutputPathSuffix; - File.WriteAllLines(outputFilePath, diffLines); - Console.WriteLine($"DONE diffing. " + - $"Output written out to {Path.GetFullPath(outputFilePath)}. " + - $"Time taken: {stopwatch.Elapsed}."); - } - - private static Dictionary RetrieveCodeowners( - string targetDirPathSuffix, - string codeownersFilePathSuffixToRootDir, - string ignoredPathPrefixes) - { - string rootDir = PathNavigatingToRootDir(CurrentDir); - string targetDir = rootDir + targetDirPathSuffix; - string codeownersFilePath = targetDir + codeownersFilePathSuffixToRootDir; - Debug.Assert(Directory.Exists(targetDir)); - Debug.Assert(File.Exists(codeownersFilePath)); - - string actualOutput, actualErr; - int returnCode; - using (var consoleOutput = new ConsoleOutput()) - { - // Act - returnCode = Program.Main( - targetPath: "/**", - codeownersFilePath, - // false because we want to see the full owners diff, but observe that - // for the build failure notification recipients determination it should be true, - // because Contacts.GetMatchingCodeownersEntry() calls ExcludeNonUserAliases(). - excludeNonUserAliases: false, - targetDir, - ignoredPathPrefixes); - - actualOutput = consoleOutput.GetStdout(); - actualErr = consoleOutput.GetStderr(); - } - - var actualEntries = JsonSerializer.Deserialize>(actualOutput)!; - return actualEntries; - } - - private static string PathNavigatingToRootDir(string currentDir) - => "./" + string.Join( - "/", - currentDir - .Split("/", StringSplitOptions.RemoveEmptyEntries) - .Select(_ => "..")); - - private static string[] PathOwnersDiff( - Dictionary left, - Dictionary right) - { - Debug.Assert( - left.Keys.ToHashSet().SetEquals(right.Keys.ToHashSet()), - "The compared maps of owner data are expected to have the same paths (keys)."); - - List outputLines = new List - { - "DIFF CODE | PATH | LEFT PATH EXPRESSION | RIGHT PATH EXPRESSION | LEFT OWNERS | RIGHT OWNERS" - }; - foreach (string path in left.Keys) - { - if (left[path].IsValid && right[path].IsValid) - { - // Path matched against an entry in both "left" and "right" owners data. - // Here we determine if the owners lists match. - outputLines.AddRange(PathOwnersDiff(path, left[path], right[path])); - } - else if (left[path].IsValid && !right[path].IsValid) - { - // Path matched against an entry in the "left" owners data, but not in the right. - outputLines.Add($"PATH LEFT -_____ " + - $"| {path} | {left[path].PathExpression} | | {string.Join(",",left[path].Owners)} |"); - } - else if (!left[path].IsValid && right[path].IsValid) - { - // Path matched against an entry in the "right" owners data, but not in the right. - outputLines.Add($"PATH _____-RIGHT " + - $"| {path} | | {right[path].PathExpression} | | {string.Join(",",right[path].Owners)}"); - } - else - { - // Path did not match against any owners data, not in "left" nor "right". - outputLines.Add($"PATH _____-_____ | {path} |"); - } - } - - return outputLines.ToArray(); - } - - private static string[] PathOwnersDiff( - string path, - CodeownersEntry left, - CodeownersEntry right) - { - Debug.Assert(left.IsValid); - Debug.Assert(right.IsValid); - - List outputLines = new List(); - - if (!left.Owners.ToHashSet().SetEquals(right.Owners.ToHashSet())) - { - // Given path owners differ between "left" an "right" owners data. - outputLines.Add( - $"OWNERS DIFF | {path} " + - $"| {left.PathExpression} | {right.PathExpression} " + - $"| {string.Join(", ", left.Owners)} | {string.Join(", ", right.Owners)}"); - } - - return outputLines.ToArray(); - } - - #endregion -} diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/ConsoleOutput.cs b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/ConsoleOutput.cs deleted file mode 100644 index 8b1803391a3..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/ConsoleOutput.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.IO; - -namespace Azure.Sdk.Tools.RetrieveCodeOwners.Tests -{ - /// - /// The class is to redirect console STDOUT and STDERR to string writer. - /// - public class ConsoleOutput : IDisposable - { - private readonly StringWriter stdoutWriter, stderrWriter; - private readonly TextWriter originalStdout, originalStderr; - - /// - /// The constructor is where we take in the console output and output to string writer. - /// - public ConsoleOutput() - { - this.stdoutWriter = new StringWriter(); - this.stderrWriter = new StringWriter(); - this.originalStdout = Console.Out; - this.originalStderr = Console.Error; - Console.SetOut(this.stdoutWriter); - Console.SetError(this.stderrWriter); - } - - /// - /// Writes the text representation of a string builder to the string. - /// - /// The string from console output. - public string GetStdout() - => this.stdoutWriter.ToString(); - - public string[] GetStdoutLines() - => this.stdoutWriter.ToString().Split(Environment.NewLine); - - public string GetStderr() - => this.stderrWriter.ToString(); - - public string[] GetStderrLines() - => this.stderrWriter.ToString().Split(Environment.NewLine); - - /// - /// Releases all resources used by the originalOutput and stringWriter object. - /// - public void Dispose() - { - Console.SetOut(this.originalStdout); - Console.SetError(this.originalStderr); - this.stdoutWriter.Dispose(); - this.stderrWriter.Dispose(); - this.originalStdout.Dispose(); - this.originalStderr.Dispose(); - // https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1816 - GC.SuppressFinalize(this); - } - - /// - /// Closes the current writer and releases any system resources associated with the writer - /// - public void Close() - { - this.stdoutWriter.Close(); - this.stderrWriter.Close(); - this.originalStderr.Close(); - this.originalStdout.Close(); - } - } - -} diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/RetrieveCodeOwnersProgramTests.cs b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/RetrieveCodeOwnersProgramTests.cs deleted file mode 100644 index 1879eecda4d..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/RetrieveCodeOwnersProgramTests.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using Azure.Sdk.Tools.CodeOwnersParser; -using NUnit.Framework; - -namespace Azure.Sdk.Tools.RetrieveCodeOwners.Tests; - -/// -/// Test class for Azure.Sdk.Tools.RetrieveCodeOwners.Program.Main(), -/// -/// The tests assertion expectations are set to match GitHub CODEOWNERS interpreter behavior, -/// as explained here: -/// https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners -/// and as observed based on manual tests and verification. -/// -/// For additional related tests, please see: -/// - Azure.Sdk.Tools.CodeOwnersParser.Tests.CodeownersFileTests -/// -[TestFixture] -public class RetrieveCodeOwnersProgramTests -{ - /// - /// A battery of test cases exercising the Azure.Sdk.Tools.RetrieveCodeOwners.Program.Main executable. - /// - /// Each test case is composed of a targetPath and expected CodeownersEntry that is to match against - /// the targetPath when the executable is executed. - /// - /// These test battery is used in the following ways: - /// - /// 1. In OutputsCorrectCodeownersOnSimpleTargetPath parameterized unit test, each test case is exercised - /// by running the executable with targetPath provided as input targetPath. - /// - /// 2. In OutputsCorrectCodeownersOnGlobTargetPath the entire test battery is asserted against - /// by running the executable with targetPaths set to "/**", thus entering the glob-matching mode and finding - /// all the targetPaths present in this battery. - /// - /// Preconditions for running tests against this battery: - /// - directory "./TestData/InputDir" and file "./TestData/test_CODEOWNERS" contain appropriate contents - /// - the exercised executable is passed as input appropriate arguments pointing to the file system; - /// consult the aforementioned tests for concrete values. - /// - private static readonly TestCase[] testCases = - { - // @formatter:off - // targetPath expected CodeownersEntry - new ("a.txt" , new CodeownersEntry("/*", new List { "star" })), - new ("b.txt" , new CodeownersEntry("/*", new List { "star" })), - new ("foo/a.txt" , new CodeownersEntry("/foo/**/a.txt", new List { "foo_2star_a" })), - new ("foo/b.txt" , new CodeownersEntry("/**", new List { "2star" })), - new ("foo/bar/a.txt" , new CodeownersEntry("/foo/*/a.txt", new List { "foo_star_a_1", "foo_star_a_2" })), - new ("foo/bar/b.txt" , new CodeownersEntry("/**", new List { "2star" })), - new ("baz/cor/c.txt" , new CodeownersEntry("/baz*", new List { "baz_star" })), - new ("baz_.txt" , new CodeownersEntry("/baz*", new List { "baz_star" })), - new ("qux/abc/d.txt" , new CodeownersEntry("/qux/", new List { "qux" })), - new ("cor.txt" , new CodeownersEntry("/*", new List { "star" })), - new ("cor2/a.txt" , new CodeownersEntry("/**", new List { "2star" })), - new ("cor/gra/a.txt" , new CodeownersEntry("/**", new List { "2star" })) - // @formatter:on - }; - - private static Dictionary TestCasesAsDictionary - => testCases.ToDictionary( - testCase => testCase.TargetPath, - testCase => testCase.ExpectedCodeownersEntry); - - /// - /// Please see comment on RetrieveCodeOwnersProgramTests.testCases - /// - [TestCaseSource(nameof(testCases))] - public void OutputsCorrectCodeownersOnSimpleTargetPath(TestCase testCase) - { - const string targetDir = "./TestData/InputDir"; - const string codeownersFilePathOrUrl = "./TestData/test_CODEOWNERS"; - const bool excludeNonUserAliases = false; - - var targetPath = testCase.TargetPath; - var expectedEntry = testCase.ExpectedCodeownersEntry; - - // Act - (string actualOutput, string actualErr, int returnCode) = RunProgramMain( - targetPath, - codeownersFilePathOrUrl, - excludeNonUserAliases, - targetDir); - - CodeownersEntry actualEntry = TryDeserializeActualEntryFromSimpleTargetPath(actualOutput, actualErr); - - Assert.Multiple(() => - { - Assert.That(actualEntry, Is.EqualTo(expectedEntry), $"path: {targetPath}"); - Assert.That(returnCode, Is.EqualTo(0)); - Assert.That(actualErr, Is.EqualTo(string.Empty)); - }); - } - - /// - /// Please see comment on RetrieveCodeOwnersProgramTests.testCases - /// - [Test] - public void OutputsCorrectCodeownersOnGlobTargetPath() - { - const string targetDir = "./TestData/InputDir"; - const string targetPath = "/**"; - const string codeownersFilePathOrUrl = "./TestData/test_CODEOWNERS"; - const bool excludeNonUserAliases = false; - - Dictionary expectedEntriesByPath = TestCasesAsDictionary; - - // Act - (string actualOutput, string actualErr, int returnCode) = RunProgramMain( - targetPath, - codeownersFilePathOrUrl, - excludeNonUserAliases, - targetDir); - - Dictionary actualEntriesByPath = TryDeserializeActualEntriesFromGlobTargetPath(actualOutput, actualErr); - - Assert.Multiple(() => - { - AssertEntries(actualEntriesByPath, expectedEntriesByPath); - Assert.That(returnCode, Is.EqualTo(0)); - Assert.That(actualErr, Is.EqualTo(string.Empty)); - }); - } - - private static (string actualOutput, string actualErr, int returnCode) RunProgramMain( - string targetPath, - string codeownersFilePathOrUrl, - bool excludeNonUserAliases, - string targetDir) - { - string actualOutput, actualErr; - int returnCode; - using (var consoleOutput = new ConsoleOutput()) - { - // Act - returnCode = Program.Main( - targetPath, - codeownersFilePathOrUrl, - excludeNonUserAliases, - targetDir); - - actualOutput = consoleOutput.GetStdout(); - actualErr = consoleOutput.GetStderr(); - } - - return (actualOutput, actualErr, returnCode); - } - - private static CodeownersEntry TryDeserializeActualEntryFromSimpleTargetPath( - string actualOutput, - string actualErr) - { - CodeownersEntry actualEntry; - try - { - actualEntry = - JsonSerializer.Deserialize(actualOutput)!; - } - catch (Exception e) - { - Console.WriteLine(e); - Console.WriteLine("actualOutput: " + actualOutput); - Console.WriteLine("actualErr: " + actualErr); - throw; - } - - return actualEntry; - } - - private static Dictionary TryDeserializeActualEntriesFromGlobTargetPath( - string actualOutput, - string actualErr) - { - Dictionary actualEntries; - try - { - actualEntries = - JsonSerializer.Deserialize>(actualOutput)!; - } - catch (Exception e) - { - Console.WriteLine(e); - Console.WriteLine("actualOutput: " + actualOutput); - Console.WriteLine("actualErr: " + actualErr); - throw; - } - - return actualEntries; - } - - private static void AssertEntries( - Dictionary actualEntries, - Dictionary expectedEntries) - { - foreach (KeyValuePair kvp in actualEntries) - { - string path = kvp.Key; - CodeownersEntry actualEntry = kvp.Value; - Assert.That(actualEntry, Is.EqualTo(expectedEntries[path]), $"path: {path}"); - } - - Assert.That(actualEntries, Has.Count.EqualTo(expectedEntries.Count)); - } - - /// - /// Please see comment on RetrieveCodeOwnersProgramTests.testCases - /// - public record TestCase( - string TargetPath, - CodeownersEntry ExpectedCodeownersEntry); -} diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/a.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/a.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/b.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/b.txt deleted file mode 100644 index 30b72c114c7..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/b.txt +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Azure.Sdk.Tools.RetrieveCodeOwners.Tests.TestData -{ - class b - { - } -} diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/baz/cor/c.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/baz/cor/c.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/baz_.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/baz_.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/cor.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/cor.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/cor/gra/a.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/cor/gra/a.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/cor2/a.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/cor2/a.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/a.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/a.txt deleted file mode 100644 index 0b1b706b30d..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/a.txt +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Azure.Sdk.Tools.RetrieveCodeOwners.Tests.TestData.foo -{ - class a - { - } -} diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/b.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/b.txt deleted file mode 100644 index e1bac95f81c..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/b.txt +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Azure.Sdk.Tools.RetrieveCodeOwners.Tests.TestData.foo -{ - class b - { - } -} diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/bar/a.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/bar/a.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/bar/b.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/foo/bar/b.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/qux/abc/d.txt b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/qux/abc/d.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/test_CODEOWNERS b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/test_CODEOWNERS deleted file mode 100644 index fdf41242c53..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/test_CODEOWNERS +++ /dev/null @@ -1,16 +0,0 @@ -# This file is a test resoure for the test: -# -# Azure.Sdk.Tools.RetrieveCodeOwners.Tests.WildcardTests.TestWildcard -# - -/** @2star -/* @star - -/foo/**/a.txt @foo_2star_a -/foo/*/a.txt @foo_star_a_1 @foo_star_a_2 - -/baz* @baz_star - -/qux/ @qux - -/cor @cor \ No newline at end of file diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Azure.Sdk.Tools.RetrieveCodeOwners.csproj b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Azure.Sdk.Tools.RetrieveCodeOwners.csproj deleted file mode 100644 index 6ac4695ec59..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Azure.Sdk.Tools.RetrieveCodeOwners.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - Exe - net6.0 - enable - Nullable - true - retrieve-codeowners - 1.0.0 - - - - - - - - - - - diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Program.cs b/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Program.cs deleted file mode 100644 index 07ca20b85b9..00000000000 --- a/tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Program.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text.Json; -using Azure.Sdk.Tools.CodeOwnersParser; - -namespace Azure.Sdk.Tools.RetrieveCodeOwners; - -/// -/// See Program.Main comment. -/// -public static class Program -{ - /// - /// See comment on Azure.Sdk.Tools.RetrieveCodeOwners.Program.Main, - /// for parameter "ignoredPathPrefixes". - /// - public const string DefaultIgnoredPrefixes = ".git"; - - /// - /// Given targetPath and CODEOWNERS file path or https url codeownersFilePathOrUrl, - /// prints out to stdout owners of the targetPath as determined by the CODEOWNERS data. - /// - /// The path whose owners are to be determined. Can be a glob path. - /// The https url or path to the CODEOWNERS file. - /// Whether owners that aren't users should be excluded from - /// the returned owners. - /// - /// The directory to search for file paths in case targetPath is a glob path. Unused otherwise. - /// - /// - /// A list of path prefixes, separated by |, to ignore when doing - /// glob-matching against glob targetPath. - /// Applies only if targetPath is a glob path. Unused otherwise. - /// Defaults to ".git". - /// Example usage: ".git|foo|bar" - /// - /// Override for the default URI where the team/storage blob data resides. - /// File to output the owners data to, will overwrite if the file exist. - /// - /// On STDOUT: The JSON representation of the matched CodeownersEntry. - /// "new CodeownersEntry()" if no path in the CODEOWNERS data matches. - ///

- /// From the Main method: exit code. 0 if successful, 1 if error. - ///
- public static int Main( - string targetPath, - string codeownersFilePathOrUrl, - bool excludeNonUserAliases = false, - string? targetDir = null, - string ignoredPathPrefixes = DefaultIgnoredPrefixes, - string? teamStorageURI = null, - string? ownersDataOutputFile = null) - { - try - { - Trace.Assert(!string.IsNullOrWhiteSpace(targetPath)); - - targetPath = targetPath.Trim(); - targetDir = targetDir?.Trim(); - codeownersFilePathOrUrl = codeownersFilePathOrUrl.Trim(); - - Trace.Assert(!string.IsNullOrWhiteSpace(codeownersFilePathOrUrl)); - Trace.Assert(!targetPath.IsGlobFilePath() - || (targetDir != null && Directory.Exists(targetDir))); - - // The "object" here is effectively an union of two types: T1 | T2, - // where T1 is the type returned by GetCodeownersForGlobPath - // and T2 is the type returned by GetCodeownersForSimplePath. - object codeownersData = targetPath.IsGlobFilePath() - ? GetCodeownersForGlobPath( - new GlobFilePath(targetPath), - targetDir!, - codeownersFilePathOrUrl, - excludeNonUserAliases, - SplitIgnoredPathPrefixes(), - teamStorageURI) - : GetCodeownersForSimplePath( - targetPath, - codeownersFilePathOrUrl, - excludeNonUserAliases, - teamStorageURI); - - string codeownersJson = JsonSerializer.Serialize( - codeownersData, - new JsonSerializerOptions { WriteIndented = true }); - - Console.WriteLine(codeownersJson); - - // If the output data file is specified, write the json to that. - if (!string.IsNullOrEmpty(ownersDataOutputFile)) - { - // False in the ctor is to overwrite, not append - using (StreamWriter outputFile = new StreamWriter(ownersDataOutputFile, false)) - { - outputFile.WriteLine(codeownersJson); - } - } - return 0; - - string[] SplitIgnoredPathPrefixes() - => ignoredPathPrefixes.Split( - "|", - StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); - } - catch (Exception e) - { - Console.Error.WriteLine(e); - return 1; - } - } - - private static Dictionary GetCodeownersForGlobPath( - GlobFilePath targetPath, - string targetDir, - string codeownersFilePathOrUrl, - bool excludeNonUserAliases, - string[]? ignoredPathPrefixes = null, - string? teamStorageURI=null) - { - ignoredPathPrefixes ??= Array.Empty(); - - Dictionary codeownersEntries = - CodeownersFile.GetMatchingCodeownersEntries( - targetPath, - targetDir, - codeownersFilePathOrUrl, - ignoredPathPrefixes, - teamStorageURI); - - if (excludeNonUserAliases) - codeownersEntries.Values.ToList().ForEach(entry => entry.ExcludeNonUserAliases()); - - return codeownersEntries; - } - - private static CodeownersEntry GetCodeownersForSimplePath( - string targetPath, - string codeownersFilePathOrUrl, - bool excludeNonUserAliases, - string? teamStorageURI = null) - { - CodeownersEntry codeownersEntry = - CodeownersFile.GetMatchingCodeownersEntry( - targetPath, - codeownersFilePathOrUrl, - teamStorageURI); - - if (excludeNonUserAliases) - codeownersEntry.ExcludeNonUserAliases(); - - return codeownersEntry; - } -} diff --git a/tools/code-owners-parser/CodeOwnersParser.sln b/tools/code-owners-parser/CodeOwnersParser.sln index 8fa63a1ca1c..a6c98e6be24 100644 --- a/tools/code-owners-parser/CodeOwnersParser.sln +++ b/tools/code-owners-parser/CodeOwnersParser.sln @@ -1,51 +1,31 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.CodeOwnersParser", "CodeOwnersParser\Azure.Sdk.Tools.CodeOwnersParser.csproj", "{55D665BF-A4B3-45EA-A2A0-B33AFB208766}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.RetrieveCodeOwners", "Azure.Sdk.Tools.RetrieveCodeOwners\Azure.Sdk.Tools.RetrieveCodeOwners.csproj", "{FE65F92D-C71B-4E38-A4B2-3089EA7C5FEC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.RetrieveCodeOwners.Tests", "Azure.Sdk.Tools.RetrieveCodeOwners.Tests\Azure.Sdk.Tools.RetrieveCodeOwners.Tests.csproj", "{798B8CAC-68FC-49FD-A0F6-51C0DC4A4D1D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EF585CCA-55F8-44EB-921A-30996CBAFC49}" - ProjectSection(SolutionItems) = preProject - ci.yml = ci.yml - ..\..\eng\common\scripts\get-codeowners.lib.ps1 = ..\..\eng\common\scripts\get-codeowners.lib.ps1 - ..\..\eng\common\scripts\get-codeowners.ps1 = ..\..\eng\common\scripts\get-codeowners.ps1 - ..\..\eng\common-tests\get-codeowners\get-codeowners.tests.ps1 = ..\..\eng\common-tests\get-codeowners\get-codeowners.tests.ps1 - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.CodeOwnersParser.Tests", "Azure.Sdk.Tools.CodeOwnersParser.Tests\Azure.Sdk.Tools.CodeOwnersParser.Tests.csproj", "{66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {55D665BF-A4B3-45EA-A2A0-B33AFB208766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {55D665BF-A4B3-45EA-A2A0-B33AFB208766}.Debug|Any CPU.Build.0 = Debug|Any CPU - {55D665BF-A4B3-45EA-A2A0-B33AFB208766}.Release|Any CPU.ActiveCfg = Release|Any CPU - {55D665BF-A4B3-45EA-A2A0-B33AFB208766}.Release|Any CPU.Build.0 = Release|Any CPU - {FE65F92D-C71B-4E38-A4B2-3089EA7C5FEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FE65F92D-C71B-4E38-A4B2-3089EA7C5FEC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FE65F92D-C71B-4E38-A4B2-3089EA7C5FEC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FE65F92D-C71B-4E38-A4B2-3089EA7C5FEC}.Release|Any CPU.Build.0 = Release|Any CPU - {798B8CAC-68FC-49FD-A0F6-51C0DC4A4D1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {798B8CAC-68FC-49FD-A0F6-51C0DC4A4D1D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {798B8CAC-68FC-49FD-A0F6-51C0DC4A4D1D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {798B8CAC-68FC-49FD-A0F6-51C0DC4A4D1D}.Release|Any CPU.Build.0 = Release|Any CPU - {66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E32EEF98-9184-4346-8801-C5A8A1C7FD7D} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.CodeOwnersParser", "CodeOwnersParser\Azure.Sdk.Tools.CodeOwnersParser.csproj", "{55D665BF-A4B3-45EA-A2A0-B33AFB208766}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.CodeOwnersParser.Tests", "Azure.Sdk.Tools.CodeOwnersParser.Tests\Azure.Sdk.Tools.CodeOwnersParser.Tests.csproj", "{66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {55D665BF-A4B3-45EA-A2A0-B33AFB208766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {55D665BF-A4B3-45EA-A2A0-B33AFB208766}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55D665BF-A4B3-45EA-A2A0-B33AFB208766}.Release|Any CPU.ActiveCfg = Release|Any CPU + {55D665BF-A4B3-45EA-A2A0-B33AFB208766}.Release|Any CPU.Build.0 = Release|Any CPU + {66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66C9FF6A-32DD-4C3C-ABE1-F1F58C1C8129}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E32EEF98-9184-4346-8801-C5A8A1C7FD7D} + EndGlobalSection +EndGlobal diff --git a/tools/code-owners-parser/ci.yml b/tools/code-owners-parser/ci.yml deleted file mode 100644 index d28af6b9058..00000000000 --- a/tools/code-owners-parser/ci.yml +++ /dev/null @@ -1,33 +0,0 @@ -# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. -trigger: - branches: - include: - - main - - feature/* - - release/* - - hotfix/* - paths: - include: - - tools/code-owners-parser - -pr: - branches: - include: - - main - - feature/* - - release/* - - hotfix/* - paths: - include: - - tools/code-owners-parser - - eng/common/scripts/get-codeowners - -extends: - template: /eng/pipelines/templates/stages/archetype-sdk-tool-dotnet.yml - parameters: - ToolDirectory: tools/code-owners-parser - TestPostSteps: - - template: /eng/common/pipelines/templates/steps/run-pester-tests.yml - parameters: - TargetDirectory: eng/common-tests/get-codeowners - TargetTags: UnitTest \ No newline at end of file From e61eca76024bd1b335391db4c0c15f68325b20ae Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Fri, 29 Sep 2023 21:31:54 +0000 Subject: [PATCH 2/5] Remove parameters that aren't needed --- eng/common/scripts/Update-DocsMsMetadata.ps1 | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/eng/common/scripts/Update-DocsMsMetadata.ps1 b/eng/common/scripts/Update-DocsMsMetadata.ps1 index 3dbaa12bb9b..817407f4bc1 100644 --- a/eng/common/scripts/Update-DocsMsMetadata.ps1 +++ b/eng/common/scripts/Update-DocsMsMetadata.ps1 @@ -32,14 +32,6 @@ GitHub repository ID of the SDK. Typically of the form: 'Azure/azure-sdk-for-js' The docker image id in format of '$containerRegistry/$imageName:$tag' e.g. azuresdkimages.azurecr.io/jsrefautocr:latest -.PARAMETER TenantId -The aad tenant id/object id. - -.PARAMETER ClientId -The add client id/application id. - -.PARAMETER ClientSecret -The client secret of add app. #> param( @@ -59,16 +51,7 @@ param( [string]$DocValidationImageId, [Parameter(Mandatory = $false)] - [string]$PackageSourceOverride, - - [Parameter(Mandatory = $false)] - [string]$TenantId, - - [Parameter(Mandatory = $false)] - [string]$ClientId, - - [Parameter(Mandatory = $false)] - [string]$ClientSecret + [string]$PackageSourceOverride ) Set-StrictMode -Version 3 . (Join-Path $PSScriptRoot common.ps1) From f05bc858a4e612ea540fd0ad8f1b4455db56a5d4 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Fri, 29 Sep 2023 21:56:52 +0000 Subject: [PATCH 3/5] Fix test expectations to exclude metadata that's been removed --- .../actual/latest/service-name-4-index.md | 15 ++++++------- .../inputs/actual/latest/service-name-4.md | 22 +++++++++---------- .../actual/preview/service-name-5-index.md | 14 ++++++------ .../inputs/actual/preview/service-name-5.md | 8 +++++++ .../actual/preview/service-name-6-index.md | 15 ++++++------- .../inputs/actual/preview/service-name-6.md | 22 +++++++++---------- .../inputs/expected/latest/service-name-2.md | 4 +--- .../inputs/expected/latest/service-name-4.md | 4 +--- .../inputs/expected/preview/service-name-1.md | 4 +--- .../inputs/expected/preview/service-name-3.md | 4 +--- .../inputs/expected/preview/service-name-5.md | 4 +--- .../inputs/expected/preview/service-name-6.md | 4 +--- 12 files changed, 55 insertions(+), 65 deletions(-) diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/latest/service-name-4-index.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/latest/service-name-4-index.md index fc167d680f7..42edb02de07 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/latest/service-name-4-index.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/latest/service-name-4-index.md @@ -1,8 +1,7 @@ -| Reference | Package | Source | -|---|---|---| -|Communication Chat|[azure-communication-chat](azure-communication-chat/test)|[Github](github.com)| -|Communication Identity|[azure-communication-identity](azure-communication-identity/test)|[Github](github.com/blob/main/sdk/communication/azure-communication-identity)| -|Communication Network Traversal|[azure-communication-networktraversal](azure-communication-networktraversal/test)|[Github](github.com/blob/main/sdk/communication/azure-communication-networktraversal)| -|Communication Phone Numbers|[azure-communication-phonenumbers](azure-communication-phonenumbers/test)|[Github](github.com)| -|Communication Sms|[azure-communication-sms](azure-communication-sms/test)|[Github](github.com)| -|Resource Management - Communication|[azure-mgmt-communication](azure-mgmt-communication/test)|[Github](github.com)| +| Reference | Package | Source | +|---|---|---| +|Communication Chat|[azure-communication-chat](azure-communication-chat/test)|[GitHub](github.com)| +|Communication Network Traversal|[azure-communication-networktraversal](azure-communication-networktraversal/test)|[GitHub](github.com/blob/main/sdk/communication/azure-communication-networktraversal)| +|Communication Phone Numbers|[azure-communication-phonenumbers](azure-communication-phonenumbers/test)|[GitHub](github.com)| +|Communication Sms|[azure-communication-sms](azure-communication-sms/test)|[GitHub](github.com)| +|Resource Management - Communication|[azure-mgmt-communication](azure-mgmt-communication/test)|[GitHub](github.com)| diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/latest/service-name-4.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/latest/service-name-4.md index 71e0081a2a3..9a350e48628 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/latest/service-name-4.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/latest/service-name-4.md @@ -1,13 +1,11 @@ ---- -title: Azure service name 4 SDK for Unknown -description: Reference for Azure service name 4 SDK for Unknown -author: github-alias -ms.author: msalias -ms.data: 2022-11-01 -ms.topic: reference -ms.devlang: Unknown -ms.service: ms-service ---- -# Azure service name 4 SDK for Unknown - preview -## Packages - preview +--- +title: Azure service name 4 SDK for Unknown +description: Reference for Azure service name 4 SDK for Unknown +ms.date: 2022-11-01 +ms.topic: reference +ms.devlang: Unknown +ms.service: ms-service +--- +# Azure service name 4 SDK for Unknown - preview +## Packages - preview [!INCLUDE [packages](service-name-3-index.md)] \ No newline at end of file diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-5-index.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-5-index.md index f52806c9ca8..42edb02de07 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-5-index.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-5-index.md @@ -1,7 +1,7 @@ -| Reference | Package | Source | -|---|---|---| -|Communication Chat|[azure-communication-chat](azure-communication-chat/test)|[Github](github.com)| -|Communication Network Traversal|[azure-communication-networktraversal](azure-communication-networktraversal/test)|[Github](github.com/blob/main/sdk/communication/azure-communication-networktraversal)| -|Communication Phone Numbers|[azure-communication-phonenumbers](azure-communication-phonenumbers/test)|[Github](github.com)| -|Communication Sms|[azure-communication-sms](azure-communication-sms/test)|[Github](github.com)| -|Resource Management - Communication|[azure-mgmt-communication](azure-mgmt-communication/test)|[Github](github.com)| +| Reference | Package | Source | +|---|---|---| +|Communication Chat|[azure-communication-chat](azure-communication-chat/test)|[GitHub](github.com)| +|Communication Network Traversal|[azure-communication-networktraversal](azure-communication-networktraversal/test)|[GitHub](github.com/blob/main/sdk/communication/azure-communication-networktraversal)| +|Communication Phone Numbers|[azure-communication-phonenumbers](azure-communication-phonenumbers/test)|[GitHub](github.com)| +|Communication Sms|[azure-communication-sms](azure-communication-sms/test)|[GitHub](github.com)| +|Resource Management - Communication|[azure-mgmt-communication](azure-mgmt-communication/test)|[GitHub](github.com)| diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-5.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-5.md index c27e18076ac..ac9e6e5c387 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-5.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-5.md @@ -1 +1,9 @@ +--- +title: Azure service name 5 SDK for Unknown +description: Reference for Azure service name 5 SDK for Unknown +ms.date: 2022-11-01 +ms.topic: reference +ms.devlang: Unknown +ms.service: ms-service +--- This is testing \ No newline at end of file diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-6-index.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-6-index.md index fc167d680f7..42edb02de07 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-6-index.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-6-index.md @@ -1,8 +1,7 @@ -| Reference | Package | Source | -|---|---|---| -|Communication Chat|[azure-communication-chat](azure-communication-chat/test)|[Github](github.com)| -|Communication Identity|[azure-communication-identity](azure-communication-identity/test)|[Github](github.com/blob/main/sdk/communication/azure-communication-identity)| -|Communication Network Traversal|[azure-communication-networktraversal](azure-communication-networktraversal/test)|[Github](github.com/blob/main/sdk/communication/azure-communication-networktraversal)| -|Communication Phone Numbers|[azure-communication-phonenumbers](azure-communication-phonenumbers/test)|[Github](github.com)| -|Communication Sms|[azure-communication-sms](azure-communication-sms/test)|[Github](github.com)| -|Resource Management - Communication|[azure-mgmt-communication](azure-mgmt-communication/test)|[Github](github.com)| +| Reference | Package | Source | +|---|---|---| +|Communication Chat|[azure-communication-chat](azure-communication-chat/test)|[GitHub](github.com)| +|Communication Network Traversal|[azure-communication-networktraversal](azure-communication-networktraversal/test)|[GitHub](github.com/blob/main/sdk/communication/azure-communication-networktraversal)| +|Communication Phone Numbers|[azure-communication-phonenumbers](azure-communication-phonenumbers/test)|[GitHub](github.com)| +|Communication Sms|[azure-communication-sms](azure-communication-sms/test)|[GitHub](github.com)| +|Resource Management - Communication|[azure-mgmt-communication](azure-mgmt-communication/test)|[GitHub](github.com)| diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-6.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-6.md index 2286efd9885..97e45a087fe 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-6.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/actual/preview/service-name-6.md @@ -1,13 +1,11 @@ ---- -title: Azure service name 6 SDK for Unknown -description: Reference for Azure service name 6 SDK for Unknown -author: github-alias -ms.author: msalias -ms.data: 2022-11-01 -ms.topic: reference -ms.devlang: Unknown -ms.service: ms-service ---- -# Azure service name 6 SDK for Unknown - preview -## Packages - preview +--- +title: Azure service name 6 SDK for Unknown +description: Reference for Azure service name 6 SDK for Unknown +ms.date: 2022-11-01 +ms.topic: reference +ms.devlang: Unknown +ms.service: ms-service +--- +# Azure service name 6 SDK for Unknown - preview +## Packages - preview [!INCLUDE [packages](service-name-5-index.md)] \ No newline at end of file diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/latest/service-name-2.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/latest/service-name-2.md index 730e7192707..7a80b581500 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/latest/service-name-2.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/latest/service-name-2.md @@ -1,9 +1,7 @@ --- title: Azure service name 2 SDK for Unknown description: Reference for Azure service name 2 SDK for Unknown -author: github-alias -ms.author: msalias -ms.data: 2022-11-01 +ms.date: 2022-11-01 ms.topic: reference ms.devlang: Unknown ms.service: ms-service diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/latest/service-name-4.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/latest/service-name-4.md index 71e0081a2a3..42b46ff5e39 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/latest/service-name-4.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/latest/service-name-4.md @@ -1,9 +1,7 @@ --- title: Azure service name 4 SDK for Unknown description: Reference for Azure service name 4 SDK for Unknown -author: github-alias -ms.author: msalias -ms.data: 2022-11-01 +ms.date: 2022-11-01 ms.topic: reference ms.devlang: Unknown ms.service: ms-service diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-1.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-1.md index 3b4e04c4573..f76eccf77c7 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-1.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-1.md @@ -1,9 +1,7 @@ --- title: Azure service name 1 SDK for Unknown description: Reference for Azure service name 1 SDK for Unknown -author: github-alias -ms.author: msalias -ms.data: 2022-11-01 +ms.date: 2022-11-01 ms.topic: reference ms.devlang: Unknown ms.service: ms-service diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-3.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-3.md index c3c754ba992..81517cab57b 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-3.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-3.md @@ -1,9 +1,7 @@ --- title: Azure service name 3 SDK for Unknown description: Reference for Azure service name 3 SDK for Unknown -author: github-alias -ms.author: msalias -ms.data: 2022-11-01 +ms.date: 2022-11-01 ms.topic: reference ms.devlang: Unknown ms.service: ms-service diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-5.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-5.md index d025b18b8a7..35de40f6d76 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-5.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-5.md @@ -1,9 +1,7 @@ --- title: Azure service name 5 SDK for Unknown description: Reference for Azure service name 5 SDK for Unknown -author: github-alias -ms.author: msalias -ms.data: 2022-11-01 +ms.date: 2022-11-01 ms.topic: reference ms.devlang: Unknown ms.service: ms-service diff --git a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-6.md b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-6.md index 2286efd9885..536e64a68e8 100644 --- a/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-6.md +++ b/eng/common-tests/doc-automation/service-readme-generation/inputs/expected/preview/service-name-6.md @@ -1,9 +1,7 @@ --- title: Azure service name 6 SDK for Unknown description: Reference for Azure service name 6 SDK for Unknown -author: github-alias -ms.author: msalias -ms.data: 2022-11-01 +ms.date: 2022-11-01 ms.topic: reference ms.devlang: Unknown ms.service: ms-service From 1880a3163acb2a409e2d4ff7559e2387e23e042c Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Mon, 2 Oct 2023 18:17:04 +0000 Subject: [PATCH 4/5] Remove auth information from update-docsms-metadata.yml --- .../pipelines/templates/steps/update-docsms-metadata.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/eng/common/pipelines/templates/steps/update-docsms-metadata.yml b/eng/common/pipelines/templates/steps/update-docsms-metadata.yml index 2635ad47943..63856f160ce 100644 --- a/eng/common/pipelines/templates/steps/update-docsms-metadata.yml +++ b/eng/common/pipelines/templates/steps/update-docsms-metadata.yml @@ -100,10 +100,7 @@ steps: -Language '${{parameters.Language}}' ` -RepoId '${{ parameters.RepoId }}' ` -DocValidationImageId '${{ parameters.DocValidationImageId }}' ` - -PackageSourceOverride '${{ parameters.PackageSourceOverride }}' ` - -TenantId '$(opensource-aad-tenant-id)' ` - -ClientId '$(opensource-aad-app-id)' ` - -ClientSecret '$(opensource-aad-secret)' + -PackageSourceOverride '${{ parameters.PackageSourceOverride }}' displayName: Apply Documentation Updates - template: /eng/common/pipelines/templates/steps/git-push-changes.yml From f4ecf306b28d8d33d888390969dba6f4c3764f67 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Mon, 2 Oct 2023 18:39:23 +0000 Subject: [PATCH 5/5] Fix notification-configuration.sln --- .../notification-configuration.sln | 122 ++++++++---------- 1 file changed, 55 insertions(+), 67 deletions(-) diff --git a/tools/notification-configuration/notification-configuration.sln b/tools/notification-configuration/notification-configuration.sln index 85293118f18..51eddfbb447 100644 --- a/tools/notification-configuration/notification-configuration.sln +++ b/tools/notification-configuration/notification-configuration.sln @@ -1,67 +1,55 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.33103.201 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.NotificationConfiguration", "notification-creator\Azure.Sdk.Tools.NotificationConfiguration.csproj", "{5759063D-A7B3-4D36-ACF4-5595C2789D27}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.NotificationConfiguration.Tests", "notification-creator.Tests\Azure.Sdk.Tools.NotificationConfiguration.Tests.csproj", "{3097CBB4-ED3C-4273-AC67-F5D189CB94BA}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.CodeOwnersParser", "..\code-owners-parser\CodeOwnersParser\Azure.Sdk.Tools.CodeOwnersParser.csproj", "{A9826C8B-85DF-48DB-8A05-40FB04833C42}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.CodeOwnersParser.Tests", "..\code-owners-parser\Azure.Sdk.Tools.CodeOwnersParser.Tests\Azure.Sdk.Tools.CodeOwnersParser.Tests.csproj", "{2146E1FF-04D1-4B19-9767-C011A73CB40D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "identity-resolution", "..\identity-resolution\identity-resolution.csproj", "{9805B503-5469-412C-9A0C-F09F504F0ED8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.RetrieveCodeOwners", "..\code-owners-parser\Azure.Sdk.Tools.RetrieveCodeOwners\Azure.Sdk.Tools.RetrieveCodeOwners.csproj", "{3E5237F2-6536-4329-A9CF-92E42B040612}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.RetrieveCodeOwners.Tests", "..\code-owners-parser\Azure.Sdk.Tools.RetrieveCodeOwners.Tests\Azure.Sdk.Tools.RetrieveCodeOwners.Tests.csproj", "{8DAEC12F-8390-4122-9959-9CF3391F18CC}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EBC153AF-0244-4DFB-8084-E6C0ACAA5CF3}" - ProjectSection(SolutionItems) = preProject - ci.yml = ci.yml - README.md = README.md - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5759063D-A7B3-4D36-ACF4-5595C2789D27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5759063D-A7B3-4D36-ACF4-5595C2789D27}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5759063D-A7B3-4D36-ACF4-5595C2789D27}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5759063D-A7B3-4D36-ACF4-5595C2789D27}.Release|Any CPU.Build.0 = Release|Any CPU - {A9826C8B-85DF-48DB-8A05-40FB04833C42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A9826C8B-85DF-48DB-8A05-40FB04833C42}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A9826C8B-85DF-48DB-8A05-40FB04833C42}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A9826C8B-85DF-48DB-8A05-40FB04833C42}.Release|Any CPU.Build.0 = Release|Any CPU - {9805B503-5469-412C-9A0C-F09F504F0ED8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9805B503-5469-412C-9A0C-F09F504F0ED8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9805B503-5469-412C-9A0C-F09F504F0ED8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9805B503-5469-412C-9A0C-F09F504F0ED8}.Release|Any CPU.Build.0 = Release|Any CPU - {8DAEC12F-8390-4122-9959-9CF3391F18CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8DAEC12F-8390-4122-9959-9CF3391F18CC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8DAEC12F-8390-4122-9959-9CF3391F18CC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8DAEC12F-8390-4122-9959-9CF3391F18CC}.Release|Any CPU.Build.0 = Release|Any CPU - {2146E1FF-04D1-4B19-9767-C011A73CB40D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2146E1FF-04D1-4B19-9767-C011A73CB40D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2146E1FF-04D1-4B19-9767-C011A73CB40D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2146E1FF-04D1-4B19-9767-C011A73CB40D}.Release|Any CPU.Build.0 = Release|Any CPU - {3E5237F2-6536-4329-A9CF-92E42B040612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E5237F2-6536-4329-A9CF-92E42B040612}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E5237F2-6536-4329-A9CF-92E42B040612}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E5237F2-6536-4329-A9CF-92E42B040612}.Release|Any CPU.Build.0 = Release|Any CPU - {3097CBB4-ED3C-4273-AC67-F5D189CB94BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3097CBB4-ED3C-4273-AC67-F5D189CB94BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3097CBB4-ED3C-4273-AC67-F5D189CB94BA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3097CBB4-ED3C-4273-AC67-F5D189CB94BA}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1B352588-04B2-4983-B0F6-A559065D99EC} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33103.201 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.NotificationConfiguration", "notification-creator\Azure.Sdk.Tools.NotificationConfiguration.csproj", "{5759063D-A7B3-4D36-ACF4-5595C2789D27}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.NotificationConfiguration.Tests", "notification-creator.Tests\Azure.Sdk.Tools.NotificationConfiguration.Tests.csproj", "{3097CBB4-ED3C-4273-AC67-F5D189CB94BA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.CodeOwnersParser", "..\code-owners-parser\CodeOwnersParser\Azure.Sdk.Tools.CodeOwnersParser.csproj", "{A9826C8B-85DF-48DB-8A05-40FB04833C42}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Sdk.Tools.CodeOwnersParser.Tests", "..\code-owners-parser\Azure.Sdk.Tools.CodeOwnersParser.Tests\Azure.Sdk.Tools.CodeOwnersParser.Tests.csproj", "{2146E1FF-04D1-4B19-9767-C011A73CB40D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "identity-resolution", "..\identity-resolution\identity-resolution.csproj", "{9805B503-5469-412C-9A0C-F09F504F0ED8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EBC153AF-0244-4DFB-8084-E6C0ACAA5CF3}" + ProjectSection(SolutionItems) = preProject + ci.yml = ci.yml + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5759063D-A7B3-4D36-ACF4-5595C2789D27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5759063D-A7B3-4D36-ACF4-5595C2789D27}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5759063D-A7B3-4D36-ACF4-5595C2789D27}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5759063D-A7B3-4D36-ACF4-5595C2789D27}.Release|Any CPU.Build.0 = Release|Any CPU + {3097CBB4-ED3C-4273-AC67-F5D189CB94BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3097CBB4-ED3C-4273-AC67-F5D189CB94BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3097CBB4-ED3C-4273-AC67-F5D189CB94BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3097CBB4-ED3C-4273-AC67-F5D189CB94BA}.Release|Any CPU.Build.0 = Release|Any CPU + {A9826C8B-85DF-48DB-8A05-40FB04833C42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A9826C8B-85DF-48DB-8A05-40FB04833C42}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9826C8B-85DF-48DB-8A05-40FB04833C42}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A9826C8B-85DF-48DB-8A05-40FB04833C42}.Release|Any CPU.Build.0 = Release|Any CPU + {2146E1FF-04D1-4B19-9767-C011A73CB40D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2146E1FF-04D1-4B19-9767-C011A73CB40D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2146E1FF-04D1-4B19-9767-C011A73CB40D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2146E1FF-04D1-4B19-9767-C011A73CB40D}.Release|Any CPU.Build.0 = Release|Any CPU + {9805B503-5469-412C-9A0C-F09F504F0ED8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9805B503-5469-412C-9A0C-F09F504F0ED8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9805B503-5469-412C-9A0C-F09F504F0ED8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9805B503-5469-412C-9A0C-F09F504F0ED8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1B352588-04B2-4983-B0F6-A559065D99EC} + EndGlobalSection +EndGlobal