Skip to content

Conversation

@treyp
Copy link
Contributor

@treyp treyp commented Mar 4, 2025

📝 Description

In the approvals-satisfied script, to specify which approvals are needed, the current parameters support either specifying teams + users, or letting CODEOWNERS be the source of truth.

This generally works, but there are times when we'd like a little of both. After all, if CODEOWNERS was flexible enough, we wouldn't need this approvals-satisfied GitHub Action in the first place.

One such case is in large repos. For larger teams, assigning code ownership of a directory to a large team using CODEOWNERS is problematic because every event notifies every member of the team which is automatically requested for review. There is no way for GitHub users to customize these notifications. One workaround is to use GitHub Actions like this to handle fine-grained approvals.

Here, we add support for still reading from CODEOWNERS, but allowing specific overrides of it. For the use case above, this allows us to specify no owner for the directory in CODEOWNERS (defaulting to any user with write permissions counting towards the minimum approvals needed, preventing a review request and thus notifications), but then enforce a specific number of approvals by specific GitHub teams/users using this GitHub Action.

@treyp treyp requested a review from a team as a code owner March 4, 2025 00:05
@danadajian
Copy link
Contributor

It feels like team code review settings could solve your notification problem, no?

@treyp
Copy link
Contributor Author

treyp commented Mar 4, 2025

It feels like team code review settings could solve your notification problem, no?

Afraid not. We don't use auto-assignment, which picks specific individuals from the team and sets the PR reviewers to them as individuals instead. Instead, the team is set as the reviewer, similar to this PR:

Screenshot 2025-03-03 at 10 10 25 PM

All individuals from the team receive notifications for all such PRs. There is no way to disable them, hence the GitHub feature requests about it.

Comment on lines 41 to 43
});
// codeowners-utils sorts its CodeOwnersEntry array in reverse order of the CODEOWNERS file
codeOwnerOverrides.reverse();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
});
// codeowners-utils sorts its CodeOwnersEntry array in reverse order of the CODEOWNERS file
codeOwnerOverrides.reverse();
}).toReversed(); // codeowners-utils sorts its CodeOwnersEntry array in reverse order of the CODEOWNERS file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danadajian originally, i was going to use .toReversed(), but i was worried about Node compatibility -- looks like it didn't land until Node 20 which may exclude some consumers. happy to chain the .reverse() call if you'd prefer though.

Copy link
Contributor

Choose a reason for hiding this comment

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

This action runs on node 20, so we should be good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, Jest still seems to use Node to run (despite being launched with bun), so if the user's default Node environment is <20, the tests will fail. However, moving forward since this repo's GitHub workflows seem to work fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Node 18's end of life is next month so honestly I'm not too worried about people using Node 18 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Once the bun test runner's mocking capabilities improve I'd like to get rid of Jest anyways

Copy link
Contributor

@danadajian danadajian left a comment

Choose a reason for hiding this comment

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

Since you're adding a new input you have to add it to action.yml

@danadajian danadajian merged commit 7f88f89 into main Mar 6, 2025
6 checks passed
@danadajian danadajian deleted the codeowners-overrides branch March 6, 2025 00:24
@eg-oss-ci
Copy link

🎉 This PR is included in version 1.75.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants