Skip to content

Commit

Permalink
Add Policy Bot Behaviors (#108)
Browse files Browse the repository at this point in the history
* Add behaviors for No-Recent-Activity

* Add behaviors for when labels are added

* Add behavior for assigning MSFT resource

* Add behavior for cleaning up stale In-PR labels

* Changed my mind on Blocking-Issue

* Add comment triggers

* Lint and add standard editor configs

* Add triggers for issue open / close / update

* Add recommended extensions

* Set default encoding on powershell files

* Add triggers for DSC Resource Labels

* Final triggers

* Spelling

* Just doing what the bot says
  • Loading branch information
Trenly authored Nov 5, 2024
1 parent 1970b70 commit 7cda050
Show file tree
Hide file tree
Showing 20 changed files with 1,118 additions and 6 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# top-most EditorConfig file
root=true

# Apply Windows-style newlines with a newline ending on every file, using UTF-8, and removing extra whitespace before newlines
[*]
end_of_line = crlf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

# Overrides for Yaml Files - Use two spaces for indents
# editorconfig/editorconfig#329
[*.{yml,yaml}]
indent_style = space
indent_size = 2

# Overrides for Markdown Files - Use tab for indents (accessibility)
[*.md]
indent_style = tab

[{allow.txt,excludes.txt,patterns.txt}]
end_of_line = lf
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.editorconfig text eol=crlf
*.json text eol=crlf
*.md text eol=crlf
*.ps1 text eol=crlf
*.txt text eol=crlf
*.yml text=auto
*.yaml text=auto
.github/actions/spelling/** text eol=lf
2 changes: 1 addition & 1 deletion .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ github
https
Icm
microsoft
MSFT
msftbot
numpy
opencode
Expand All @@ -37,3 +36,4 @@ prerel
uilt
Windo
ELSPROBLEMS
requ
2 changes: 2 additions & 0 deletions .github/actions/spelling/expect/generic_terms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ VGpu
versioning
worktree
sortby
msft
automerge
3 changes: 0 additions & 3 deletions .github/actions/spelling/expect/usernames.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
denelon
Trenly
ryfu
stephengillie
34 changes: 34 additions & 0 deletions .github/policies/labelAdded.authorNotAuthorized.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
id: labelAdded.authorNotAuthorized
name: GitOps.PullRequestIssueManagement
description: Handlers when "Author-Not-Authorized" label is added
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- description: >-
When the label "Author-Not-Authorized" is added to a pull request
* Add the PR specific reply notifying the issue author
* Label with Needs-Attention
if:
- payloadType: Pull_Request
- labelAdded:
label: Author-Not-Authorized
then:
- addReply:
reply: >-
${issueAuthor},
Changes to one or more files in your PR require authorization to modify. This PR has been assigned to our on call staff to evaluate.
Template: msftbot/requiresApproval/MSFT
- addLabel:
label: Needs-Attention # This will automatically assign the ICM Users
# The policy service should trigger even when the label was added by the policy service
triggerOnOwnActions: true
onFailure:
onSuccess:
37 changes: 37 additions & 0 deletions .github/policies/labelAdded.changesRequested.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
id: labelAdded.changesRequested
name: GitOps.PullRequestIssueManagement
description: Handlers when "Changes-Requested" label is added
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- description: >-
When the label "Changes-Requested" is added to a pull request
* Add the PR specific reply notifying the issue author
* Assign to the Author
* Label with Needs-Author-Feedback
if:
- payloadType: Pull_Request
- labelAdded:
label: Changes-Requested
then:
- addReply:
reply: >-
Hello @${issueAuthor},
The package manager bot determined changes have been requested to your PR.
Template: msftbot/changesRequested
- assignTo:
author: True
- addLabel:
label: Needs-Author-Feedback
# The policy service should trigger even when the label was added by the policy service
triggerOnOwnActions: true
onFailure:
onSuccess:
31 changes: 31 additions & 0 deletions .github/policies/labelAdded.needsCLA.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
id: labelAdded.needsCLA
name: GitOps.PullRequestIssueManagement
description: Handlers when "Needs-CLA" label is added
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- description: >-
When the label "Needs-CLA" is added to a pull request
* Add the PR specific reply notifying the issue they must sign the CLA
if:
- payloadType: Pull_Request
- labelAdded:
label: Needs-CLA
then:
- addReply:
reply: >-
Hello @${issueAuthor},
This PR cannot be merged until you sign the Contributor License Agreement (CLA). More information on this process can be found on the [Microsoft Open Source](https://opensource.microsoft.com/cla/) website.
Template: msftbot/needsCLA
# The policy service should trigger even when the label was added by the policy service
triggerOnOwnActions: true
onFailure:
onSuccess:
50 changes: 50 additions & 0 deletions .github/policies/labelAdded.noRecentActivity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
id: labelAdded.noRecentActivity
name: GitOps.PullRequestIssueManagement
description: Handlers when "No-Recent-Activity" label is added
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- description: >-
When the label "No-Recent-Activity" is added to a pull request
* Add the PR specific reply notifying the issue author of pending closure
if:
- payloadType: Pull_Request
- labelAdded:
label: No-Recent-Activity
then:
- addReply:
reply: >-
Hello @${issueAuthor},
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any recent activity. It will be closed if no further activity occurs **within 3 days of this comment**.
Template: msftbot/noRecentActivity
# The policy service should trigger even when the label was added by the policy service
triggerOnOwnActions: true
- description: >-
When the label "No-Recent-Activity" is added to an issue
* Add the issue specific reply notifying the issue author of pending closure
if:
- payloadType: Issues
- labelAdded:
label: No-Recent-Activity
then:
- addReply:
reply: >-
Hello @${issueAuthor},
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any recent activity. It will be closed if no further activity occurs **within 3 days of this comment**.
Template: msftbot/noRecentActivity
# The policy service should trigger even when the label was added by the policy service
triggerOnOwnActions: true
onFailure:
onSuccess:
34 changes: 34 additions & 0 deletions .github/policies/labelAdded.projectFile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
id: labelAdded.projectFile
name: GitOps.PullRequestIssueManagement
description: Handlers when "Project-File" label is added
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- description: >-
When the label "Project-File" is added to a pull request
* Add the PR specific reply notifying the issue author
* Label with Needs-Attention
if:
- payloadType: Pull_Request
- labelAdded:
label: Project-File
then:
- addReply:
reply: >-
${issueAuthor},
Changes to one or more files in your PR require authorization to modify. This PR has been assigned to our on call staff to evaluate.
Template: msftbot/requiresApproval/MSFT
- addLabel:
label: Needs-Attention # This will automatically assign the ICM Users
# The policy service should trigger even when the label was added by the policy service
triggerOnOwnActions: true
onFailure:
onSuccess:
37 changes: 37 additions & 0 deletions .github/policies/labelManagement.assignIcmUsersAndModerators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
id: labelAdded.assignIcmUsersAndModerators
name: GitOps.PullRequestIssueManagement
description: When these labels are added, the ICM Primary and secondary user should be assigned
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- description: >-
When any label below is added to a PR
* Assign the ICM users
- if:
- payloadType: Pull_Request
- or:
- labelAdded:
label: Needs-Attention
- labelAdded:
label: Internal-Error
- labelAdded:
label: Author-Not-Authorized
then:
- assignTo:
user: ryfu-msft
# - assignIcmUsers:
# teamId: 85579
# primary: True
# secondary: False
# - assignIcmUsers:
# teamId: 85579
# primary: False
# secondary: True
# The policy service should trigger even when the label was added by the policy service
triggerOnOwnActions: true
onFailure:
onSuccess:
38 changes: 38 additions & 0 deletions .github/policies/labelManagement.issueClosed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
id: labelManagement.issueClosed
name: GitOps.PullRequestIssueManagement
description: Handlers when an issue gets closed
owner:
resource: repository
disabled: false
where:
configuration:
resourceManagementConfiguration:
eventResponderTasks:
- description: Remove labels when an issue is closed
if:
- payloadType: Issues
- isAction:
action: Closed
then:
- removeLabel:
label: Needs-Triage
- removeLabel:
label: Needs-Attention
- removeLabel:
label: Needs-Author-Feedback
- removeLabel:
label: Help-Wanted
## TODO: Unassign author
- description: Remove labels when a pull request is closed
if:
- payloadType: Pull_Request
- isAction:
action: Closed
then:
- removeLabel:
label: Needs-Attention
- removeLabel:
label: Needs-Author-Feedback
## TODO: Unassign ICM Users
onFailure:
onSuccess:
Loading

0 comments on commit 7cda050

Please sign in to comment.