From 0f7b2d329b624d942a7c14f63df749ae492a8409 Mon Sep 17 00:00:00 2001 From: Konrad Jamrozik Date: Thu, 23 Feb 2023 14:11:08 -0800 Subject: [PATCH 1/3] Add todos to update packages to pick up the newest CODEOWNERS interpreter --- .../retrieve-codeowners.tests.ps1 | 69 +++++++++++++++++++ eng/common/scripts/get-codeowners.ps1 | 2 +- eng/pipelines/templates/variables/globals.yml | 2 +- 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 eng/common-tests/retrieve-codeowners.tests.ps1 diff --git a/eng/common-tests/retrieve-codeowners.tests.ps1 b/eng/common-tests/retrieve-codeowners.tests.ps1 new file mode 100644 index 00000000000..d145de7d7a9 --- /dev/null +++ b/eng/common-tests/retrieve-codeowners.tests.ps1 @@ -0,0 +1,69 @@ +Import-Module Pester + +BeforeAll { + . $PSScriptRoot/../common/scripts/get-codeowners-functions.ps1 + + $ToolVersion = "1.0.0-dev.20230214.3" + $ToolPath = (Join-Path ([System.IO.Path]::GetTempPath()) "codeowners-tool-path") + $DevOpsFeed = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json" + $VsoVariable = "" + + function TestGetCodeowners2([string]$targetPath, [string]$codeownersFileLocation, [bool]$includeNonUserAliases = $false, [string[]]$expectReturn) { + Write-Host "Test: find owners matching '$targetPath' ..." + + $actualReturn = Get-Codeowners ` + -ToolVersion $ToolVersion ` + -ToolPath $ToolPath ` + -DevOpsFeed $DevOpsFeed ` + -VsoVariable $VsoVariable ` + -targetPath $targetPath ` + -codeownersFileLocation $codeownersFileLocation ` + -includeNonUserAliases $IncludeNonUserAliases + + if ($actualReturn.Count -ne $expectReturn.Count) { + Write-Error "The length of actual result is not as expected. Expected length: $($expectReturn.Count), Actual length: $($actualReturn.Count)." + exit 1 + } + for ($i = 0; $i -lt $expectReturn.Count; $i++) { + if ($expectReturn[$i] -ne $actualReturn[$i]) { + Write-Error "Expect result $expectReturn[$i] is different than actual result $actualReturn[$i]." + exit 1 + } + } + } +} + +Describe "Retrieve Codeowners" -Tag "UnitTest" { + It "Should retrieve Codeowners" -TestCases @( + @{ + $codeownersPath = "$PSScriptRoot/../../.github/CODEOWNERS"; + $targetPath = "eng/common/scripts/get-codeowners.ps1"; + $expectedOwners = @("konrad-jamrozik", "weshaggard", "benbp") + } + ) { + $azSdkToolsCodeowners = (Resolve-Path "$PSScriptRoot/../../.github/CODEOWNERS") + TestGetCodeowners2 -targetPath "eng/common/scripts/get-codeowners.ps1" -codeownersFileLocation $azSdkToolsCodeowners -includeNonUserAliases $true -expectReturn @("konrad-jamrozik", "weshaggard", "benbp") + + $LASTEXITCODE | Should -Be 0 + + $testCodeowners = (Resolve-Path "$PSScriptRoot/../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/glob_path_CODEOWNERS") + TestGetCodeowners2 -targetPath "tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/a.txt" -codeownersFileLocation $testCodeowners -includeNonUserAliases $true -expectReturn @("2star") + + $LASTEXITCODE | Should -Be 0 + } +} + +# Describe "Retrieve Codeowners" -Tag "UnitTest" { +# It "Should retrieve Codeowners" -TestCases @(@{} +# ) { +# $azSdkToolsCodeowners = (Resolve-Path "$PSScriptRoot/../../.github/CODEOWNERS") +# TestGetCodeowners2 -targetPath "eng/common/scripts/get-codeowners.ps1" -codeownersFileLocation $azSdkToolsCodeowners -includeNonUserAliases $true -expectReturn @("konrad-jamrozik", "weshaggard", "benbp") + +# $LASTEXITCODE | Should -Be 0 + +# $testCodeowners = (Resolve-Path "$PSScriptRoot/../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/glob_path_CODEOWNERS") +# TestGetCodeowners2 -targetPath "tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/a.txt" -codeownersFileLocation $testCodeowners -includeNonUserAliases $true -expectReturn @("2star") + +# $LASTEXITCODE | Should -Be 0 +# } +# } \ No newline at end of file diff --git a/eng/common/scripts/get-codeowners.ps1 b/eng/common/scripts/get-codeowners.ps1 index afe993d50ba..98e73ded533 100644 --- a/eng/common/scripts/get-codeowners.ps1 +++ b/eng/common/scripts/get-codeowners.ps1 @@ -62,7 +62,7 @@ param ( # but not this one: # Remove the obsolete, prefix-based CODEOWNERS matcher & related tests # https://github.com/Azure/azure-sdk-tools/pull/5431 - [string]$ToolVersion = "1.0.0-dev.20230214.3", + [string]$ToolVersion = "1.0.0-dev.20230214.3", # // kja TODO update [string]$ToolPath = (Join-Path ([System.IO.Path]::GetTempPath()) "codeowners-tool-path"), [string]$DevOpsFeed = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json", [string]$VsoVariable = "", diff --git a/eng/pipelines/templates/variables/globals.yml b/eng/pipelines/templates/variables/globals.yml index 69793a69eb1..f2c015a1505 100644 --- a/eng/pipelines/templates/variables/globals.yml +++ b/eng/pipelines/templates/variables/globals.yml @@ -1,5 +1,5 @@ variables: OfficialBuildId: $(Build.BuildNumber) skipComponentGovernanceDetection: true - NotificationsCreatorVersion: '1.0.0-dev.20230216.1' + NotificationsCreatorVersion: '1.0.0-dev.20230216.1' # kja TODO update PipelineOwnersExtractorVersion: '1.0.0-dev.20230211.1' From 8040d0ce6e9bb126e5913ae427a4f89944909f35 Mon Sep 17 00:00:00 2001 From: Konrad Jamrozik Date: Thu, 23 Feb 2023 14:25:07 -0800 Subject: [PATCH 2/3] remove --- .../retrieve-codeowners.tests.ps1 | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 eng/common-tests/retrieve-codeowners.tests.ps1 diff --git a/eng/common-tests/retrieve-codeowners.tests.ps1 b/eng/common-tests/retrieve-codeowners.tests.ps1 deleted file mode 100644 index d145de7d7a9..00000000000 --- a/eng/common-tests/retrieve-codeowners.tests.ps1 +++ /dev/null @@ -1,69 +0,0 @@ -Import-Module Pester - -BeforeAll { - . $PSScriptRoot/../common/scripts/get-codeowners-functions.ps1 - - $ToolVersion = "1.0.0-dev.20230214.3" - $ToolPath = (Join-Path ([System.IO.Path]::GetTempPath()) "codeowners-tool-path") - $DevOpsFeed = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json" - $VsoVariable = "" - - function TestGetCodeowners2([string]$targetPath, [string]$codeownersFileLocation, [bool]$includeNonUserAliases = $false, [string[]]$expectReturn) { - Write-Host "Test: find owners matching '$targetPath' ..." - - $actualReturn = Get-Codeowners ` - -ToolVersion $ToolVersion ` - -ToolPath $ToolPath ` - -DevOpsFeed $DevOpsFeed ` - -VsoVariable $VsoVariable ` - -targetPath $targetPath ` - -codeownersFileLocation $codeownersFileLocation ` - -includeNonUserAliases $IncludeNonUserAliases - - if ($actualReturn.Count -ne $expectReturn.Count) { - Write-Error "The length of actual result is not as expected. Expected length: $($expectReturn.Count), Actual length: $($actualReturn.Count)." - exit 1 - } - for ($i = 0; $i -lt $expectReturn.Count; $i++) { - if ($expectReturn[$i] -ne $actualReturn[$i]) { - Write-Error "Expect result $expectReturn[$i] is different than actual result $actualReturn[$i]." - exit 1 - } - } - } -} - -Describe "Retrieve Codeowners" -Tag "UnitTest" { - It "Should retrieve Codeowners" -TestCases @( - @{ - $codeownersPath = "$PSScriptRoot/../../.github/CODEOWNERS"; - $targetPath = "eng/common/scripts/get-codeowners.ps1"; - $expectedOwners = @("konrad-jamrozik", "weshaggard", "benbp") - } - ) { - $azSdkToolsCodeowners = (Resolve-Path "$PSScriptRoot/../../.github/CODEOWNERS") - TestGetCodeowners2 -targetPath "eng/common/scripts/get-codeowners.ps1" -codeownersFileLocation $azSdkToolsCodeowners -includeNonUserAliases $true -expectReturn @("konrad-jamrozik", "weshaggard", "benbp") - - $LASTEXITCODE | Should -Be 0 - - $testCodeowners = (Resolve-Path "$PSScriptRoot/../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/glob_path_CODEOWNERS") - TestGetCodeowners2 -targetPath "tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/a.txt" -codeownersFileLocation $testCodeowners -includeNonUserAliases $true -expectReturn @("2star") - - $LASTEXITCODE | Should -Be 0 - } -} - -# Describe "Retrieve Codeowners" -Tag "UnitTest" { -# It "Should retrieve Codeowners" -TestCases @(@{} -# ) { -# $azSdkToolsCodeowners = (Resolve-Path "$PSScriptRoot/../../.github/CODEOWNERS") -# TestGetCodeowners2 -targetPath "eng/common/scripts/get-codeowners.ps1" -codeownersFileLocation $azSdkToolsCodeowners -includeNonUserAliases $true -expectReturn @("konrad-jamrozik", "weshaggard", "benbp") - -# $LASTEXITCODE | Should -Be 0 - -# $testCodeowners = (Resolve-Path "$PSScriptRoot/../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/glob_path_CODEOWNERS") -# TestGetCodeowners2 -targetPath "tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/InputDir/a.txt" -codeownersFileLocation $testCodeowners -includeNonUserAliases $true -expectReturn @("2star") - -# $LASTEXITCODE | Should -Be 0 -# } -# } \ No newline at end of file From 3d2c01e12bfabab777e19f72a018e1d0e6f258a8 Mon Sep 17 00:00:00 2001 From: Konrad Jamrozik Date: Thu, 23 Feb 2023 16:46:11 -0800 Subject: [PATCH 3/3] update --- eng/common/scripts/get-codeowners.ps1 | 2 +- eng/pipelines/templates/variables/globals.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/get-codeowners.ps1 b/eng/common/scripts/get-codeowners.ps1 index 98e73ded533..a4a18ecea42 100644 --- a/eng/common/scripts/get-codeowners.ps1 +++ b/eng/common/scripts/get-codeowners.ps1 @@ -62,7 +62,7 @@ param ( # but not this one: # Remove the obsolete, prefix-based CODEOWNERS matcher & related tests # https://github.com/Azure/azure-sdk-tools/pull/5431 - [string]$ToolVersion = "1.0.0-dev.20230214.3", # // kja TODO update + [string]$ToolVersion = "1.0.0-dev.20230223.4", [string]$ToolPath = (Join-Path ([System.IO.Path]::GetTempPath()) "codeowners-tool-path"), [string]$DevOpsFeed = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json", [string]$VsoVariable = "", diff --git a/eng/pipelines/templates/variables/globals.yml b/eng/pipelines/templates/variables/globals.yml index f2c015a1505..808bbdb3278 100644 --- a/eng/pipelines/templates/variables/globals.yml +++ b/eng/pipelines/templates/variables/globals.yml @@ -1,5 +1,5 @@ variables: OfficialBuildId: $(Build.BuildNumber) skipComponentGovernanceDetection: true - NotificationsCreatorVersion: '1.0.0-dev.20230216.1' # kja TODO update + NotificationsCreatorVersion: '1.0.0-dev.20230223.2' PipelineOwnersExtractorVersion: '1.0.0-dev.20230211.1'