From 95a68f229a11907358a6c860815c8af7610b86bf Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Fri, 25 Feb 2022 17:16:11 -0800 Subject: [PATCH] Generate fabricbot config for the machinelearning repo (#65875) --- .../generated/areapods-machinelearning.json | 280 +++++++++++++++++++++ .github/fabricbot/scripts/updateAreaPodConfigs.js | 92 ++++--- 2 files changed, 339 insertions(+), 33 deletions(-) create mode 100644 .github/fabricbot/generated/areapods-machinelearning.json diff --git a/.github/fabricbot/generated/areapods-machinelearning.json b/.github/fabricbot/generated/areapods-machinelearning.json new file mode 100644 index 0000000..adcc63e --- /dev/null +++ b/.github/fabricbot/generated/areapods-machinelearning.json @@ -0,0 +1,280 @@ +[ + { + "taskType": "trigger", + "capabilityId": "IssueResponder", + "subCapability": "IssuesOnlyResponder", + "version": "1.0", + "config": { + "conditions": { + "operator": "and", + "operands": [ + { + "operator": "or", + "operands": [ + { + "operator": "and", + "operands": [ + { + "operator": "or", + "operands": [ + { + "name": "isAction", + "parameters": { + "action": "reopened" + } + }, + { + "operator": "not", + "operands": [ + { + "name": "isInMilestone", + "parameters": {} + } + ] + } + ] + } + ] + } + ] + }, + { + "name": "isOpen", + "parameters": {} + }, + { + "operator": "or", + "operands": [ + { + "operator": "not", + "operands": [ + { + "name": "isInProject", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - Issue Triage", + "isOrgProject": true + } + } + ] + }, + { + "name": "isInProjectColumn", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - Issue Triage", + "isOrgProject": true, + "columnName": "Triaged" + } + } + ] + } + ] + }, + "eventType": "issue", + "eventNames": [ + "issues", + "project_card" + ], + "taskName": "[Area Pod: Michael / Tanner - Issue Triage] Add new issue to Board", + "actions": [ + { + "name": "addToProject", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - Issue Triage", + "columnName": "Needs Triage", + "isOrgProject": true + } + } + ] + } + }, + { + "taskType": "trigger", + "capabilityId": "IssueResponder", + "subCapability": "IssueCommentResponder", + "version": "1.0", + "config": { + "conditions": { + "operator": "and", + "operands": [ + { + "operator": "not", + "operands": [ + { + "name": "isCloseAndComment", + "parameters": {} + } + ] + }, + { + "operator": "not", + "operands": [ + { + "name": "activitySenderHasPermissions", + "parameters": { + "permissions": "write" + } + } + ] + }, + { + "operator": "or", + "operands": [ + { + "operator": "not", + "operands": [ + { + "name": "isInProject", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - Issue Triage", + "isOrgProject": true + } + } + ] + }, + { + "name": "isInProjectColumn", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - Issue Triage", + "columnName": "Triaged", + "isOrgProject": true + } + } + ] + } + ] + }, + "eventType": "issue", + "eventNames": [ + "issue_comment" + ], + "taskName": "[Area Pod: Michael / Tanner - Issue Triage] Needs Further Triage", + "actions": [ + { + "name": "addToProject", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - Issue Triage", + "columnName": "Needs Triage", + "isOrgProject": true + } + } + ] + } + }, + { + "taskType": "trigger", + "capabilityId": "IssueResponder", + "subCapability": "IssuesOnlyResponder", + "version": "1.0", + "config": { + "conditions": { + "operator": "and", + "operands": [ + { + "name": "isInProject", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - Issue Triage", + "isOrgProject": true + } + }, + { + "operator": "not", + "operands": [ + { + "name": "isInProjectColumn", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - Issue Triage", + "columnName": "Triaged" + } + } + ] + }, + { + "operator": "or", + "operands": [ + { + "name": "addedToMilestone", + "parameters": {} + }, + { + "name": "labelAdded", + "parameters": { + "label": "needs-author-action" + } + }, + { + "name": "labelAdded", + "parameters": { + "label": "api-ready-for-review" + } + }, + { + "name": "isAction", + "parameters": { + "action": "closed" + } + } + ] + } + ] + }, + "eventType": "issue", + "eventNames": [ + "issues", + "project_card" + ], + "taskName": "[Area Pod: Michael / Tanner - Issue Triage] Move to Triaged Column", + "actions": [ + { + "name": "addToProject", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - Issue Triage", + "columnName": "Triaged", + "isOrgProject": true + } + } + ] + } + }, + { + "taskType": "trigger", + "capabilityId": "IssueResponder", + "subCapability": "PullRequestResponder", + "version": "1.0", + "config": { + "conditions": { + "operator": "and", + "operands": [ + { + "operator": "not", + "operands": [ + { + "name": "isInProject", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - PRs", + "isOrgProject": true + } + } + ] + } + ] + }, + "eventType": "pull_request", + "eventNames": [ + "pull_request", + "issues", + "project_card" + ], + "taskName": "[Area Pod: Michael / Tanner - PRs] Add new PR to Board", + "actions": [ + { + "name": "addToProject", + "parameters": { + "projectName": "Area Pod: Michael / Tanner - PRs", + "columnName": "Needs Champion", + "isOrgProject": true + } + } + ] + } + } +] \ No newline at end of file diff --git a/.github/fabricbot/scripts/updateAreaPodConfigs.js b/.github/fabricbot/scripts/updateAreaPodConfigs.js index 2440496..cf992ff 100644 --- a/.github/fabricbot/scripts/updateAreaPodConfigs.js +++ b/.github/fabricbot/scripts/updateAreaPodConfigs.js @@ -9,6 +9,7 @@ const fs = require('fs'); let generatedRuntimeConfigsFile = path.join(__dirname, '..', 'generated', 'areapods-runtime.json'); let generatedApiDocsConfigsFile = path.join(__dirname, '..', 'generated', 'areapods-dotnet-api-docs.json'); +let generatedMachineLearningConfigsFile = path.join(__dirname, '..', 'generated', 'areapods-machinelearning.json'); let areaPods = [ { @@ -100,6 +101,9 @@ let areaPods = [ "area-System.Numerics.Tensors", "area-System.Runtime", "area-System.Runtime.Intrinsics" + ], + "repos": [ + "machinelearning" ] }, { @@ -116,7 +120,7 @@ let areaPods = [ ]; let areaPodConfig = { - issueTriageRemove: ({pod, areas}) => ({ + issueRemove: ({pod, areas}) => ({ "taskType": "trigger", "capabilityId": "IssueResponder", "subCapability": "IssuesOnlyResponder", @@ -128,9 +132,9 @@ let areaPodConfig = { { "name": "isInProjectColumn", "parameters": { - "projectName": `Area Pod: ${pod} - Issue Triage`, - "columnName": "Needs Triage", - "isOrgProject": true + "projectName": `Area Pod: ${pod} - Issue Triage`, + "columnName": "Needs Triage", + "isOrgProject": true } }, { @@ -164,7 +168,7 @@ let areaPodConfig = { ] } }), - issueTriageNeedsTriage: ({pod, areas}) => ({ + issueNeedsTriage: ({pod, areas}) => ({ "taskType": "trigger", "capabilityId": "IssueResponder", "subCapability": "IssuesOnlyResponder", @@ -184,13 +188,13 @@ let areaPodConfig = { "operator": "and", "operands": [ - { + (!!areas && { "operator": "or", "operands": areas.map(area => ({ "name": "hasLabel", "parameters": { "label": area } })) - }, + }), { "operator": "or", "operands": @@ -214,16 +218,16 @@ let areaPodConfig = { } ] } - ] + ].filter(op => !!op) // We will have a falsy element in the array of we're not filtering by area label }, - { + (!!areas && { "operator": "or", "operands": areas.map(area => ({ "name": "labelAdded", "parameters": { "label": area } })) - } - ] + }) + ].filter(op => !!op) // We will have a falsy element in the array of we're not filtering by area label }, { "name": "isOpen", @@ -282,7 +286,7 @@ let areaPodConfig = { ] } }), - issueTriageNeedsFurtherTriage: ({pod, areas}) => ({ + issueNeedsFurtherTriage: ({pod, areas}) => ({ "taskType": "trigger", "capabilityId": "IssueResponder", "subCapability": "IssueCommentResponder", @@ -294,13 +298,13 @@ let areaPodConfig = { "operator": "and", "operands": [ - { + (!!areas && { "operator": "or", "operands": areas.map(area => ({ "name": "hasLabel", "parameters": { "label": area } })) - }, + }), { "operator": "not", "operands": @@ -352,7 +356,7 @@ let areaPodConfig = { } ] } - ] + ].filter(op => !!op) // We will have a falsy element in the array of we're not filtering by area label }, "eventType": "issue", "eventNames": @@ -374,7 +378,7 @@ let areaPodConfig = { ] } }), - issueTriageTriaged: ({pod, areas}) => ({ + issueTriaged: ({pod, areas}) => ({ "taskType": "trigger", "capabilityId": "IssueResponder", "subCapability": "IssuesOnlyResponder", @@ -472,13 +476,13 @@ let areaPodConfig = { "conditions": { "operator": "and", "operands": [ - { + (!!areas && { "operator": "or", "operands": areas.map(area => ({ "name": "hasLabel", "parameters": { "label": area } })) - }, + }), { "operator": "not", "operands": [ @@ -491,7 +495,7 @@ let areaPodConfig = { } ] } - ] + ].filter(op => !!op) // We will have a falsy element in the array of we're not filtering by area label }, "eventType": "pull_request", "eventNames": [ @@ -512,7 +516,7 @@ let areaPodConfig = { ] } }), - prRemove: ({pod, areas}) => ({ + pullRequestRemove: ({pod, areas}) => ({ "taskType": "trigger", "capabilityId": "IssueResponder", "subCapability": "PullRequestResponder", @@ -529,7 +533,7 @@ let areaPodConfig = { "isOrgProject": true } }, - { + (!!areas && { "operator": "and", "operands": areas.map(area => ({ "operator": "not", @@ -540,8 +544,8 @@ let areaPodConfig = { } ] })) - } - ] + }) + ].filter(op => !!op) // We will have a falsy element in the array of we're not filtering by area label }, "eventType": "pull_request", "eventNames": [ @@ -568,12 +572,12 @@ let generatedRuntimeTasks = areaPods .filter(areaPod => areaPod.enabled) .flatMap(areaPod => [ - areaPodConfig.issueTriageNeedsTriage(areaPod), - areaPodConfig.issueTriageNeedsFurtherTriage(areaPod), - areaPodConfig.issueTriageRemove(areaPod), - areaPodConfig.issueTriageTriaged(areaPod), + areaPodConfig.issueNeedsTriage(areaPod), + areaPodConfig.issueNeedsFurtherTriage(areaPod), + areaPodConfig.issueRemove(areaPod), + areaPodConfig.issueTriaged(areaPod), areaPodConfig.pullRequestAdd(areaPod), - areaPodConfig.prRemove(areaPod), + areaPodConfig.pullRequestRemove(areaPod), ]); let generatedRuntimeJson = JSON.stringify(generatedRuntimeTasks, null, 2); @@ -585,14 +589,36 @@ let generatedApiDocsTasks = areaPods .filter(areaPod => areaPod.enabled) .flatMap(areaPod => [ - areaPodConfig.issueTriageNeedsTriage(areaPod), - areaPodConfig.issueTriageNeedsFurtherTriage(areaPod), - areaPodConfig.issueTriageRemove(areaPod), - // areaPodConfig.issueTriageTriaged(areaPod), + areaPodConfig.issueNeedsTriage(areaPod), + areaPodConfig.issueNeedsFurtherTriage(areaPod), + areaPodConfig.issueRemove(areaPod), + // We're not using milestones in the dotnet-api-docs repo, so we can't automatically move to triaged + // areaPodConfig.issueTriaged(areaPod), areaPodConfig.pullRequestAdd(areaPod), - areaPodConfig.prRemove(areaPod), + areaPodConfig.pullRequestRemove(areaPod), ]); let generatedApiDocsJson = JSON.stringify(generatedApiDocsTasks, null, 2); fs.writeFileSync(generatedApiDocsConfigsFile, generatedApiDocsJson); console.log(`Written generated tasks to ${generatedApiDocsConfigsFile}`); + +// Generate machinelearning automation +let generatedMachineLearningTasks = areaPods + .filter(areaPod => areaPod.enabled) + // Filter to the pod that includes the machinelearning repo + .filter(({repos}) => repos && repos.includes("machinelearning")) + // Remove the `areas` property from the pod + .map(({areas, ...podWithoutAreas}) => podWithoutAreas) + .flatMap(areaPod => + [ + areaPodConfig.issueNeedsTriage(areaPod), + areaPodConfig.issueNeedsFurtherTriage(areaPod), + areaPodConfig.issueTriaged(areaPod), + areaPodConfig.pullRequestAdd(areaPod) + // Issues and PRs don't get removed from the boards because that + // only applies when moved to a different pod via area label + ]); + +let generatedMachineLearningJson = JSON.stringify(generatedMachineLearningTasks, null, 2); +fs.writeFileSync(generatedMachineLearningConfigsFile, generatedMachineLearningJson); +console.log(`Written generated tasks to ${generatedMachineLearningConfigsFile}`); -- 2.7.4