Skip to content

Commit

Permalink
Add CodeownersUtils, a CodeownersParser replacement (#7097)
Browse files Browse the repository at this point in the history
* Add CodeownersUtils

* Add pipeline yml

* Add README and METADATA markdown files

* Use string insensitive comparison when checking the Azure org for team entries

* Remove nonexistent tools/check-enforcer path entry and add tools/codeowners-parser with owners

* Updates based upon feedback, minor changes for AzureSdkOwner being tied to ServiceLabel and updates to remove block formatting errors from filtering.

* Update readme for changes in the previous commit
  • Loading branch information
JimSuplizio authored Oct 19, 2023
1 parent 3f21000 commit 6272524
Show file tree
Hide file tree
Showing 74 changed files with 5,469 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
# Eng Sys Tools
###########
/tools/ @azure/azure-sdk-eng
/tools/check-enforcer/ @praveenkuttappan @weshaggard
/tools/code-owners-parser/ @konrad-jamrozik @JimSuplizio
/tools/codeowners-utils/ @JimSuplizio
/tools/github-issues/ @praveenkuttappan @weshaggard
/tools/github-event-processor/ @JimSuplizio @benbp
/tools/github-team-user-store/ @JimSuplizio @weshaggard
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Azure.Sdk.Tools.CodeownersUtils\Azure.Sdk.Tools.CodeownersUtils.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="CodeownersTestFiles/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<None Update="CodeownersTestFiles\VerifyBlock\ServiceLabelTooManyOwnersAndMonikers">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# CODEOWNERS with no errors, for end to end tesing.

# A single source path/owner line
/sdk/someFakePath1 @TestOwner0

# PPLabel block ending in a source path/owner line
# PRLabel: TestLabel1
/sdk/someFakePath2 @TestOwner2

# ServiceLabel block ending in a source path/owner line
# ServiceLabel: %TestLabel1
/sdk/someFakePath3 @TestOwner4 @TestOwner2

# ServiceLabel block with MissingFolder moniker for owners
# ServiceLabel: %TestLabel2
#/<NotInRepo>/ @TestOwner0 @TestOwner4

# ServiceLabel block with ServiceOwners moniker, no % before label
# ServiceLabel: TestLabel3
# ServiceOwners: @TestOwner0 @TestOwner2

# AzureSdkOwners must be part of a block with a ServiceLabel entry
# AzureSdkOwners: @TestOwner0
# ServiceLabel: %TestLabel3
/sdk/someFakePath4 @TestOwner2 @TestOwner4

# Every moniker that can be grouped together and end in a source path/owner line
# AzureSdkOwners: @TestOwner0
# PRLabel: %TestLabel2
# ServiceLabel: %TestLabel4
/sdk/someFakePath5 @TestOwner2 @TestOwner4
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# CODEOWNERS with errors, for end to end tesing.
# Note: For the generated owners, for testing, every odd owner isn't public

# This block has errors
# 1. TestOwner1 is non-public
# 2. TestOwner42 doesn't exist
# owner that doesn't exist
/sdk/someFakePath1 @TestOwner1 @TestOwner2 @TestOwner42

# This block does not have errors.
# PRLabel block ending in a source path/owner line
# PRLabel: %TestLabel1
/sdk/someFakePath2 @TestOwner2

# This block has errors
# 1. The label won't exist for the repository
# 2. The PRLabel moniker needs to be in a block that ends in a source path/owner line
# PRLabel: %TestLabel987

# This block has no errors
# ServiceLabel block with MissingFolder moniker for owners
# ServiceLabel: %TestLabel2
#/<NotInRepo>/ @TestOwner0 @TestOwner4

# This block has errors
# 1. TestLabel55 doesn't exist for the repository
# 2. TestOwner3 isn't a public member of Azure
# ServiceLabel block with ServiceOwners moniker
# ServiceLabel: %TestLabel55
# ServiceOwners: @TestOwner0 @TestOwner3

# This block has no errors
# AzureSdkOwners must be part of a block with a ServiceLabel entry
# AzureSdkOwners: @TestOwner0
# ServiceLabel: %TestLabel55
/sdk/someFakePath4 @TestOwner2 @TestOwner4

# This block has errors
# AzureSdkOwners must be part of a block with a ServiceLabel entry and block
# is missing the ServiceLabel entry
# AzureSdkOwners: @TestOwner0
# ServiceOwners: @TestOwner2

# This block has errors
# 1. AzureSdkOwners exists twice in the same block
# 2. TestOwner3 isn't a public member of Azure
# AzureSdkOwners: @TestOwner2
# AzureSdkOwners: @TestOwner3
/sdk/someFakePath5 @TestOwner2 @TestOwner4

# This block has errors
# 1. ServiceLabel needs to be part of a block that has ServiceOwners or ends
# in a source path/owner line but not both
# 2. The TestOwner1 isn't a public member of Azure
# AzureSdkOwners: @TestOwner0
# PRLabel: %TestLabel2
# ServiceLabel: %TestLabel4
# ServiceOwners: @TestOwner1
/sdk/someFakePath6 @TestOwner2 @TestOwner4

# This block does not have errors
# AzureSdkOwners: @TestOwner0
# PRLabel: %TestLabel2
# ServiceLabel: %TestLabel4
/sdk/someFakePath7 @TestOwner2 @TestOwner4
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TestOwner1 is not a public member of Azure.
TestOwner42 is an invalid user. Ensure the user exists, is public member of Azure and has write permissions.
'TestLabel987' is not a valid label for this repository.
'TestLabel55' is not a valid label for this repository.
TestOwner3 is not a public member of Azure.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# CODEOWNERS with no errors, for end to end tesing.

# The fallback/catch all
/** @TestOwner2

# A single source path/owner line
/sdk/someFakePath1/ @TestOwner0

# PPLabel block ending in a source path/owner line
# PRLabel: TestLabel1
/sdk/someFakePath2/ @TestOwner2

# ServiceLabel block ending in a source path/owner line
# ServiceLabel: %TestLabel1
/sdk/someFakePath3/ @TestOwner4 @TestOwner2

# ServiceLabel block with MissingFolder moniker for owners
# ServiceLabel: %TestLabel2
#/<NotInRepo>/ @TestOwner0 @TestOwner4

# ServiceLabel block with ServiceOwners moniker, no % before label
# ServiceLabel: TestLabel3
# ServiceOwners: @TestOwner0 @TestOwner2

# AzureSdkOwners must be part of a block with a ServiceLabel entry
# AzureSdkOwners: @TestOwner0
# ServiceLabel: %TestLabel3
/sdk/someFakePath4/ @TestOwner2 @TestOwner4

# Every moniker that can be grouped together and end in a source path/owner line.
# AzureSdkOwners: @TestOwner0
# PRLabel: %TestLabel2
# ServiceLabel: %TestLabel4
/sdk/someFakePath5/ @TestOwner2 @TestOwner4
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
[
{
"PathExpression": "/**",
"ContainsWildcard": true,
"SourceOwners": [
"TestOwner2"
],
"PRLabels": [],
"ServiceLabels": [],
"ServiceOwners": [],
"AzureSdkOwners": [],
"IsValid": true
},
{
"PathExpression": "/sdk/someFakePath1/",
"ContainsWildcard": false,
"SourceOwners": [
"TestOwner0"
],
"PRLabels": [],
"ServiceLabels": [],
"ServiceOwners": [],
"AzureSdkOwners": [],
"IsValid": true
},
{
"PathExpression": "/sdk/someFakePath2/",
"ContainsWildcard": false,
"SourceOwners": [
"TestOwner2"
],
"PRLabels": [
"TestLabel1"
],
"ServiceLabels": [],
"ServiceOwners": [],
"AzureSdkOwners": [],
"IsValid": true
},
{
"PathExpression": "/sdk/someFakePath3/",
"ContainsWildcard": false,
"SourceOwners": [
"TestOwner4",
"TestOwner2"
],
"PRLabels": [],
"ServiceLabels": [
"TestLabel1"
],
"ServiceOwners": [
"TestOwner4",
"TestOwner2"
],
"AzureSdkOwners": [],
"IsValid": true
},
{
"PathExpression": "",
"ContainsWildcard": false,
"SourceOwners": [],
"PRLabels": [],
"ServiceLabels": [
"TestLabel2"
],
"ServiceOwners": [
"TestOwner0",
"TestOwner4"
],
"AzureSdkOwners": [],
"IsValid": false
},
{
"PathExpression": "",
"ContainsWildcard": false,
"SourceOwners": [],
"PRLabels": [],
"ServiceLabels": [
"TestLabel3"
],
"ServiceOwners": [
"TestOwner0",
"TestOwner2"
],
"AzureSdkOwners": [],
"IsValid": false
},
{
"PathExpression": "/sdk/someFakePath4/",
"ContainsWildcard": false,
"SourceOwners": [
"TestOwner2",
"TestOwner4"
],
"PRLabels": [],
"ServiceLabels": [
"TestLabel3"
],
"ServiceOwners": [
"TestOwner2",
"TestOwner4"
],
"AzureSdkOwners": [
"TestOwner0"
],
"IsValid": true
},
{
"PathExpression": "/sdk/someFakePath5/",
"ContainsWildcard": false,
"SourceOwners": [
"TestOwner2",
"TestOwner4"
],
"PRLabels": [
"TestLabel2"
],
"ServiceLabels": [
"TestLabel4"
],
"ServiceOwners": [
"TestOwner2",
"TestOwner4"
],
"AzureSdkOwners": [
"TestOwner0"
],
"IsValid": true
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# CODEOWNERS with errors, for end to end tesing.
# Note: For the generated owners, for testing, every odd owner isn't public

# This block has line errors. Linting will find the errors but parsing should still parse the entry.
# 1. TestOwner1 is non-public
# 2. TestOwner42 doesn't exist
# owner that doesn't exist
/sdk/someFakePath1/ @TestOwner1 @TestOwner2 @TestOwner42

# This block does not have errors.
# PRLabel block ending in a source path/owner line
# PRLabel: %TestLabel1
/sdk/someFakePath2/ @TestOwner2

# This block has block and line errors
# 1. The label won't exist for the repository
# 2. The PRLabel moniker needs to be in a block that ends in a source path/owner line
# PRLabel: %TestLabel987

# This block has no errors
# ServiceLabel block with MissingFolder moniker for owners
# ServiceLabel: %TestLabel2
#/<NotInRepo>/ @TestOwner0 @TestOwner4

# This block has line errors. Linting will find the errors but parsing should still parse the entry.
# 1. TestLabel55 doesn't exist for the repository
# 2. TestOwner3 isn't a public member of Azure
# ServiceLabel block with ServiceOwners moniker
# ServiceLabel: %TestLabel55
# ServiceOwners: @TestOwner0 @TestOwner3

# This block has a block error
# AzureSdkOwners must be part of a block with a ServiceLabel
# AzureSdkOwners: @TestOwner0
/sdk/someFakePath4/ @TestOwner2 @TestOwner4

# This block has both block and line errors
# 1. AzureSdkOwners exists twice in the same block
# 2. TestOwner3 isn't a public member of Azure
# AzureSdkOwners: @TestOwner2
# AzureSdkOwners: @TestOwner3
/sdk/someFakePath5/ @TestOwner2 @TestOwner4

# This block has block and line errors
# 1. ServiceLabel needs to be part of a block that has ServiceOwners or ends
# in a source path/owner line but not both
# 2. The TestOwner1 isn't a public member of Azure
# AzureSdkOwners: @TestOwner0
# PRLabel: %TestLabel2
# ServiceLabel: %TestLabel4
# ServiceOwners: @TestOwner1
/sdk/someFakePath6/ @TestOwner2 @TestOwner4

# This block does not have errors
# AzureSdkOwners: @TestOwner0
# PRLabel: %TestLabel2
# ServiceLabel: %TestLabel4
/sdk/someFakePath7/ @TestOwner2 @TestOwner4
Loading

0 comments on commit 6272524

Please sign in to comment.