Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the new, regex-based, wildcard-supporting CODEOWNERS matcher #5088

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

konrad-jamrozik
Copy link
Contributor

@konrad-jamrozik konrad-jamrozik commented Jan 9, 2023

This PR enables the parser introduced in:

And as such, this PR contributes to:

Before a package published out of this PR is depended upon, a review of affected CODEOWNERS files is necessary, as explained in Behavior change of existing CODEOWNERS paths with wildcards section of this comment:

Full behavior difference between the old and new parser can be determined by comparing the two rightmost columns of this test battery.

This parser will be executed by the automation - build-failure-notification-subscriptions pipeline, once the package it depends on is published and updated, similar as it is done in this PR:

As a result, the following CODEOWNERS files are expected to be affected, and thus require a review:

Following files won't be affected, as they are not triggered by the pipeline, whose source is notifications.yml:

In addition, following work needs to be implemented and applied to the CODEOWNERS files before we can enable support for wildcards:

Related work

@konrad-jamrozik konrad-jamrozik requested a review from a team as a code owner January 9, 2023 06:06
@konrad-jamrozik konrad-jamrozik self-assigned this Jan 9, 2023
@konrad-jamrozik konrad-jamrozik added Central-EngSys This issue is owned by the Engineering System team. EngSys This issue is impacting the engineering system. labels Jan 9, 2023
@konrad-jamrozik
Copy link
Contributor Author

konrad-jamrozik commented Jan 9, 2023

@weshaggard as I mentioned in this PR description - a review of the listed CODEOWNERS files is necessary, to see how support of wildcards changes the owners. Could you provide me with guidance what algorithm I should apply here?

Should I reach out first to all the folks who will now start getting ADO notifications for build failures because of wildcards now matching, and ask them if they want to opt out before I deploy this change?

Or maybe I should comment out all wildcard-supporting paths and ask the assigned owners to let me know if I should uncomment them?

Due to wildcards now matching possibly some set of people will stop getting notifications, but I think figuring this set out would be a lot of work, so I am not sure if I should try to do it. I would have to check if each wildcard path would match against any path listed above it, and if so, if there is at least one file matching both these paths, and if so, if the owners are different, and if so, if the owner change is in fact a problem.

Thanks!

@weshaggard
Copy link
Member

weshaggard commented Jan 10, 2023

My biggest concern is the **/ci.yml and **/test.yml patterns that are setup at the bottom of the files which point to engsys folks. That is going to cause all pipeline notifications to come to those folks instead of the service teams which is not what we want to happen. I suggest we simply remove those patterns from the Codeowners files.

I would suggest doing a test where you look at the owners of all the *.yml files in the repo before and after your changes and compare the results to see what changed.

Might consider that for any other patterns you see in the codeowners where ** patterns exist.

Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want this merged until we verify the yml file mappings as I believe this will break all our notification mappings.

@konrad-jamrozik
Copy link
Contributor Author

My biggest concern is the **/ci.yml and **/test.yml patterns that are setup at the bottom of the files which point to engsys folks. That is going to cause all pipeline notifications to come to those folks instead of the service teams which is not what we want to happen. I suggest we simply remove those patterns from the Codeowners files.

I would suggest doing a test where you look at the owners of all the *.yml files in the repo before and after your changes and compare the results to see what changed.

Might consider that for any other patterns you see in the codeowners where ** patterns exist.

@weshaggard OK, cool. I am going to make all the tests as you proposed.

My plan is to augment the retrieve-codeowners tool (which is wrapped by get-codeowners.ps1 script) to allow it to not only target specific directory to check its ownership, but to be able to target a path with wildcards, find all concrete paths matching that path-with-wildcards, and return ownership information for all of them.

I will then run this tool with the old and new parser and report here the ownership diff here.

ghost pushed a commit that referenced this pull request Jan 14, 2023
…r all paths matching given glob path. (#5134)

This PR implements for the `retrieve-codeowners` tool the ability to return not only owners for a single path, but a list of all owners for all paths resolved when matching a glob path given as input.

As such, this PR contributes to:
- #5135

This work is necessary to be able to compare and diff the owners of all files in repository before and after the regex matcher is turned on, per this comment:
- #5088 (review)

In other words, this PR contributes to unblocking to the following PR:
- #5088

And as such, also contributes to:
- #2770

This PR will require some upstream changes, which are captured by:
- #5103

### Additional changes

- Removed logger from `CodeOwnersParser`; replaced with `Console.Out` and `Console.Error`. This addresses the following comment:
    - #5063 (comment)
- Prevented the new regex matcher from matching paths that have `*` in them - such paths are malformed anyway (at least on Windows).
- A lot of assorted changes to surrounding production & test code - please see the file diff for details.

### Implementation notes

This PR leverages [`Microsoft.Extensions.FileSystemGlobbing`](https://www.nuget.org/packages/Microsoft.Extensions.FileSystemGlobbing).
Doc: https://learn.microsoft.com/en-us/dotnet/core/extensions/file-globbing
@konrad-jamrozik
Copy link
Contributor Author

konrad-jamrozik commented Jan 17, 2023

I have confirmed that commenting out the following lines in CODEOWNERS for azure-sdk-for-net:

#/**/*Management*/                               @fengzhou-msft @archerzz @ArcturusZhang @Yao725 @ArthurMa1978
#/**/Azure.ResourceManager*/                     @fengzhou-msft @archerzz @ArcturusZhang @Yao725 @ArthurMa1978

#/**/tests.yml   @hallipr @benbp
#/**/ci.yml      @hallipr @benbp

results in exactly the same owners being matched using the new regex matcher as the obsolete prefix-based matcher.

I'll add more details here and link to the tool I used a bit later.

@weshaggard
Copy link
Member

weshaggard commented Jan 17, 2023

I think it is fine to remove the **/*.yml entries for engsys but we should talk with the mgmt folks about those before we remove them. We could also consider moving some of these wildcard entries to the top of the file so they will still catch anything missed but allow the more specific paths to override.

@konrad-jamrozik
Copy link
Contributor Author

konrad-jamrozik commented Jan 19, 2023

I think it is fine to remove the **/*.yml entries for engsys but we should talk with the mgmt folks about those before we remove them. We could also consider moving some of these wildcard entries to the top of the file so they will still catch anything missed but allow the more specific paths to override.

@weshaggard the diff is actually more complex, as I discovered when working on:

Sorry about the confusion.

I think dealing with paths having wildcards in them is a bit tricky: if I move the rules around, it will change the owners as interpreted by GitHub itself. For the same reason I also cannot just comment-out all wildcard paths to allow graceful, gradual migration to the regex-based matcher.

Not sure yet what is the best way to approach this. I could ask the affected folks to review the owners diff I get from #5165 and ask all of them if they are OK with getting the build failure notifications now.

In the meantime I made this PR:

Here is the full diff on the azure-sdk-for-net CODEOWNERS. LEFT is current prefix-based matcher, while RIGHT is the new regex-based matcher AND including the PR 33584 changes applied. Meaning that once the new matcher is enabled, ADO build failures will be routed to RIGHT OWNERS instead of LEFT OWNERS. However, PR reviewers are already being assigned to RIGHT OWNERS, because GitHub supports wildcards.

@weshaggard
Copy link
Member

Not sure yet what is the best way to approach this. I could ask the affected folks to review the owners diff I get from #5165 and ask all of them if they are OK with getting the build failure notifications now.

Looks like that diff still has the **/ci.yml and **/tests.yml paths in the codeowners file going to EngSys I know that is definitely going to be wrong so I would like to see a diff with those patterns removed.

As for the mgmt codeowners entries I think it is probably safe to keep those and let the folks still be labeled as the owners for all the mgmt libraries.

@weshaggard
Copy link
Member

With our new approach we might also want to consider removing the /sdk/ pattern which was all about having the leads be the owners so they can push to get any missing owners figured out but once we get our pipeline setup we can have the pipeline identify new code paths that don't have owners.

@konrad-jamrozik
Copy link
Contributor Author

konrad-jamrozik commented Jan 19, 2023

Looks like that diff still has the **/ci.yml and **/tests.yml paths in the codeowners file going to EngSys I know that is definitely going to be wrong so I would like to see a diff with those patterns removed.

@weshaggard I added the diff you requested to the Excel diff, in the tab named azure-sdk-for-net_owners_diff_2 (note the _2 at the end).

With our new approach we might also want to consider removing the /sdk/ pattern

You mean only the the line with exactly /sdk/, yes? But not paths like /sdk/objectanchors/?

Here is my thinking:

  • If that diff looks OK to you, I will remove the **/ci.yml and **/tests.yml paths from the azure-sdk-for-net. Done in this PR: Remove CODEOWNERS rules /**/ci.yml and /**/tests.yml azure-sdk-for-net#33595
  • then I'll enable the new regex-based matcher for azure-sdk-for-net repo only, keeping the old matcher for other repos (I will hardcode some rules to make the matcher distinguish on which repo it runs and decide which matching logic to use).
  • After some cooking time, I will then repeat this process for each of our other language repos.

Re the removal of /sdk/ I see following paths matching to it in the diff:

image

So, in a separate PR, I could remove /sdk/ and add a bunch of rules like /sdk/maps/, /sdk/quantum/ etc., with the same owners assigned. Then let the two owners, pallavit and jsquire know, to determine exact owners for these paths. I made a PR for this:

Thoughts?

konrad-jamrozik pushed a commit to Azure/azure-sdk-for-go that referenced this pull request Feb 10, 2023
As part of ongoing work of enabling wildcard support for `CODEOWNERS`:
- Azure/azure-sdk-tools#2770
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240

Related PRs:
- Similar PR fixing invalid paths, but for `net` repo: Azure/azure-sdk-for-net#33584
- Similar PR deprioritizing the Azure SDK EngSys team ownership, but for `python` repo: Azure/azure-sdk-for-python#28534
konrad-jamrozik added a commit to Azure/azure-sdk-for-c that referenced this pull request Feb 10, 2023
As part of ongoing work of enabling wildcard support for `CODEOWNERS`:
- Azure/azure-sdk-tools#2770
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240
konrad-jamrozik pushed a commit to Azure/azure-sdk-for-cpp that referenced this pull request Feb 10, 2023
As part of ongoing work of enabling wildcard support for `CODEOWNERS`:
- Azure/azure-sdk-tools#2770
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240
konrad-jamrozik pushed a commit to Azure/azure-sdk-for-ios that referenced this pull request Feb 10, 2023
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240
konrad-jamrozik pushed a commit to Azure/azure-sdk-for-android that referenced this pull request Feb 10, 2023
As part of ongoing work of enabling wildcard support for `CODEOWNERS`:
- Azure/azure-sdk-tools#2770
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240
konrad-jamrozik pushed a commit to Azure/azure-dev that referenced this pull request Feb 10, 2023
As part of ongoing work of enabling wildcard support for `CODEOWNERS`:
- Azure/azure-sdk-tools#2770
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240
ellismg pushed a commit to Azure/azure-dev that referenced this pull request Feb 10, 2023
As part of ongoing work of enabling wildcard support for `CODEOWNERS`:
- Azure/azure-sdk-tools#2770
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240
@konrad-jamrozik
Copy link
Contributor Author

konrad-jamrozik commented Feb 13, 2023

@weshaggard I have updated all the CODEOWNERS files in scope of the new matcher. You can see what I did by reviewing the PRs I linked to this issue. There are still few PRs open, as can be seen above and below. But as soon as I get your approval on them, I will merge them, and then we can proceed with merging this PR.

I do have few outstanding questions about ownership, but I don't think they should be blocking. Here is the full list of unanswered questions:

konrad-jamrozik added a commit to Azure/azure-sdk-for-c that referenced this pull request Feb 13, 2023
As part of ongoing work of enabling wildcard support for `CODEOWNERS`:
- Azure/azure-sdk-tools#2770
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240
konrad-jamrozik pushed a commit to Azure/azure-sdk-for-ios that referenced this pull request Feb 13, 2023
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240
konrad-jamrozik pushed a commit to Azure/azure-sdk-for-js that referenced this pull request Feb 13, 2023
konrad-jamrozik pushed a commit to Azure/azure-sdk-for-android that referenced this pull request Feb 13, 2023
As part of ongoing work of enabling wildcard support for `CODEOWNERS`:
- Azure/azure-sdk-tools#2770
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240
konrad-jamrozik pushed a commit to Azure/azure-sdk-for-go that referenced this pull request Feb 13, 2023
* Update `CODEOWNERS` paths: fix invalid paths

As part of ongoing work of enabling wildcard support for `CODEOWNERS`:
- Azure/azure-sdk-tools#2770
- Azure/azure-sdk-tools#5088

and enabling stricter validation:
- Azure/azure-sdk-tools#4859

this PR:
- fixes invalid paths, to match rules explained [here](https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners);
- removes `/**/tests.yml` and `/**/ci.yml`, to avoid all build failure notifications being routed to it once we enable the new regex-based, wildcard-supporting `CODEOWNERS` matcher, per: Azure/azure-sdk-tools#5088 (comment)

Once this PR is merged, I will enable the new `CODEOWNERS` matcher, similar to how it was done for `net` repo by these two PRs:
- Azure/azure-sdk-tools#5241
- Azure/azure-sdk-tools#5240

Related PRs:
- Similar PR fixing invalid paths, but for `net` repo: Azure/azure-sdk-for-net#33584
- Similar PR deprioritizing the Azure SDK EngSys team ownership, but for `python` repo: Azure/azure-sdk-for-python#28534

* Update .github/CODEOWNERS

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

---------

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
@konrad-jamrozik konrad-jamrozik merged commit 5ba9d1d into main Feb 13, 2023
@konrad-jamrozik konrad-jamrozik deleted the users/kojamroz/enable_new_co_parser branch February 13, 2023 21:44
ghost pushed a commit that referenced this pull request Feb 16, 2023
…ers` executable + add some tests; make assorted refactorings (#5103)

This PR is part of work required in preparation to merge:
- #5088

Specifically, to enable review of ownership changes due to upcoming wildcards support, as explained in:
- #5088 (comment)

As such, this PR contributes to:
- #2770

This PR is a prerequisite for following PRs:
- #5431

### Merging prerequisite

This PR can be merged only after the following PRs are merged and relevant NuGet package published
- #5437
- #5104

This is because this PR depends on that NuGet package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Central-EngSys This issue is owned by the Engineering System team. EngSys This issue is impacting the engineering system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants