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

Add glob-based support for wildcards in CODEOWNERS file parser (disabled, behind a feature flag) #5030

Merged
merged 2 commits into from
Jan 7, 2023

Conversation

konrad-jamrozik
Copy link
Contributor

@konrad-jamrozik konrad-jamrozik commented Dec 29, 2022

This is a first PR to address:

Changes made

Changes in CodeOwnersFile.cs:

  • In this PR I add a new implementation for matching entries in our CODEOWNERS file. This implementation is disabled, hidden behind a method feature flag parameter.
  • The method targeted by this PR is CodeOwnersFile.FindOwnersForClosestMatch. It now either calls its previous, unchanged, legacy implementation, now located in CodeOwnersFile.FindOwnersForClosestMatchLegacyImpl, or the newly introduced implementation. The decision is made here and is based on newly introduced method feature flag parameter, useNewFindOwnersForClosestMatchImpl.
    • The useNewFindOwnersForClosestMatchImpl is by default false, meaning the code uses the legacy implementation. It is only ever set to true in the added tests.
  • If useNewFindOwnersForClosestMatchImpl is true, then new implementation is used. That implementation's entry point is the newly-introduced MatchedCodeOwnerEntry ctor.

Newly added MatchedCodeOwnerEntry.cs class:

  • This class contains the logic for the new matching logic, as explained above.
  • This class leverages Microsoft.Extensions.FileSystemGlobbing (namespace) to reuse support for glob matching of * and ** during path matching. See the class implementation and comments for details.

Newly added Azure.Sdk.Tools.CodeOwnersParser.Tests/CodeOwnersFileTests.cs:

  • This is a new project and a test class for testing the implementations of FindOwnersForClosestMatch directly.
  • It includes a battery of over 50 test cases that achieve 100% code coverage both on the legacy and new parsing logic.
  • The test battery also compares the behavior of the legacy and new matching logic, to be discussed w.r.t. backward compatibility issues and pre-existing bugs in the legacy logic.

Changes to Azure.Sdk.Tools.RetrieveCodeOwners.Tests.csproj:

  • I updated and added some missing dependencies, based on the dependencies created when creating a new NUnit project in visual studio.
    • This includes linter for NUnit, which resulted in some warnings around assertions, which broke PR build. I fixed them.
    • I also enabled strict nullability checking.

Testing done

Next steps

Reference

@konrad-jamrozik konrad-jamrozik self-assigned this Dec 29, 2022
@konrad-jamrozik konrad-jamrozik added the Central-EngSys This issue is owned by the Engineering System team. label Dec 29, 2022
@konrad-jamrozik konrad-jamrozik force-pushed the users/kojamroz/iss_2770_tests branch 5 times, most recently from 6ed0cee to 11e3586 Compare December 30, 2022 01:46
@konrad-jamrozik konrad-jamrozik marked this pull request as ready for review December 30, 2022 16:39
@konrad-jamrozik konrad-jamrozik requested a review from a team as a code owner December 30, 2022 16:39
@konrad-jamrozik konrad-jamrozik changed the title Add support for wildcards in CODEOWNERS file parser Add support for wildcards in CODEOWNERS file parser (disabled, behind a feature flag) Dec 30, 2022
@konrad-jamrozik
Copy link
Contributor Author

konrad-jamrozik commented Jan 4, 2023

@weshaggard while the new parser implementation in this PR requires a rewrite, I would like to merge this PR to keep it as a reference, e.g. for the bug I reported here:

Is it OK if we merge this? Note the new implementation is not used. I will make a follow-up PR that changes the implementation as we discussed in:

UPDATE 1/5/2023 8:12 AM PST: here is the new regex-based parser. The PR for it is based on this PR:

@konrad-jamrozik konrad-jamrozik changed the title Add support for wildcards in CODEOWNERS file parser (disabled, behind a feature flag) Add glob-based support for wildcards in CODEOWNERS file parser (disabled, behind a feature flag) Jan 5, 2023
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.

Given the new implementation is currently disabled and you want it for the glob reference I'm good with you merging this and then pulling in your change to switch to regex.

@konrad-jamrozik konrad-jamrozik merged commit 5101537 into main Jan 7, 2023
@konrad-jamrozik konrad-jamrozik deleted the users/kojamroz/iss_2770_tests branch January 7, 2023 05:01
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants