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 linting for CODEOWNERS #3554

Closed
dhruvkb opened this issue Dec 19, 2023 · 4 comments
Closed

Add linting for CODEOWNERS #3554

dhruvkb opened this issue Dec 19, 2023 · 4 comments
Assignees
Labels
🤖 aspect: dx Concerns developers' experience with the codebase ✨ goal: improvement Improvement to an existing user-facing feature good first issue New-contributor friendly help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: mgmt Related to repo management and automations

Comments

@dhruvkb
Copy link
Member

dhruvkb commented Dec 19, 2023

Goal

The CODEOWNERS file frequently goes out of sync with the codebase.

We need to ensure two things:

  • Every file/folder in the repo has a CODEOWNERS entry.
  • Every entry in CODEOWNERS must be a real, existing file/folder.
@dhruvkb dhruvkb added good first issue New-contributor friendly help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 🤖 aspect: dx Concerns developers' experience with the codebase 🧱 stack: mgmt Related to repo management and automations labels Dec 19, 2023
@openverse-bot openverse-bot moved this to 📋 Backlog in Openverse Backlog Dec 19, 2023
@gmottajr
Copy link
Contributor

Hello Dhruv (@dhruvkb),

I Just came across your issue report and at first quickly read an idea lighted up in my mind.
This is about tackling your CODEOWNERS file synchronization request programmatically by creating a Python function. Here's a high-level overview of the Python function approach:

Step 1: List All Files/Folders in the Repository:
    We'll start by getting a list of all the files and folders in our repo.

Step 2: Parse the CODEOWNERS File:
    Next, we'll look at the CODEOWNERS file to see what's currently listed there.

Step 3: Compare Entries:
    We'll then compare these two lists to find out if there are any mismatches.

Step 4: Generate a Synchronization Report:
    If we find any discrepancies, we'll create a report to list what's missing and what shouldn't be there.

Step 5: Logging (optional):
    In case you think it would be a good idea, we can log this report to a file so that we can review it later for reference.

Optional 6: Update CODEOWNERS File:
    Depending on what we find, we can decide whether or not to automatically update the CODEOWNERS file.

Benefits:
Automation: The Python function automates the process, reducing the need for manual checks and updates, which can be time-consuming, especially in large repositories

Proactive Issue Identification: By running the synchronization function before any potential problems arise, we proactively identify discrepancies or misconfigurations between the CODEOWNERS file and the codebase. These issues might not yet have caused any problems, but they have the potential to do so in the future.

Preventing Future Errors: Identifying and addressing these discrepancies early on helps prevent future errors and complications. For example, if an important file or folder lacks an entry in CODEOWNERS, this might not immediately impact the project, but it could lead to confusion or security concerns later.

Maintaining Codebase Integrity: Keeping the CODEOWNERS file in sync ensures the integrity of the codebase's ownership and responsibility structure. This can be crucial for collaboration and code review processes.

Efficiency: This approach streamlines the synchronization process, making it more efficient and consistent across projects.

Transparency: The synchronization report provides transparency by clearly outlining what's missing or incorrectly specified in the CODEOWNERS file, making it easier to understand and address.

Documentation: It contributes to maintaining a well-documented codebase by ensuring that every file and folder has a corresponding entry in CODEOWNERS, which can be especially valuable for onboarding new team members.

Customization: The Python function can be customized to fit specific project needs and can be integrated into existing workflows, such as CI/CD pipelines.

Logging: By logging the synchronization report, we create a historical record of changes and can easily review the state of CODEOWNERS at different points in time.

So basically, this is the plan in a nutshell. If needed, how does that sound? I can dive deeper into the specifics and actually write the Python function though.
Let me know your thoughts!
Cheers,

@dhruvkb
Copy link
Member Author

dhruvkb commented Dec 20, 2023

There is a package https://github.com/mszostok/codeowners-validator that already does the checking for us. We need to integrate it into our lint hooks (managed by pre-commit in the .pre-commit-config.yaml file). pre-commit supports Docker hooks so we can use the Docker approach to add this our repo.

Would you like to add it to our Git hooks? If so I can assign the issue to you.

@gmottajr
Copy link
Contributor

Yeah, sure, I'll give it a try.
Please assign the issue to me.

@openverse-bot openverse-bot moved this from 📋 Backlog to 📅 To Do in Openverse Backlog Dec 20, 2023
@openverse-bot openverse-bot moved this from 📅 To Do to 🏗 In Progress in Openverse Backlog Dec 22, 2023
@dhruvkb
Copy link
Member Author

dhruvkb commented Feb 9, 2024

This change was completed by #3570.

@dhruvkb dhruvkb closed this as completed Feb 9, 2024
@openverse-bot openverse-bot moved this from 🏗 In Progress to ✅ Done in Openverse Backlog Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase ✨ goal: improvement Improvement to an existing user-facing feature good first issue New-contributor friendly help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: mgmt Related to repo management and automations
Projects
Archived in project
Development

No branches or pull requests

2 participants