-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CodeownersUtils, a CodeownersParser replacement (#7097)
* 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
1 parent
3f21000
commit 6272524
Showing
74 changed files
with
5,469 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...utils/Azure.Sdk.Tools.CodeownersLinter.Tests/Azure.Sdk.Tools.CodeownersUtils.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
31 changes: 31 additions & 0 deletions
31
...owners-utils/Azure.Sdk.Tools.CodeownersLinter.Tests/CodeownersTestFiles/Baseline/NoErrors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Empty file.
65 changes: 65 additions & 0 deletions
65
...utils/Azure.Sdk.Tools.CodeownersLinter.Tests/CodeownersTestFiles/Baseline/WithBlockErrors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
5 changes: 5 additions & 0 deletions
5
...ools.CodeownersLinter.Tests/CodeownersTestFiles/Baseline/WithBlockErrors_FullBaseline.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
34 changes: 34 additions & 0 deletions
34
...owners-utils/Azure.Sdk.Tools.CodeownersLinter.Tests/CodeownersTestFiles/EndToEnd/NoErrors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
130 changes: 130 additions & 0 deletions
130
...dk.Tools.CodeownersLinter.Tests/CodeownersTestFiles/EndToEnd/NoErrorsExpectedEntries.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] |
58 changes: 58 additions & 0 deletions
58
...utils/Azure.Sdk.Tools.CodeownersLinter.Tests/CodeownersTestFiles/EndToEnd/WithBlockErrors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.