-
Notifications
You must be signed in to change notification settings - Fork 26
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
Update Github CodeTeam Plugin to enforce github.team
presence
#79
Update Github CodeTeam Plugin to enforce github.team
presence
#79
Conversation
@@ -22,13 +22,22 @@ def github | |||
sig { override.params(teams: T::Array[CodeTeams::Team]).returns(T::Array[String]) } | |||
def self.validation_errors(teams) | |||
all_github_teams = teams.flat_map { |team| self.for(team).github.team } | |||
missing_github_teams = teams.select { |team| self.for(team).github.team.nil? } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes sense, but one concern is that this is technically a breaking change since it was previously allowed to be nil
and now it is no longer allowed to be.
One alternative to simplify this is to just ignore teams that do not have this set when specifying teams used more than once. That way it wouldn't be considered an error and wouldn't show up in the confusing way you described in the PR description.
Let me know what ya think @timlkelly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great call out! Thanks for bringing that up. Is there interest in a separate team plugin to require the Github key? Then it could potentially be opt-in and a non-breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could be a separate plugin. Another possibility is if the code ownership configuration YML file could support an optional configuration flag, e.g. require_github_teams
that errors if any are nil. That way it can be opt-in without needing to fragment the plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexevanczuk good idea. I've updated it to include a new configuration key. I'm new to sorbet, so let me know if I missed anything there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
Two small things:
- could you add a quick test that checks for those validation errors
- could ya bump the minor version? I think we can consider this a non-breaking change since it only affects folks with exactly one team without a name (otherwise they'd get a duplicate name issue), and I think this is mostly a bug fix + new feature.
3bf2027
to
6406107
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good to me! @shageman could you help with merging this one 🙏🏼
Thanks @timlkelly for the PR. My team is dedicating two working sessions each week to review open PRs. We've been using a two-prong approach to tackle the newest open PRs and the oldest open PRs during each session. |
Okay! Thanks for letting me know. I've updated the |
Issue
The Github CodeTeam Plugin only enforces that more than one CodeTeam does not have a duplicate
github.team
value. The validation error message is not specific if more than one CodeTeam do not havegithub.team
keys.Given two CodeTeam YAML files with no
github.team
key, the validation errors produces the follow error message:It is not clear which CodeTeams are the offenders.
Solution
Update the Plugin to check that each CodeTeam has a
github.team
key.This still prints the original, unspecific error message, but at least there's context on the files that are missing
github.team
keys. If we want to remove thenil
Github teams from the original error message, we could#compact
on theflat_map
.Reproduction
rails new
bundle add code_teams
bundle add code_ownership
config/teams
rails console
and runCodeTeams.validation_errors(CodeTeams.all)