-
Notifications
You must be signed in to change notification settings - Fork 183
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
Implement CODEOWNERS file changes validation (gating), with baselining #4859
Comments
Brain dump of potential rules to validate
|
Note: As of 5/22/2023 this spec has been implemented few months ago. In case of inconsistencies the implementation takes precedence. Please see the (massive) battery of unit tests included. Note: this spec has been updated as of 1/23/2023 3:00 PM PST. Per my chat with @weshaggard today, we want to add following restrictions on CODEOWNERS file which we will validate against: CODEOWNERS paths must be relative to repository root
CODEOWNERS paths must avoid ambiguous use of wildcardsThis section was added on 1/23/2023. We forbid usage of
In addition, usage of suffix CODEOWNERS paths must not have some characters that have regex interpretationThe characters CODEOWNERS paths must point to files and directories that exist
All files and directories must be covered by CODEOWNERS paths
Drift management
Casing
Consequences for the parser logic implementationAs of 1/23/2023 this section has been updated. Previously, we assumed that if CODEOWNERS paths are matched against target path As a consequence of the rules above, we can simplify our CODEOWNERS parser logic by making additional assumption:
This assumption works because:
In addition, we can assume in the parser that all CODEOWNERS paths are absolute to the repository root. Required review of existing CODEOWNERS filesTo ensure our existing language repositories CODEOWNER files match the rules outlined above, we must do the following:
|
I think that is a good goal but I don't know how feasible it will be. Otherwise I believe what you wrote sounds correct based on our conversations. |
Idea from @jsquire: Have a weekly report with paths without owners or invalid owners. It would help understand where are the gaps while avoiding noise by avoiding "catch-all" ownership assignment. |
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
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
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
- 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
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
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
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
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
- 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
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
* 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 <[email protected]> --------- Co-authored-by: Ben Broderick Phillips <[email protected]>
The parsing and linting have been completely rewritten as part of the work being done for the new syntax. The updates include baselining. The PR is currently in review. Once that goes in the YML for the linter pipeline needs to be written. |
Background
Our Azure SDK repositories leverage
CODEOWNERS
files (e.g. azure-sdk-for-python, azure-sdk-for-net) in two ways.First, to determine pull request reviewers, via GitHub interpreter of code owners file, as documented on GitHub docs "About code owners".
Second, to apply various additional augmentations, like automatically label PRs, notify about new issues being filed, or notify about relevant build failures. This is done by our own custom logic, as documented in azure-sdk/docs/pipelines/opensource.md.
Problem statement
The problem on the functionality relying on code owners contents, is that we do not have code owners file contents validation, thus resulting in ill-defined files, resulting in problems like notifications silently failing to be sent.
The GitHub-based logic, responsible for adding reviewers to PRs, has a GitHub-provided validator that results in a warnings banner if the file validation fails, e.g.:
The main issue here is these are just warnings, while we would like to prevent merging any changes to code owners file unless they pass validation (i.e. to gate the changes). For example, we would like to prevent folks from adding groups to the file, if they don't have necessary write permissions, as pointed out by this comment. We might also want to restrict the teams to a pre-vetted list, as seen here (Microsoft-internal).
More importantly, our own logic does not have any validation in place, hence if the code owners file is invalid, our augmentations will just silently be ignored, with no easy way to debug the issue.
Proposed solution
To address the code owners file contents issues described above, we propose to introduce a new pipeline and PR check that will validate our
azure-sdk-*
reposCODEOWNERS
files and report any issues, both for the features provided by GitHub-based interpreter, and our logic providing all the custom augmentations.The pipeline output would result in a set of well-defined problems, that can be manually uploaded beside the
CODEOWNERS
file as a text file used for baselining. Once baseline is available, the PR check will prevent any further changes to the code owners file unless they pass all validations.Once such validations are in place, we could start addressing the various issues and limitations we have, as already reported by GitHub validator (see links above), or reported by our users, e.g. #4487.
An example validation rule we could implement: flag all aliases mentioned in CODEOWNERS file for folks who are no longer Microsoft employees. Once we discover them, we probably could delete them right now as part of a cleanup effort, even before we establish the baselines.
Implementation considerations
We could handle a team assigned to given path in a code owners file by expanding it to its members in referentially transparent way. This is nontrivial because we have bunch of custom tooling ingesting as input the output of our own customer
CODEOWNERS
parser, likeFabricBot
(seeReference
section below for details). Bottom line, any additions or changes to our code owners parser require careful analysis, to ensure all our downstream tooling can properly interpret the changes/additions to supported format.One possible way to figure out how to expand GitHub teams into Microsoft aliases is through usage of CloudMine Kusto clusters. Patrick Hallisey is possible point of contact to help with this.
Related work
Linter by @heaths:
https://github.com/heaths/gh-codeowners
If you have access, see also email thread
RE: Proposed API Stewardship Board process changes for PRs
from 2023/04.Reference
This doc (Microsoft-internal) (see also #4837) explains how build failure notifications via Azure DevOps notification system are implemented. The main executable source is configuration-creator, run via notficiations.yml.
Our other augmentations are provided by our other solutions, like
FabricBot
providing the PR labeling augmentation. This is explained in detail in #2770 (comment).The text was updated successfully, but these errors were encountered: