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

feat: add risk label group #311

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/plugins/label/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const (

var (
defaultLabels = []string{"kind", "priority", "area"}
needsLabels = []string{"kind", "priority", "sig", "triage"} // "needs-*"
needsLabels = []string{"kind", "priority", "sig", "triage", "risk"} // "needs-*"
commentRegex = regexp.MustCompile(`(?s)<!--(.*?)-->`)
labelRegex = regexp.MustCompile(`(?m)^/(area|committee|kind|language|priority|sig|triage|wg)\s*(.*?)\s*$`)
removeLabelRegex = regexp.MustCompile(`(?m)^/remove-(area|committee|kind|language|priority|sig|triage|wg)\s*(.*?)\s*$`)
labelRegex = regexp.MustCompile(`(?m)^/(area|committee|kind|language|priority|risk|sig|triage|wg)\s*(.*?)\s*$`)
removeLabelRegex = regexp.MustCompile(`(?m)^/remove-(area|committee|kind|language|priority|risk|sig|triage|wg)\s*(.*?)\s*$`)
customLabelRegex = regexp.MustCompile(`(?m)^/label\s*(.*?)\s*$`)
customRemoveLabelRegex = regexp.MustCompile(`(?m)^/remove-label\s*(.*?)\s*$`)
)
Expand Down Expand Up @@ -79,14 +79,14 @@ func helpProvider(config *plugins.Configuration, _ []config.OrgRepo) (*pluginhel
logrus.WithError(err).Warnf("cannot generate comments for %s plugin", PluginName)
}
pluginHelp := &pluginhelp.PluginHelp{
Description: "The label plugin provides commands that add or remove certain types of labels. Labels of the following types can be manipulated: 'area/*', 'committee/*', 'kind/*', 'language/*', 'priority/*', 'sig/*', 'triage/*', and 'wg/*'. More labels can be configured to be used via the /label command. Restricted labels are only able to be added by the teams and users present in their configuration, and those users can be automatically assigned when another label is added using the assign_on config.",
Description: "The label plugin provides commands that add or remove certain types of labels. Labels of the following types can be manipulated: 'area/*', 'committee/*', 'kind/*', 'language/*', 'priority/*', 'risk/*', 'sig/*', 'triage/*', and 'wg/*'. More labels can be configured to be used via the /label command. Restricted labels are only able to be added by the teams and users present in their configuration, and those users can be automatically assigned when another label is added using the assign_on config.",
Config: map[string]string{
"": configString(labels),
},
Snippet: yamlSnippet,
}
pluginHelp.AddCommand(pluginhelp.Command{
Usage: "/[remove-](area|committee|kind|language|priority|sig|triage|wg|label) <target>",
Usage: "/[remove-](area|committee|kind|language|priority|risk|sig|triage|wg|label) <target>",
Description: "Applies or removes a label from one of the recognized types of labels.",
Featured: false,
WhoCanUse: "Anyone can trigger this command on issues and PRs. `triage/accepted` can only be added by org members. Restricted labels are only able to be added by teams and users in their configuration.",
Expand Down
20 changes: 20 additions & 0 deletions pkg/plugins/label/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,26 @@ func TestHandleComment(t *testing.T) {
commenter: orgMember,
action: github.GenericCommentActionCreated,
},
{
name: "Remove Risk Label",
body: "/remove-risk high",
repoLabels: []string{"area/infra", "risk/high", "needs-risk"},
issueLabels: []string{"area/infra", "risk/high"},
expectedNewLabels: formatWithPRInfo("needs-risk"),
expectedRemovedLabels: formatWithPRInfo("risk/high"),
commenter: orgMember,
action: github.GenericCommentActionCreated,
},
{
name: "Add Risk Label",
body: "/risk medium",
repoLabels: []string{"area/infra", "area/api", "risk/medium", "needs-risk"},
issueLabels: []string{"area/api", "needs-risk"},
expectedNewLabels: formatWithPRInfo("risk/medium"),
expectedRemovedLabels: []string{},
commenter: orgMember,
action: github.GenericCommentActionCreated,
},
{
name: "Remove SIG Label",
body: "/remove-sig testing",
Expand Down