diff --git a/.github/policies/BreakingChangeManagement.yml b/.github/policies/BreakingChangeManagement.yml new file mode 100644 index 0000000000..1b32be5c25 --- /dev/null +++ b/.github/policies/BreakingChangeManagement.yml @@ -0,0 +1,43 @@ +id: +name: GitOps.BreakingChangeManagement +description: GitOps.BreakingChangeManagement primitive +owner: +resource: repository +disabled: false +where: +configuration: + resourceManagementConfiguration: + eventResponderTasks: + - if: + - payloadType: Issues + - labelAdded: + label: breaking-change + then: + - addReply: + reply: >- + Refer to the [.NET SDK breaking change guidelines](https://github.com/dotnet/sdk/blob/main/documentation/project-docs/breaking-change-guidelines.md#required-process-for-all-net-sdk-breaking-changes) + description: Add breaking change doc instructions to issue + - if: + - payloadType: Pull_Request + - labelAdded: + label: breaking-change + then: + - addLabel: + label: needs-breaking-change-doc-created + - addReply: + reply: >- + Added `needs-breaking-change-doc-created` label because this PR has the `breaking-change` label. + + + When you commit this breaking change: + + + 1. [ ] Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the [breaking change documentation template](https://aka.ms/dotnet/docs/new-breaking-change-issue), then remove this `needs-breaking-change-doc-created` label. + + 2. [ ] Ask a committer to mail the `.NET SDK Breaking Change Notification` email list. + + + You can refer to the [.NET SDK breaking change guidelines](https://github.com/dotnet/sdk/blob/main/documentation/project-docs/breaking-change-guidelines.md) + description: Add breaking change instructions to PR. +onFailure: +onSuccess: diff --git a/.github/policies/LabelManagement.IssueClosed.yml b/.github/policies/LabelManagement.IssueClosed.yml new file mode 100644 index 0000000000..e4865dc4f3 --- /dev/null +++ b/.github/policies/LabelManagement.IssueClosed.yml @@ -0,0 +1,36 @@ +id: +name: LabelManagement.IssueClosed +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 :mag:' + - removeLabel: + label: 'Needs: Attention :wave:' + - removeLabel: + label: 'Needs: Author Feedback' + - removeLabel: + label: Help-Wanted + - description: Remove labels when a pull request is closed + if: + - payloadType: Pull_Request + - isAction: + action: Closed + then: + - removeLabel: + label: 'Needs: Attention :wave:' + - removeLabel: + label: 'Needs: Author Feedback' +onFailure: +onSuccess: diff --git a/.github/policies/LabelManagement.IssueOpened.yml b/.github/policies/LabelManagement.IssueOpened.yml new file mode 100644 index 0000000000..02b4d0bf22 --- /dev/null +++ b/.github/policies/LabelManagement.IssueOpened.yml @@ -0,0 +1,27 @@ +id: +name: LabelManagement.IssueOpened +description: Handlers when an issue is first opened +owner: +resource: repository +disabled: false +where: +configuration: + resourceManagementConfiguration: + eventResponderTasks: + - description: Add needs triage to new issues + if: + - payloadType: Issues + - isAction: + action: Opened + - and: + - not: + activitySenderHasPermission: + permission: Admin + - not: + activitySenderHasPermission: + permission: Write + then: + - addLabel: + label: 'Needs: Triage :mag:' +onFailure: +onSuccess: diff --git a/.github/policies/LabelManagement.IssueUpdated.yml b/.github/policies/LabelManagement.IssueUpdated.yml new file mode 100644 index 0000000000..fee7f3e06e --- /dev/null +++ b/.github/policies/LabelManagement.IssueUpdated.yml @@ -0,0 +1,144 @@ +id: +name: LabelManagement.IssueUpdated +description: Handlers when an issue is updated but not closed +owner: +resource: repository +disabled: false +where: +configuration: + resourceManagementConfiguration: + eventResponderTasks: + - description: >- + Remove "State: No Recent Activity" when a pull request or issue is updated + if: + - or: + - payloadType: Pull_Request + - payloadType: Pull_Request_Review + - payloadType: Pull_Request_Review_Comment + - payloadType: Issue_Comment + - payloadType: Issues + - not: + isAction: + action: Closed + - hasLabel: + label: "State: No Recent Activity" + then: + - removeLabel: + label: "State: No Recent Activity" + # The policy service should not trigger itself here, or else the label would be removed immediately after being added + triggerOnOwnActions: False + - description: Clean email replies on every comment + if: + - payloadType: Issue_Comment + then: + - cleanEmailReply + - description: Remove "Help-Wanted" label when an issue goes into PR + if: + - payloadType: Issues + - labelAdded: + label: In-PR + - hasLabel: + label: Help-Wanted + then: + - removeLabel: + label: Help-Wanted + - description: >- + If an author responds to an issue which needs author feedback + * Remove the "Needs: Author Feedback" Label + * Add the "Needs: Attention :wave:" Label + if: + - or: + - payloadType: Pull_Request_Review + - payloadType: Pull_Request_Review_Comment + - payloadType: Issue_Comment + - isActivitySender: + issueAuthor: True + - hasLabel: + label: "Needs: Author Feedback" + - not: + isAction: + action: Synchronize + then: + - removeLabel: + label: "Needs: Author Feedback" + - addLabel: + label: "Needs: Attention :wave:" + - description: >- + If team members respond to an issue which needs attention + * Remove the "Needs: Attention :wave:" Label + if: + - or: + - payloadType: Pull_Request_Review + - payloadType: Pull_Request_Review_Comment + - payloadType: Issue_Comment + - isActivitySender: + issueAuthor: True + - hasLabel: + label: "Needs: Attention :wave:" + - not: + isAction: + action: Synchronize + - or: + - activitySenderHasAssociation: + association: Member + - activitySenderHasAssociation: + association: Owner + - activitySenderHasAssociation: + association: Collaborator + then: + - removeLabel: + label: "Needs: Attention :wave:" + - description: >- + If team members respond to an issue which needs triage + * Remove the "Needs: Triage :mag:" Label + if: + - or: + - payloadType: Pull_Request_Review + - payloadType: Pull_Request_Review_Comment + - payloadType: Issue_Comment + - isActivitySender: + issueAuthor: True + - hasLabel: + label: "Needs: Triage :mag:" + - not: + isAction: + action: Synchronize + - or: + - activitySenderHasAssociation: + association: Member + - activitySenderHasAssociation: + association: Owner + - activitySenderHasAssociation: + association: Collaborator + then: + - removeLabel: + label: "Needs: Triage :mag:" + - description: >- + When changes are requested on a pull request + * Disable automerge + * Assign to the author + * Label with "Needs: Author Feedback" + if: + - payloadType: Pull_Request_Review + - isAction: + action: Submitted + - isReviewState: + reviewState: Changes_requested + then: + - disableAutoMerge + - assignTo: + author: True + - addLabel: + label: "Needs: Author Feedback" + - description: Sync labels from issues on all pull request events + if: + - payloadType: Pull_Request + then: + - labelSync: + pattern: "Area:" + - labelSync: + pattern: "Type:" + - inPrLabel: + label: In-PR +onFailure: +onSuccess: diff --git a/.github/policies/ScheduledSearch.AutoClose.yml b/.github/policies/ScheduledSearch.AutoClose.yml new file mode 100644 index 0000000000..df645b7c6e --- /dev/null +++ b/.github/policies/ScheduledSearch.AutoClose.yml @@ -0,0 +1,102 @@ +id: ScheduledSearch.AutoClose +name: GitOps.PullRequestIssueManagement +description: Housekeeping of issues that should be closed +owner: +resource: repository +disabled: false +where: +configuration: + resourceManagementConfiguration: + scheduledSearches: + - description: >- + Search for PR where - + * Pull Request is Open + * Pull request has the label "State: No Recent Activity" + * Pull request has the label "Needs: Author Feedback" + * Has not had activity in the last 7 days + + Then - + * Close the PR + frequencies: + - hourly: + hour: 6 + filters: + - isPullRequest + - isOpen + - hasLabel: + label: "State: No Recent Activity" + - hasLabel: + label: "Needs: Author Feedback" + - noActivitySince: + days: 7 + actions: + - closeIssue + - description: >- + Search for Issues where - + * Issue is Open + * Issue has the label "State: No Recent Activity" + * Issue has the label "Needs: Author Feedback" + * Has not had activity in the last 7 days + + Then - + * Close the Issue + frequencies: + - hourly: + hour: 6 + filters: + - isIssue + - isOpen + - hasLabel: + label: "State: No Recent Activity" + - hasLabel: + label: "Needs: Author Feedback" + - noActivitySince: + days: 7 + actions: + - closeIssue + - description: >- + Search for Issues where - + * Issue is Open + * Issue has the label "State: Won't Fix" + * Has not had activity in the last 1 day + + Then - + * Close the Issue + frequencies: + - hourly: + hour: 6 + filters: + - isIssue + - isOpen + - hasLabel: + label: "State: Won't Fix" + - noActivitySince: + days: 1 + actions: + - addReply: + reply: This issue has been marked as won't fix and has not had any activity for **1 day**. It will be closed for housekeeping purposes. + - closeIssue + - description: >- + Search for Issues where - + * Issue is Open + * Issue has the label "Resolution: Duplicate" + * Has not had activity in the last 1 day + + Then - + * Close the Issue + frequencies: + - hourly: + hour: 6 + filters: + - isIssue + - isOpen + - hasLabel: + label: "Resolution: Duplicate" + - noActivitySince: + days: 1 + actions: + - addReply: + reply: This issue has been marked as duplicate and has not had any activity for **1 day**. It will be closed for housekeeping purposes. + - closeIssue +onFailure: +onSuccess: \ No newline at end of file diff --git a/.github/policies/ScheduledSearch.MarkNoRecentActivity.yml b/.github/policies/ScheduledSearch.MarkNoRecentActivity.yml new file mode 100644 index 0000000000..f4fd2da1a8 --- /dev/null +++ b/.github/policies/ScheduledSearch.MarkNoRecentActivity.yml @@ -0,0 +1,72 @@ +id: ScheduledSearch.MarkNoRecentActivity +name: GitOps.PullRequestIssueManagement +description: Mark issues and pull requests with no recent activity +owner: +resource: repository +disabled: false +where: +configuration: + resourceManagementConfiguration: + scheduledSearches: + - description: >- + Search for PR where - + * Pull Request is Open + * Pull request does not have the label "State: No Recent Activity" + * Pull request has the label "Needs: Author Feedback" + * Has not had activity in the last 7 days + + Then - + * Add "State: No Recent Activity" label + * Warn user about pending closure + frequencies: + - hourly: + hour: 6 + filters: + - isPullRequest + - isOpen + - isNotLabeledWith: + label: "State: No Recent Activity" + - hasLabel: + label: "Needs: Author Feedback" + - noActivitySince: + days: 7 + actions: + - addLabel: + label: "State: No Recent Activity" + - 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 activity for **7 days**. It will be closed if no further activity occurs **within 7 days of this comment**. + - description: >- + Search for Issues where - + * Issue is Open + * Issue has the label "Needs: Author Feedback" + * Issue does not have the label "State: No Recent Activity" + * Has not had activity in the last 7 days + + Then - + * Add "State: No Recent Activity" label + * Warn user about pending closure + frequencies: + - hourly: + hour: 6 + filters: + - isIssue + - isOpen + - hasLabel: + label: "Needs: Author Feedback" + - isNotLabeledWith: + label: "State: No Recent Activity" + - noActivitySince: + days: 7 + actions: + - addLabel: + label: "State: No Recent Activity" + - 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 activity for **7 days**. It will be closed if no further activity occurs **within 7 days of this comment**. +onFailure: +onSuccess: \ No newline at end of file diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml deleted file mode 100644 index 5d593c9599..0000000000 --- a/.github/policies/resourceManagement.yml +++ /dev/null @@ -1,143 +0,0 @@ -id: -name: GitOps.PullRequestIssueManagement -description: GitOps.PullRequestIssueManagement primitive -owner: -resource: repository -disabled: false -where: -configuration: - resourceManagementConfiguration: - scheduledSearches: - - description: - frequencies: - - hourly: - hour: 6 - filters: - - isIssue - - isOpen - - hasLabel: - label: needs-author-feedback - - noActivitySince: - days: 10 - - isNotLabeledWith: - label: status-no-recent-activity - actions: - - addLabel: - label: status-no-recent-activity - - addReply: - reply: This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **10 days**. - - description: - frequencies: - - hourly: - hour: 6 - filters: - - isIssue - - isOpen - - hasLabel: - label: duplicate - - noActivitySince: - days: 1 - actions: - - addReply: - reply: This issue has been marked as duplicate and has not had any activity for **1 day**. It will be closed for housekeeping purposes. - - closeIssue - eventResponderTasks: - - if: - - payloadType: Issues - - labelAdded: - label: breaking-change - then: - - addReply: - reply: >- - Refer to the [.NET SDK breaking change guidelines](https://github.com/dotnet/sdk/blob/main/documentation/project-docs/breaking-change-guidelines.md#required-process-for-all-net-sdk-breaking-changes) - description: Add breaking change doc instructions to issue - - if: - - payloadType: Pull_Request - - labelAdded: - label: breaking-change - then: - - addLabel: - label: needs-breaking-change-doc-created - - addReply: - reply: >- - Added `needs-breaking-change-doc-created` label because this PR has the `breaking-change` label. - - - When you commit this breaking change: - - - 1. [ ] Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the [breaking change documentation template](https://aka.ms/dotnet/docs/new-breaking-change-issue), then remove this `needs-breaking-change-doc-created` label. - - 2. [ ] Ask a committer to mail the `.NET SDK Breaking Change Notification` email list. - - - You can refer to the [.NET SDK breaking change guidelines](https://github.com/dotnet/sdk/blob/main/documentation/project-docs/breaking-change-guidelines.md) - description: Add breaking change instructions to PR. - - if: - - payloadType: Issue_Comment - - isAction: - action: Created - - isActivitySender: - issueAuthor: True - - hasLabel: - label: needs-author-feedback - - isOpen - then: - - addLabel: - label: needs-attention - - removeLabel: - label: needs-author-feedback - description: - - if: - - payloadType: Issues - - not: - isAction: - action: Closed - - hasLabel: - label: status-no-recent-activity - then: - - removeLabel: - label: status-no-recent-activity - description: - - if: - - payloadType: Issue_Comment - - hasLabel: - label: status-no-recent-activity - then: - - removeLabel: - label: status-no-recent-activity - description: - - if: - - payloadType: Pull_Request - - hasLabel: - label: auto-merge - then: - - enableAutoMerge: - mergeMethod: Squash - description: - - if: - - payloadType: Pull_Request - - labelRemoved: - label: auto-merge - then: - - disableAutoMerge - description: - - if: - - payloadType: Pull_Request - - titleContains: - pattern: .+Update dependencies from dotnet/arcade .+ - isRegex: True - - isActivitySender: - user: dotnet-maestro - issueAuthor: False - - isAction: - action: Opened - then: - - addLabel: - label: auto-merge - - approvePullRequest: - comment: Arcade update PR auto-approved. - description: - triggerOnOwnActions: true -onFailure: -onSuccess: diff --git a/.github/workflows/enable-auto-merge.yml b/.github/workflows/enable-auto-merge.yml new file mode 100644 index 0000000000..6f9f597939 --- /dev/null +++ b/.github/workflows/enable-auto-merge.yml @@ -0,0 +1,28 @@ +name: Enable auto merge +on: + pull_request_target: + types: [opened, ready_for_review] +permissions: + contents: write +jobs: + add_milestone: + runs-on: ubuntu-latest + if: ${{ github.repository == 'microsoft/vstest' && github.event.pull_request.user.login == 'dotnet-bot' && (startsWith(github.event.pull_request.title, 'Localized file check-in') || startsWith(github.event.pull_request.title, 'Update dependencies from dotnet/') || startsWith(github.event.pull_request.title, 'Update dependencies from microsoft/')) }} + steps: + - name: Enable pull request auto-merge + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PULL_REQUEST_ID: ${{ github.event.pull_request.node_id }} + run: | + gh api graphql -f query=' + mutation($pull: ID!) { + enablePullRequestAutoMerge(input: {pullRequestId: $pull}) { + pullRequest { + id + number + autoMergeRequest { + mergeMethod + } + } + } + }' -f pull=$PULL_REQUEST_ID \ No newline at end of file