Open itsyoboieltr opened 5 months ago
Writing up the results of my investigation:
Team labeling should only happen once, when a pull request is opened. When this happens, the GitHub handle of the author of the pull request can be extracted using the github.event.pull_request.user.login
property. Using the GitHub handle, dynamically fetching the GitHub teams a person belongs to in the MetaMask organization is possible using the GitHub GraphQL API.
query($organization: String!, $user: String!) {
organization(login: $organization) {
teams(first: 100, userLogins: [$user]) {
edges {
node {
name
description
slug
}
}
}
}
}
This returns data in JSON like:
{
"data": {
"organization": {
"teams": {
"edges": [
{
"node": {
"name": "Extension Platform",
"description": "...",
"slug": "extension-platform"
}
}
]
}
}
}
}
A list of teams with some properties extracted. There are many more properties available, but based on https://docs.github.com/en/graphql/reference/objects#team, I thought these would be the relevant ones.
Now that we have a list of teams for the user that submitted the pull request, we need to select a team and pair it to the team's label. This proved to be unexpectedly complex:
I am posting this to start a discussion. Looking forward to hearing your ideas! Maybe I missed something, or there is a better way.
Thanks for this investigation @itsyoboieltr ! Indeed these are very valid concerns.
I'm not saying we can't overcome these obstacles, but it's going to take time/energy, and we'll have to make sure it is maintained over the months/years. FYI, we already started asking for more consistency in this Slack thread, but haven't been fully sucessful.
@gauthierpetetin I put the status to blocked in the meanwhile then :)
What is this about?
PR #25208 added the
add-team-label
GitHub workflow that automatically adds the author's team to the labels when a new PR is opened. The label corresponding to the author is extracted from teams.json found in the MetaMask-planning repository.This issue was opened to capture the desired outcome of the automatic team labeling, as @seaona raised a question about the maintenance of the aforementioned teams.json file in https://github.com/MetaMask/metamask-extension/pull/25208#pullrequestreview-2115428545:
Ideally, instead of having a teams.json file which requires manual maintenance, it would be great to dynamically fetch the available GitHub teams and match the author to one of the teams to find the correct label. This way we would have a fully automated process for GitHub team labeling.
Scenario
No response
Design
No response
Technical Details
No response
Threat Modeling Framework
No response
Acceptance Criteria
No response
Stakeholder review needed before the work gets merged
References
No response