From 5685ddab5c9949161242617e35e7a297d2a2416d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 8 Aug 2024 09:52:41 -0700 Subject: [PATCH] Fix blessings (#1045) --- packages/mergebot/src/_tests/cachedQueries.js | 1 + .../src/_tests/fixtures/45627/derived.json | 2 +- .../src/_tests/fixtures/45884/derived.json | 2 +- .../src/_tests/fixtures/45888/derived.json | 2 +- .../src/_tests/fixtures/45888/mutations.json | 13 + .../src/_tests/fixtures/45888/result.json | 2 +- .../src/_tests/fixtures/45999/derived.json | 2 +- .../src/_tests/fixtures/46008/derived.json | 2 +- .../src/_tests/fixtures/46279/derived.json | 2 +- .../src/_tests/fixtures/46279/mutations.json | 2 +- .../src/_tests/fixtures/46279/result.json | 2 +- .../src/_tests/fixtures/46804/derived.json | 2 +- .../src/_tests/fixtures/46804/mutations.json | 13 + .../src/_tests/fixtures/46804/result.json | 2 +- .../47017-blessed-and-one-owner/derived.json | 2 +- .../mutations.json | 13 + .../47017-blessed-and-one-owner/result.json | 2 +- .../47017-blessed-and-two-owner/derived.json | 2 +- .../fixtures/47017-blessed/derived.json | 2 +- .../fixtures/47017-blessed/mutations.json | 13 + .../_tests/fixtures/47017-blessed/result.json | 2 +- .../src/_tests/fixtures/52848/derived.json | 3 +- .../src/_tests/fixtures/52848/mutations.json | 2 +- .../src/_tests/fixtures/52848/result.json | 2 +- .../src/_tests/fixtures/70222/_downloads.json | 3 + .../src/_tests/fixtures/70222/_files.json | 4 + .../src/_tests/fixtures/70222/_response.json | 227 ++++++++++++++++++ .../src/_tests/fixtures/70222/derived.json | 42 ++++ .../src/_tests/fixtures/70222/mutations.json | 11 + .../src/_tests/fixtures/70222/result.json | 25 ++ packages/mergebot/src/basic.ts | 18 +- packages/mergebot/src/compute-pr-actions.ts | 42 ++-- packages/mergebot/src/execute-pr-actions.ts | 15 +- packages/mergebot/src/pr-info.ts | 32 ++- packages/mergebot/src/queries/pr-query.ts | 1 + packages/mergebot/src/queries/schema/PR.ts | 4 + 36 files changed, 451 insertions(+), 65 deletions(-) create mode 100644 packages/mergebot/src/_tests/fixtures/70222/_downloads.json create mode 100644 packages/mergebot/src/_tests/fixtures/70222/_files.json create mode 100644 packages/mergebot/src/_tests/fixtures/70222/_response.json create mode 100644 packages/mergebot/src/_tests/fixtures/70222/derived.json create mode 100644 packages/mergebot/src/_tests/fixtures/70222/mutations.json create mode 100644 packages/mergebot/src/_tests/fixtures/70222/result.json diff --git a/packages/mergebot/src/_tests/cachedQueries.js b/packages/mergebot/src/_tests/cachedQueries.js index 0521ee3e84..059b57e3e7 100644 --- a/packages/mergebot/src/_tests/cachedQueries.js +++ b/packages/mergebot/src/_tests/cachedQueries.js @@ -4,6 +4,7 @@ module.exports = ((h) => ({ new Map([ ["Needs Maintainer Action", "f75ad846"], ["Needs Maintainer Review", "47fc9ee4"], + ["Waiting for Code Reviews (Blessed)", "e2dd54d5"], ["Waiting for Code Reviews", "98236657"], ["Needs Author Action", "d389394c"], ["Waiting for Author to Merge", "7da042bf"], diff --git a/packages/mergebot/src/_tests/fixtures/45627/derived.json b/packages/mergebot/src/_tests/fixtures/45627/derived.json index c790dc7eaf..db416f6900 100644 --- a/packages/mergebot/src/_tests/fixtures/45627/derived.json +++ b/packages/mergebot/src/_tests/fixtures/45627/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-06-21T09:33:06.000Z", "lastActivityDate": "2020-07-06T08:36:06.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "mergeOfferDate": "2020-04-30T01:31:41.000Z", "mergeRequestDate": "2020-07-06T08:36:06.000Z", "mergeRequestUser": "spamshaker", diff --git a/packages/mergebot/src/_tests/fixtures/45884/derived.json b/packages/mergebot/src/_tests/fixtures/45884/derived.json index a8f148d019..12781873fb 100644 --- a/packages/mergebot/src/_tests/fixtures/45884/derived.json +++ b/packages/mergebot/src/_tests/fixtures/45884/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-07-04T08:33:11.000Z", "lastActivityDate": "2020-07-06T06:50:47.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "mergeOfferDate": "2020-07-06T06:51:10.000Z", "hasMergeConflict": false, "isFirstContribution": true, diff --git a/packages/mergebot/src/_tests/fixtures/45888/derived.json b/packages/mergebot/src/_tests/fixtures/45888/derived.json index a10017bb08..7b331bff8b 100644 --- a/packages/mergebot/src/_tests/fixtures/45888/derived.json +++ b/packages/mergebot/src/_tests/fixtures/45888/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-07-04T18:01:47.000Z", "lastActivityDate": "2020-07-06T07:40:21.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "hasMergeConflict": false, "isFirstContribution": true, "tooManyFiles": false, diff --git a/packages/mergebot/src/_tests/fixtures/45888/mutations.json b/packages/mergebot/src/_tests/fixtures/45888/mutations.json index fef1a8a33e..94f5719e42 100644 --- a/packages/mergebot/src/_tests/fixtures/45888/mutations.json +++ b/packages/mergebot/src/_tests/fixtures/45888/mutations.json @@ -8,6 +8,19 @@ } } }, + { + "mutation": "mutation ($input: UpdateProjectV2ItemFieldValueInput!) {\n updateProjectV2ItemFieldValue(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "itemId": "MDExOlByb2plY3RDYXJkNDEyNjY1MTY=", + "projectId": "PVT_kwDOADeBNM4AkH1q", + "fieldId": "PVTSSF_lADOADeBNM4AkH1qzgcYOEM", + "value": { + "singleSelectOptionId": "e2dd54d5" + } + } + } + }, { "mutation": "mutation ($input: AddCommentInput!) {\n addComment(input: $input) {\n __typename\n }\n}\n", "variables": { diff --git a/packages/mergebot/src/_tests/fixtures/45888/result.json b/packages/mergebot/src/_tests/fixtures/45888/result.json index 9c6430d1f1..31adafdac6 100644 --- a/packages/mergebot/src/_tests/fixtures/45888/result.json +++ b/packages/mergebot/src/_tests/fixtures/45888/result.json @@ -1,5 +1,5 @@ { - "projectColumn": "Waiting for Code Reviews", + "projectColumn": "Waiting for Code Reviews (Blessed)", "labels": [ "Other Approved", "Untested Change" diff --git a/packages/mergebot/src/_tests/fixtures/45999/derived.json b/packages/mergebot/src/_tests/fixtures/45999/derived.json index a118730bc0..2b5d82045a 100644 --- a/packages/mergebot/src/_tests/fixtures/45999/derived.json +++ b/packages/mergebot/src/_tests/fixtures/45999/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-07-10T13:10:49.000Z", "lastActivityDate": "2020-07-11T02:36:41.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "hasMergeConflict": false, "isFirstContribution": false, "tooManyFiles": false, diff --git a/packages/mergebot/src/_tests/fixtures/46008/derived.json b/packages/mergebot/src/_tests/fixtures/46008/derived.json index a25b19bc8a..2518974613 100644 --- a/packages/mergebot/src/_tests/fixtures/46008/derived.json +++ b/packages/mergebot/src/_tests/fixtures/46008/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-07-10T00:44:49.000Z", "lastActivityDate": "2020-07-11T02:09:10.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "hasMergeConflict": false, "isFirstContribution": true, "tooManyFiles": false, diff --git a/packages/mergebot/src/_tests/fixtures/46279/derived.json b/packages/mergebot/src/_tests/fixtures/46279/derived.json index 4890ffc426..7da9e827e4 100644 --- a/packages/mergebot/src/_tests/fixtures/46279/derived.json +++ b/packages/mergebot/src/_tests/fixtures/46279/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-07-23T01:03:50.000Z", "lastActivityDate": "2020-07-23T18:40:41.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "hasMergeConflict": false, "isFirstContribution": false, "tooManyFiles": false, diff --git a/packages/mergebot/src/_tests/fixtures/46279/mutations.json b/packages/mergebot/src/_tests/fixtures/46279/mutations.json index 16323677d3..6e26fb2f9a 100644 --- a/packages/mergebot/src/_tests/fixtures/46279/mutations.json +++ b/packages/mergebot/src/_tests/fixtures/46279/mutations.json @@ -4,7 +4,7 @@ "variables": { "input": { "id": "MDEyOklzc3VlQ29tbWVudDY2Mjc3Mjk1MA==", - "body": "@pzingg Thank you for submitting this PR!\n\n***This is a live comment that I will keep updated.***\n\n## 1 package in this PR\n\n* `phoenix_live_view` — [on npm](https://www.npmjs.com/package/phoenix_live_view), [on unpkg](https://unpkg.com/browse/phoenix_live_view@latest/) (author is owner)\n\n## Code Reviews\n\nThis PR can be merged once it's reviewed.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=46279&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 Most recent commit is approved by a DT maintainer\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n" + "body": "@pzingg Thank you for submitting this PR!\n\n***This is a live comment that I will keep updated.***\n\n## 1 package in this PR\n\n* `phoenix_live_view` — [on npm](https://www.npmjs.com/package/phoenix_live_view), [on unpkg](https://unpkg.com/browse/phoenix_live_view@latest/) (author is owner)\n\n## Code Reviews\n\nThere aren't any other owners of this package, so a DT maintainer will review it.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=46279&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 A DT maintainer can merge changes when there are no other reviewers\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n" } } }, diff --git a/packages/mergebot/src/_tests/fixtures/46279/result.json b/packages/mergebot/src/_tests/fixtures/46279/result.json index 2c2de3bea7..4336659993 100644 --- a/packages/mergebot/src/_tests/fixtures/46279/result.json +++ b/packages/mergebot/src/_tests/fixtures/46279/result.json @@ -12,7 +12,7 @@ }, { "tag": "welcome", - "status": "@pzingg Thank you for submitting this PR!\n\n***This is a live comment that I will keep updated.***\n\n## 1 package in this PR\n\n* `phoenix_live_view` — [on npm](https://www.npmjs.com/package/phoenix_live_view), [on unpkg](https://unpkg.com/browse/phoenix_live_view@latest/) (author is owner)\n\n## Code Reviews\n\nThis PR can be merged once it's reviewed.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=46279&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 Most recent commit is approved by a DT maintainer\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ..." + "status": "@pzingg Thank you for submitting this PR!\n\n***This is a live comment that I will keep updated.***\n\n## 1 package in this PR\n\n* `phoenix_live_view` — [on npm](https://www.npmjs.com/package/phoenix_live_view), [on unpkg](https://unpkg.com/browse/phoenix_live_view@latest/) (author is owner)\n\n## Code Reviews\n\nThere aren't any other owners of this package, so a DT maintainer will review it.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=46279&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 A DT maintainer can merge changes when there are no other reviewers\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ..." }, { "tag": "pinging-reviewers-others", diff --git a/packages/mergebot/src/_tests/fixtures/46804/derived.json b/packages/mergebot/src/_tests/fixtures/46804/derived.json index c5fee1b25b..27e0f3b514 100644 --- a/packages/mergebot/src/_tests/fixtures/46804/derived.json +++ b/packages/mergebot/src/_tests/fixtures/46804/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-08-15T20:29:40.000Z", "lastActivityDate": "2020-08-25T19:30:37.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "hasMergeConflict": false, "isFirstContribution": true, "tooManyFiles": false, diff --git a/packages/mergebot/src/_tests/fixtures/46804/mutations.json b/packages/mergebot/src/_tests/fixtures/46804/mutations.json index 471d53d9de..fad7de925e 100644 --- a/packages/mergebot/src/_tests/fixtures/46804/mutations.json +++ b/packages/mergebot/src/_tests/fixtures/46804/mutations.json @@ -19,6 +19,19 @@ } } }, + { + "mutation": "mutation ($input: UpdateProjectV2ItemFieldValueInput!) {\n updateProjectV2ItemFieldValue(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "itemId": "MDExOlByb2plY3RDYXJkNDM3MTk3MDM=", + "projectId": "PVT_kwDOADeBNM4AkH1q", + "fieldId": "PVTSSF_lADOADeBNM4AkH1qzgcYOEM", + "value": { + "singleSelectOptionId": "e2dd54d5" + } + } + } + }, { "mutation": "mutation ($input: AddCommentInput!) {\n addComment(input: $input) {\n __typename\n }\n}\n", "variables": { diff --git a/packages/mergebot/src/_tests/fixtures/46804/result.json b/packages/mergebot/src/_tests/fixtures/46804/result.json index 78f6a74dfe..1bf4e8f4b7 100644 --- a/packages/mergebot/src/_tests/fixtures/46804/result.json +++ b/packages/mergebot/src/_tests/fixtures/46804/result.json @@ -1,5 +1,5 @@ { - "projectColumn": "Waiting for Code Reviews", + "projectColumn": "Waiting for Code Reviews (Blessed)", "labels": [ "Untested Change" ], diff --git a/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/derived.json b/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/derived.json index 9ab7d68c8c..e270ef5dc7 100644 --- a/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/derived.json +++ b/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-08-25T05:47:26.000Z", "lastActivityDate": "2020-08-26T20:01:58.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "hasMergeConflict": false, "isFirstContribution": false, "tooManyFiles": false, diff --git a/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/mutations.json b/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/mutations.json index e3fc65cc31..34e1644a7f 100644 --- a/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/mutations.json +++ b/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/mutations.json @@ -7,5 +7,18 @@ "body": "@mastermatt Thank you for submitting this PR!\n\n***This is a live comment that I will keep updated.***\n\n## 2 packages in this PR\n\n* `express-serve-static-core` — [on npm](https://www.npmjs.com/package/express-serve-static-core), [on unpkg](https://unpkg.com/browse/express-serve-static-core@latest/)\n - owner-approval: @dwrss\n* `express` — [on npm](https://www.npmjs.com/package/express), [on unpkg](https://unpkg.com/browse/express@latest/)\n\n## Code Reviews\n\nThis PR can be merged once it's reviewed.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=47017&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 All owners or a DT maintainer needs to approve changes that affect more than one package\n - ✅ express-serve-static-core\n - 🕐 express\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n" } } + }, + { + "mutation": "mutation ($input: UpdateProjectV2ItemFieldValueInput!) {\n updateProjectV2ItemFieldValue(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "itemId": "MDExOlByb2plY3RDYXJkNDQyNTE2ODU=", + "projectId": "PVT_kwDOADeBNM4AkH1q", + "fieldId": "PVTSSF_lADOADeBNM4AkH1qzgcYOEM", + "value": { + "singleSelectOptionId": "e2dd54d5" + } + } + } } ] diff --git a/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/result.json b/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/result.json index 16c47a61fe..d368ea5ecb 100644 --- a/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/result.json +++ b/packages/mergebot/src/_tests/fixtures/47017-blessed-and-one-owner/result.json @@ -1,5 +1,5 @@ { - "projectColumn": "Waiting for Code Reviews", + "projectColumn": "Waiting for Code Reviews (Blessed)", "labels": [ "Critical package", "Edits multiple packages" diff --git a/packages/mergebot/src/_tests/fixtures/47017-blessed-and-two-owner/derived.json b/packages/mergebot/src/_tests/fixtures/47017-blessed-and-two-owner/derived.json index 29f449a102..6bc151ded3 100644 --- a/packages/mergebot/src/_tests/fixtures/47017-blessed-and-two-owner/derived.json +++ b/packages/mergebot/src/_tests/fixtures/47017-blessed-and-two-owner/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-08-25T05:47:26.000Z", "lastActivityDate": "2020-08-26T20:01:58.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "hasMergeConflict": false, "isFirstContribution": false, "tooManyFiles": false, diff --git a/packages/mergebot/src/_tests/fixtures/47017-blessed/derived.json b/packages/mergebot/src/_tests/fixtures/47017-blessed/derived.json index 4560b30378..54d8400683 100644 --- a/packages/mergebot/src/_tests/fixtures/47017-blessed/derived.json +++ b/packages/mergebot/src/_tests/fixtures/47017-blessed/derived.json @@ -7,7 +7,7 @@ "mergeBaseOid": "master", "lastPushDate": "2020-08-25T05:47:26.000Z", "lastActivityDate": "2020-08-26T20:01:58.000Z", - "maintainerBlessed": "Waiting for Code Reviews", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", "hasMergeConflict": false, "isFirstContribution": false, "tooManyFiles": false, diff --git a/packages/mergebot/src/_tests/fixtures/47017-blessed/mutations.json b/packages/mergebot/src/_tests/fixtures/47017-blessed/mutations.json index 3897dd83eb..6ffc51d617 100644 --- a/packages/mergebot/src/_tests/fixtures/47017-blessed/mutations.json +++ b/packages/mergebot/src/_tests/fixtures/47017-blessed/mutations.json @@ -7,5 +7,18 @@ "body": "@mastermatt Thank you for submitting this PR!\n\n***This is a live comment that I will keep updated.***\n\n## 2 packages in this PR\n\n* `express-serve-static-core` — [on npm](https://www.npmjs.com/package/express-serve-static-core), [on unpkg](https://unpkg.com/browse/express-serve-static-core@latest/)\n* `express` — [on npm](https://www.npmjs.com/package/express), [on unpkg](https://unpkg.com/browse/express@latest/)\n\n## Code Reviews\n\nThis PR can be merged once it's reviewed.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=47017&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 All owners or a DT maintainer needs to approve changes that affect more than one package\n - 🕐 express-serve-static-core\n - 🕐 express\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n" } } + }, + { + "mutation": "mutation ($input: UpdateProjectV2ItemFieldValueInput!) {\n updateProjectV2ItemFieldValue(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "itemId": "MDExOlByb2plY3RDYXJkNDQyNTE2ODU=", + "projectId": "PVT_kwDOADeBNM4AkH1q", + "fieldId": "PVTSSF_lADOADeBNM4AkH1qzgcYOEM", + "value": { + "singleSelectOptionId": "e2dd54d5" + } + } + } } ] diff --git a/packages/mergebot/src/_tests/fixtures/47017-blessed/result.json b/packages/mergebot/src/_tests/fixtures/47017-blessed/result.json index ac1ce645a6..c2d4c20250 100644 --- a/packages/mergebot/src/_tests/fixtures/47017-blessed/result.json +++ b/packages/mergebot/src/_tests/fixtures/47017-blessed/result.json @@ -1,5 +1,5 @@ { - "projectColumn": "Waiting for Code Reviews", + "projectColumn": "Waiting for Code Reviews (Blessed)", "labels": [ "Critical package", "Edits multiple packages" diff --git a/packages/mergebot/src/_tests/fixtures/52848/derived.json b/packages/mergebot/src/_tests/fixtures/52848/derived.json index 05f3083fab..901596805f 100644 --- a/packages/mergebot/src/_tests/fixtures/52848/derived.json +++ b/packages/mergebot/src/_tests/fixtures/52848/derived.json @@ -6,8 +6,7 @@ "headCommitOid": "14499debca98ea23cfc47a80a288d5bd32798cff", "mergeBaseOid": "master", "lastPushDate": "2021-05-10T07:57:17.000Z", - "lastActivityDate": "2021-05-10T15:42:52.000Z", - "maintainerBlessed": "Waiting for Author to Merge", + "lastActivityDate": "2021-05-10T07:59:10.000Z", "hasMergeConflict": false, "isFirstContribution": true, "tooManyFiles": false, diff --git a/packages/mergebot/src/_tests/fixtures/52848/mutations.json b/packages/mergebot/src/_tests/fixtures/52848/mutations.json index 1394186661..2acf3c41d3 100644 --- a/packages/mergebot/src/_tests/fixtures/52848/mutations.json +++ b/packages/mergebot/src/_tests/fixtures/52848/mutations.json @@ -4,7 +4,7 @@ "variables": { "input": { "id": "MDEyOklzc3VlQ29tbWVudDgzNjMyODk5Mg==", - "body": "@Runtu4378 Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.\n\n***This is a live comment that I will keep updated.***\n\nThis PR touches some part of DefinitelyTyped infrastructure, so a DT maintainer will need to review it. This is rare — did you mean to do this?\n\n## 0 packages in this PR (and infra files)\n\n* Infra files\n - [`README.cn.md`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files/14499debca98ea23cfc47a80a288d5bd32798cff#diff-97a2a8d47e133a2b24ad7bc1a2e25710f534470e28a73efb62da312a3bb19235)\n\n## Code Reviews\n\nThis PR can be merged.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=52848&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * 🕐 Continuous integration tests are still running\n * ✅ A DT maintainer needs to approve changes that affect DT infrastructure ([`README.cn.md`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files/14499debca98ea23cfc47a80a288d5bd32798cff#diff-97a2a8d47e133a2b24ad7bc1a2e25710f534470e28a73efb62da312a3bb19235))\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n" + "body": "@Runtu4378 Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.\n\n***This is a live comment that I will keep updated.***\n\nThis PR touches some part of DefinitelyTyped infrastructure, so a DT maintainer will need to review it. This is rare — did you mean to do this?\n\n## 0 packages in this PR (and infra files)\n\n* Infra files\n - [`README.cn.md`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files/14499debca98ea23cfc47a80a288d5bd32798cff#diff-97a2a8d47e133a2b24ad7bc1a2e25710f534470e28a73efb62da312a3bb19235)\n\n## Code Reviews\n\nThere aren't any other owners of this package, so a DT maintainer will review it.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=52848&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * 🕐 Continuous integration tests are still running\n * 🕐 A DT maintainer needs to approve changes that affect DT infrastructure ([`README.cn.md`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files/14499debca98ea23cfc47a80a288d5bd32798cff#diff-97a2a8d47e133a2b24ad7bc1a2e25710f534470e28a73efb62da312a3bb19235))\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n" } } }, diff --git a/packages/mergebot/src/_tests/fixtures/52848/result.json b/packages/mergebot/src/_tests/fixtures/52848/result.json index a771b7d4ae..c256999a6c 100644 --- a/packages/mergebot/src/_tests/fixtures/52848/result.json +++ b/packages/mergebot/src/_tests/fixtures/52848/result.json @@ -6,7 +6,7 @@ "responseComments": [ { "tag": "welcome", - "status": "@Runtu4378 Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.\n\n***This is a live comment that I will keep updated.***\n\nThis PR touches some part of DefinitelyTyped infrastructure, so a DT maintainer will need to review it. This is rare — did you mean to do this?\n\n## 0 packages in this PR (and infra files)\n\n* Infra files\n - [`README.cn.md`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files/14499debca98ea23cfc47a80a288d5bd32798cff#diff-97a2a8d47e133a2b24ad7bc1a2e25710f534470e28a73efb62da312a3bb19235)\n\n## Code Reviews\n\nThis PR can be merged.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=52848&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * 🕐 Continuous integration tests are still running\n * ✅ A DT maintainer needs to approve changes that affect DT infrastructure ([`README.cn.md`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files/14499debca98ea23cfc47a80a288d5bd32798cff#diff-97a2a8d47e133a2b24ad7bc1a2e25710f534470e28a73efb62da312a3bb19235))\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ..." + "status": "@Runtu4378 Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.\n\n***This is a live comment that I will keep updated.***\n\nThis PR touches some part of DefinitelyTyped infrastructure, so a DT maintainer will need to review it. This is rare — did you mean to do this?\n\n## 0 packages in this PR (and infra files)\n\n* Infra files\n - [`README.cn.md`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files/14499debca98ea23cfc47a80a288d5bd32798cff#diff-97a2a8d47e133a2b24ad7bc1a2e25710f534470e28a73efb62da312a3bb19235)\n\n## Code Reviews\n\nThere aren't any other owners of this package, so a DT maintainer will review it.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=52848&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * 🕐 Continuous integration tests are still running\n * 🕐 A DT maintainer needs to approve changes that affect DT infrastructure ([`README.cn.md`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files/14499debca98ea23cfc47a80a288d5bd32798cff#diff-97a2a8d47e133a2b24ad7bc1a2e25710f534470e28a73efb62da312a3bb19235))\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ..." }, { "tag": "pinging-reviewers-others", diff --git a/packages/mergebot/src/_tests/fixtures/70222/_downloads.json b/packages/mergebot/src/_tests/fixtures/70222/_downloads.json new file mode 100644 index 0000000000..15e6270477 --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/70222/_downloads.json @@ -0,0 +1,3 @@ +{ + "three": 2288510 +} diff --git a/packages/mergebot/src/_tests/fixtures/70222/_files.json b/packages/mergebot/src/_tests/fixtures/70222/_files.json new file mode 100644 index 0000000000..302034b0ca --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/70222/_files.json @@ -0,0 +1,4 @@ +{ + "3bd3a71c3954ed99b7fcbc61b75b6a455580d8bc:types/three/package.json": "{\n \"private\": true,\n \"name\": \"@types/three\",\n \"version\": \"0.167.9999\",\n \"projects\": [\n \"https://threejs.org/\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./build/three.module.js\",\n \"require\": \"./build/three.cjs\"\n },\n \"./examples/fonts/*\": \"./examples/fonts/*\",\n \"./examples/jsm/*\": \"./examples/jsm/*\",\n \"./addons\": \"./examples/jsm/Addons.js\",\n \"./addons/*\": \"./examples/jsm/*\",\n \"./src/*\": \"./src/*\",\n \"./webgpu\": \"./build/three.webgpu.js\",\n \"./tsl\": \"./build/three.webgpu.js\"\n },\n \"dependencies\": {\n \"@tweenjs/tween.js\": \"~23.1.2\",\n \"@types/stats.js\": \"*\",\n \"@types/webxr\": \"*\",\n \"fflate\": \"~0.8.2\",\n \"meshoptimizer\": \"~0.18.1\"\n },\n \"devDependencies\": {\n \"@types/three\": \"workspace:.\"\n },\n \"owners\": [\n {\n \"name\": \"Josh Ellis\",\n \"githubUsername\": \"joshuaellis\"\n },\n {\n \"name\": \"Nathan Bierema\",\n \"githubUsername\": \"Methuselah96\"\n }\n ]\n}\n", + "2cff400b4bfcd606c7631a97fcc02e8cf14e98df:types/three/package.json": "{\n \"private\": true,\n \"name\": \"@types/three\",\n \"version\": \"0.167.9999\",\n \"projects\": [\n \"https://threejs.org/\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./build/three.module.js\",\n \"require\": \"./build/three.cjs\"\n },\n \"./examples/fonts/*\": \"./examples/fonts/*\",\n \"./examples/jsm/*\": \"./examples/jsm/*\",\n \"./addons\": \"./examples/jsm/Addons.js\",\n \"./addons/*\": \"./examples/jsm/*\",\n \"./src/*\": \"./src/*\",\n \"./webgpu\": \"./build/three.webgpu.js\",\n \"./tsl\": \"./build/three.webgpu.js\"\n },\n \"dependencies\": {\n \"@tweenjs/tween.js\": \"~23.1.2\",\n \"@types/stats.js\": \"*\",\n \"@types/webxr\": \"*\",\n \"fflate\": \"~0.8.2\",\n \"meshoptimizer\": \"~0.18.1\"\n },\n \"devDependencies\": {\n \"@types/three\": \"workspace:.\"\n },\n \"owners\": [\n {\n \"name\": \"Josh Ellis\",\n \"githubUsername\": \"joshuaellis\"\n },\n {\n \"name\": \"Nathan Bierema\",\n \"githubUsername\": \"Methuselah96\"\n }\n ]\n}\n" +} diff --git a/packages/mergebot/src/_tests/fixtures/70222/_response.json b/packages/mergebot/src/_tests/fixtures/70222/_response.json new file mode 100644 index 0000000000..d09c435826 --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/70222/_response.json @@ -0,0 +1,227 @@ +{ + "data": { + "repository": { + "id": "MDEwOlJlcG9zaXRvcnk2MDkzMzE2", + "pullRequest": { + "id": "PR_kwDOAFz6BM53fdQn", + "title": "[three] Add missing WebXRManager type exports", + "createdAt": "2024-08-05T20:01:55Z", + "author": { + "login": "Methuselah96", + "__typename": "User" + }, + "authorAssociation": "CONTRIBUTOR", + "baseRef": { + "name": "master", + "__typename": "Ref" + }, + "labels": { + "nodes": [ + { + "name": "Popular package", + "__typename": "Label" + }, + { + "name": "Author is Owner", + "__typename": "Label" + }, + { + "name": "Untested Change", + "__typename": "Label" + } + ], + "__typename": "LabelConnection" + }, + "isDraft": false, + "mergeable": "MERGEABLE", + "number": 70222, + "state": "OPEN", + "headRefOid": "2cff400b4bfcd606c7631a97fcc02e8cf14e98df", + "changedFiles": 2, + "additions": 12, + "deletions": 0, + "commitIds": { + "nodes": [ + { + "commit": { + "oid": "2cff400b4bfcd606c7631a97fcc02e8cf14e98df", + "parents": { + "nodes": [ + { + "oid": "3bd3a71c3954ed99b7fcbc61b75b6a455580d8bc", + "__typename": "Commit" + } + ], + "__typename": "CommitConnection" + }, + "__typename": "Commit" + }, + "__typename": "PullRequestCommit" + } + ], + "__typename": "PullRequestCommitConnection" + }, + "timelineItems": { + "nodes": [], + "__typename": "PullRequestTimelineItemsConnection" + }, + "reviews": { + "nodes": [], + "__typename": "PullRequestReviewConnection" + }, + "commits": { + "totalCount": 1, + "nodes": [ + { + "commit": { + "checkSuites": { + "nodes": [ + { + "databaseId": 26826814271, + "app": { + "name": "GitHub Actions", + "__typename": "App" + }, + "conclusion": "SUCCESS", + "resourcePath": "/DefinitelyTyped/DefinitelyTyped/commit/2cff400b4bfcd606c7631a97fcc02e8cf14e98df/checks?check_suite_id=26826814271", + "status": "COMPLETED", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/2cff400b4bfcd606c7631a97fcc02e8cf14e98df/checks?check_suite_id=26826814271", + "checkRuns": { + "nodes": [ + { + "title": null, + "__typename": "CheckRun" + } + ], + "__typename": "CheckRunConnection" + }, + "createdAt": "2024-08-05T20:01:59Z", + "workflowRun": { + "file": { + "path": ".github/workflows/CI.yml", + "__typename": "WorkflowRunFile" + }, + "__typename": "WorkflowRun" + }, + "__typename": "CheckSuite" + } + ], + "__typename": "CheckSuiteConnection" + }, + "status": null, + "authoredDate": "2024-08-05T20:01:00Z", + "committedDate": "2024-08-05T20:01:00Z", + "pushedDate": null, + "oid": "2cff400b4bfcd606c7631a97fcc02e8cf14e98df", + "__typename": "Commit" + }, + "__typename": "PullRequestCommit" + } + ], + "__typename": "PullRequestCommitConnection" + }, + "comments": { + "totalCount": 3, + "nodes": [ + { + "id": "IC_kwDOAFz6BM6HSqmn", + "author": { + "login": "typescript-bot", + "__typename": "User" + }, + "databaseId": 2269817255, + "body": "@Methuselah96 Thank you for submitting this PR!\n\n***This is a live comment that I will keep updated.***\n\n## 1 package in this PR\n\n* `three` — [on npm](https://www.npmjs.com/package/three), [on unpkg](https://unpkg.com/browse/three@latest/) (author is owner)\n\n## Code Reviews\n\nThis PR can be merged once it's reviewed by a DT maintainer.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=70222&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 Only a DT maintainer can approve changes [without tests](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-test-editing-an-existing-package)\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n", + "createdAt": "2024-08-05T20:02:30Z", + "reactions": { + "nodes": [], + "__typename": "ReactionConnection" + }, + "__typename": "IssueComment" + }, + { + "id": "IC_kwDOAFz6BM6HSqno", + "author": { + "login": "typescript-bot", + "__typename": "User" + }, + "databaseId": 2269817320, + "body": "Hey @Methuselah96,\n\n:unamused: Your PR doesn't modify any tests, so it's hard to know what's being fixed, and your changes might regress in the future. Please consider [adding tests](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-test-editing-an-existing-package) to cover the change you're making. Including tests allows this PR to be merged by yourself and the owners of this module.\n\n***This can potentially save days of time for you!***\n", + "createdAt": "2024-08-05T20:02:32Z", + "reactions": { + "nodes": [], + "__typename": "ReactionConnection" + }, + "__typename": "IssueComment" + }, + { + "id": "IC_kwDOAFz6BM6HSqn0", + "author": { + "login": "typescript-bot", + "__typename": "User" + }, + "databaseId": 2269817332, + "body": "🔔 @joshuaellis — please [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/70222/files) in the next few days. Be sure to explicitly select **`Approve`** or **`Request Changes`** in the GitHub UI so I know what's going on.\n", + "createdAt": "2024-08-05T20:02:33Z", + "reactions": { + "nodes": [], + "__typename": "ReactionConnection" + }, + "__typename": "IssueComment" + } + ], + "__typename": "IssueCommentConnection" + }, + "files": { + "totalCount": 2, + "nodes": [ + { + "path": "types/three/src/Three.WebGPU.d.ts", + "additions": 6, + "deletions": 0, + "__typename": "PullRequestChangedFile" + }, + { + "path": "types/three/src/Three.d.ts", + "additions": 6, + "deletions": 0, + "__typename": "PullRequestChangedFile" + } + ], + "pageInfo": { + "hasNextPage": false, + "endCursor": "Mg", + "__typename": "PageInfo" + }, + "__typename": "PullRequestChangedFileConnection" + }, + "projectItems": { + "nodes": [ + { + "id": "PVTI_lADOADeBNM4AkH1qzgRi0iU", + "project": { + "id": "PVT_kwDOADeBNM4AkH1q", + "number": 1, + "__typename": "ProjectV2" + }, + "fieldValueByName": { + "name": "Waiting for Code Reviews (Blessed)", + "field": { + "id": "PVTSSF_lADOADeBNM4AkH1qzgcYOEM", + "__typename": "ProjectV2SingleSelectField" + }, + "__typename": "ProjectV2ItemFieldSingleSelectValue" + }, + "updatedAt": "2024-08-07T21:46:24Z", + "__typename": "ProjectV2Item" + } + ], + "__typename": "ProjectV2ItemConnection" + }, + "__typename": "PullRequest" + }, + "__typename": "Repository" + } + }, + "loading": false, + "networkStatus": 7 +} diff --git a/packages/mergebot/src/_tests/fixtures/70222/derived.json b/packages/mergebot/src/_tests/fixtures/70222/derived.json new file mode 100644 index 0000000000..7bcbe8f774 --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/70222/derived.json @@ -0,0 +1,42 @@ +{ + "type": "info", + "now": "2024-08-07T21:46:27.651Z", + "pr_number": 70222, + "author": "Methuselah96", + "headCommitOid": "2cff400b4bfcd606c7631a97fcc02e8cf14e98df", + "mergeBaseOid": "3bd3a71c3954ed99b7fcbc61b75b6a455580d8bc", + "lastPushDate": "2024-08-05T20:01:55.000Z", + "lastActivityDate": "2024-08-05T20:01:55.000Z", + "maintainerBlessed": "Waiting for Code Reviews (Blessed)", + "hasMergeConflict": false, + "isFirstContribution": false, + "tooManyFiles": false, + "hugeChange": false, + "popularityLevel": "Popular", + "pkgInfo": [ + { + "name": "three", + "kind": "edit", + "files": [ + { + "path": "types/three/src/Three.WebGPU.d.ts", + "kind": "definition" + }, + { + "path": "types/three/src/Three.d.ts", + "kind": "definition" + } + ], + "owners": [ + "joshuaellis", + "Methuselah96" + ], + "addedOwners": [], + "deletedOwners": [], + "popularityLevel": "Popular" + } + ], + "reviews": [], + "mainBotCommentID": 2269817255, + "ciResult": "pass" +} diff --git a/packages/mergebot/src/_tests/fixtures/70222/mutations.json b/packages/mergebot/src/_tests/fixtures/70222/mutations.json new file mode 100644 index 0000000000..8541c9eab6 --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/70222/mutations.json @@ -0,0 +1,11 @@ +[ + { + "mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "id": "IC_kwDOAFz6BM6HSqmn", + "body": "@Methuselah96 Thank you for submitting this PR!\n\n***This is a live comment that I will keep updated.***\n\n## 1 package in this PR\n\n* `three` — [on npm](https://www.npmjs.com/package/three), [on unpkg](https://unpkg.com/browse/three@latest/) (author is owner)\n\n## Code Reviews\n\nThis PR can be merged once it's reviewed.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=70222&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 Most recent commit is approved by type definition owners or DT maintainers\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n" + } + } + } +] diff --git a/packages/mergebot/src/_tests/fixtures/70222/result.json b/packages/mergebot/src/_tests/fixtures/70222/result.json new file mode 100644 index 0000000000..6639d5d426 --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/70222/result.json @@ -0,0 +1,25 @@ +{ + "projectColumn": "Waiting for Code Reviews (Blessed)", + "labels": [ + "Popular package", + "Author is Owner", + "Untested Change" + ], + "responseComments": [ + { + "tag": "suggest-testing", + "status": "Hey @Methuselah96,\n\n:unamused: Your PR doesn't modify any tests, so it's hard to know what's being fixed, and your changes might regress in the future. Please consider [adding tests](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-test-editing-an-existing-package) to cover the change you're making. Including tests allows this PR to be merged by yourself and the owners of this module.\n\n***This can potentially save days of time for you!***" + }, + { + "tag": "welcome", + "status": "@Methuselah96 Thank you for submitting this PR!\n\n***This is a live comment that I will keep updated.***\n\n## 1 package in this PR\n\n* `three` — [on npm](https://www.npmjs.com/package/three), [on unpkg](https://unpkg.com/browse/three@latest/) (author is owner)\n\n## Code Reviews\n\nThis PR can be merged once it's reviewed.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=70222&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 Most recent commit is approved by type definition owners or DT maintainers\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ..." + }, + { + "tag": "pinging-reviewers", + "status": "🔔 @joshuaellis — please [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/70222/files) in the next few days. Be sure to explicitly select **`Approve`** or **`Request Changes`** in the GitHub UI so I know what's going on." + } + ], + "shouldClose": false, + "shouldMerge": false, + "shouldUpdateLabels": true +} diff --git a/packages/mergebot/src/basic.ts b/packages/mergebot/src/basic.ts index 8680c2a768..e2806eff8c 100644 --- a/packages/mergebot/src/basic.ts +++ b/packages/mergebot/src/basic.ts @@ -6,8 +6,11 @@ export type ColumnName = | "Needs Author Action" | "Recently Merged" | "Waiting for Code Reviews" + | BlessedColumnName | "*REMOVE*"; // special value: indicates closing the PR +export type BlessedColumnName = "Waiting for Code Reviews (Blessed)"; + export type PopularityLevel = "Well-liked by everyone" | "Popular" | "Critical"; export type StalenessKind = (typeof stalenessKinds)[number]; @@ -50,4 +53,17 @@ export const labelNames = [ export type ApproverKind = "maintainer" | "owner" | "other"; -export type BlessingKind = "merge" | "review" | undefined; +// https://github.com/orgs/DefinitelyTyped/projects/1 +export const projectBoardNumber = 1; + +/** + * The id for the project board, saved statically for inserting new cards. + * you can query this with `projectV2(number: 1) { id }` + */ +export const projectIdStatic = "PVT_kwDOADeBNM4AkH1q"; + +/** + * The id for the Status field, which controls the column that the card appears in. + * This is the statically saved ID, used as a fallback if the field id isn't found dynamically. + */ +export const fieldIdStatic = "PVTSSF_lADOADeBNM4AkH1qzgcYOEM"; diff --git a/packages/mergebot/src/compute-pr-actions.ts b/packages/mergebot/src/compute-pr-actions.ts index 622be97f04..3cce5041b4 100644 --- a/packages/mergebot/src/compute-pr-actions.ts +++ b/packages/mergebot/src/compute-pr-actions.ts @@ -1,4 +1,4 @@ -import { ColumnName, LabelName, StalenessKind, ApproverKind, BlessingKind } from "./basic"; +import { ColumnName, LabelName, StalenessKind, ApproverKind } from "./basic"; import * as Comments from "./comments"; import * as emoji from "./emoji"; import * as urls from "./urls"; @@ -66,7 +66,7 @@ interface ExtendedPrInfo extends PrInfo { readonly approverKind: ApproverKind; readonly requireMaintainer: boolean; readonly blessable: boolean; - readonly blessingKind: BlessingKind; + readonly blessed: boolean; readonly approvedReviews: (ReviewInfo & { type: "approved" })[]; readonly changereqReviews: (ReviewInfo & { type: "changereq" })[]; readonly staleReviews: (ReviewInfo & { type: "stale" })[]; @@ -109,7 +109,7 @@ function extendPrInfo(info: PrInfo): ExtendedPrInfo { const requireMaintainer = possiblyEditsInfra || checkConfig || hasMultiplePackages || isUntested || hasNewPackages || tooManyOwners; const blessable = !(hasNewPackages || possiblyEditsInfra || noOtherOwners); - const blessingKind = getBlessingKind(); + const blessed = blessable && isBlessed(); const approvedReviews = info.reviews.filter((r) => r.type === "approved") as ExtendedPrInfo["approvedReviews"]; const changereqReviews = info.reviews.filter((r) => r.type === "changereq") as ExtendedPrInfo["changereqReviews"]; const staleReviews = info.reviews.filter((r) => r.type === "stale") as ExtendedPrInfo["staleReviews"]; @@ -121,7 +121,7 @@ function extendPrInfo(info: PrInfo): ExtendedPrInfo { const failedCI = info.ciResult === "fail"; const blockedCI = info.ciResult === "action_required"; const ciResult = blockedCI && !possiblyEditsInfra ? "unknown" : info.ciResult; // override ciResult: treated as in-progress if it's approved (blockedCI distinguishes it from real unknown) - const canBeSelfMerged = info.ciResult === "pass" && !info.hasMergeConflict && (approved || blessingKind === "merge"); + const canBeSelfMerged = info.ciResult === "pass" && !info.hasMergeConflict && approved; const hasValidMergeRequest = !!( info.mergeOfferDate && info.mergeRequestDate && @@ -150,7 +150,7 @@ function extendPrInfo(info: PrInfo): ExtendedPrInfo { approverKind, requireMaintainer, blessable, - blessingKind, + blessed, failedCI, blockedCI, ciResult, @@ -198,12 +198,8 @@ function extendPrInfo(info: PrInfo): ExtendedPrInfo { return undefined; } - function getBlessingKind() { - return info.maintainerBlessed === "Waiting for Author to Merge" - ? "merge" - : info.maintainerBlessed === "Waiting for Code Reviews" - ? "review" - : undefined; + function isBlessed(): boolean { + return info.maintainerBlessed === "Waiting for Code Reviews (Blessed)"; } function getApprovedBy() { @@ -225,7 +221,6 @@ function extendPrInfo(info: PrInfo): ExtendedPrInfo { } function getApproverKind() { - const blessed = blessable && blessingKind === "review"; const who: ApproverKind = requireMaintainer ? "maintainer" : ( @@ -250,11 +245,10 @@ function extendPrInfo(info: PrInfo): ExtendedPrInfo { function getReviewColumn(): ColumnName { // Get the project column for review with least access // E.g. let people review, but fall back to the DT maintainers based on the access rights above - return approverKind !== "maintainer" - ? "Waiting for Code Reviews" - : blessable - ? "Needs Maintainer Review" - : "Needs Maintainer Action"; + return blessed ? "Waiting for Code Reviews (Blessed)" + : approverKind !== "maintainer" ? "Waiting for Code Reviews" + : blessable ? "Needs Maintainer Review" + : "Needs Maintainer Action"; } } @@ -565,12 +559,10 @@ function createWelcomeComment(info: ExtendedPrInfo, post: (c: Comments.Comment) // Lets the author know who needs to review this display(``, `## Code Reviews`, ``); - if (info.blessingKind === "merge") { - display("This PR can be merged."); - } else if (info.hasNewPackages) { + if (info.hasNewPackages) { display(txt`This PR adds a new definition, so it needs to be reviewed by ${requiredApproverLower} before it can be merged.`); - } else if (info.popularityLevel === "Critical" && info.blessingKind !== "review") { + } else if (info.popularityLevel === "Critical" && !info.blessed) { display(txt`Because this is a widely-used package, ${requiredApproverLower} will need to review it before it can be merged.`); } else if (!info.requireMaintainer) { @@ -578,7 +570,7 @@ function createWelcomeComment(info: ExtendedPrInfo, post: (c: Comments.Comment) info.hasDefinitions && info.hasTests ? "and updated the tests (👏)" : "and there were no type definition changes"; display(txt`Because you edited one package ${and}, I can help you merge this PR once someone else signs off on it.`); - } else if (info.blessingKind === "review") { + } else if (info.blessed) { display("This PR can be merged once it's reviewed."); } else { if (info.noOtherOwners) { @@ -608,7 +600,7 @@ function createWelcomeComment(info: ExtendedPrInfo, post: (c: Comments.Comment) display(` * ${result.emoji} Continuous integration tests ${result.text}`); } - const approved = emoji.pending(!(info.approved || info.blessingKind === "merge")); + const approved = emoji.pending(!info.approved); if (info.hasNewPackages) { display(` * ${approved} Only ${requiredApproverLower} can approve changes when there are new packages added`); @@ -618,7 +610,7 @@ function createWelcomeComment(info: ExtendedPrInfo, post: (c: Comments.Comment) display( ` * ${approved} ${requiredApproverUpper} needs to approve changes that affect DT infrastructure (${links.join(", ")})`, ); - } else if (criticalNum > 1 && info.blessingKind === "review") { + } else if (criticalNum > 1 && info.blessed) { display(` * ${approved} ${requiredApproverUpper} needs to approve changes that affect more than one package`); for (const p of info.pkgInfo) { if (!(p.name && p.popularityLevel === "Critical")) continue; @@ -626,7 +618,7 @@ function createWelcomeComment(info: ExtendedPrInfo, post: (c: Comments.Comment) } } else if (info.hasMultiplePackages) { display(` * ${approved} ${requiredApproverUpper} needs to approve changes that affect more than one package`); - } else if (!info.requireMaintainer || info.blessingKind === "review") { + } else if (!info.requireMaintainer || info.blessed) { display(` * ${approved} Most recent commit is approved by ${requiredApproverLower}`); } else if (info.noOtherOwners) { display(` * ${approved} ${requiredApproverUpper} can merge changes when there are no other reviewers`); diff --git a/packages/mergebot/src/execute-pr-actions.ts b/packages/mergebot/src/execute-pr-actions.ts index 0a3238e351..7848b20ef4 100644 --- a/packages/mergebot/src/execute-pr-actions.ts +++ b/packages/mergebot/src/execute-pr-actions.ts @@ -1,4 +1,4 @@ -import { LabelName, labelNames } from "./basic"; +import { fieldIdStatic, LabelName, labelNames, projectBoardNumber, projectIdStatic } from "./basic"; import { MutationOptions } from "@apollo/client/core"; import * as schema from "@octokit/graphql-schema/schema"; import { PR_repository_pullRequest } from "./queries/schema/PR"; @@ -11,19 +11,6 @@ import * as comment from "./util/comment"; import { request } from "https"; import { assertDefined } from "@definitelytyped/utils"; -// https://github.com/orgs/DefinitelyTyped/projects/1 -const projectBoardNumber = 1; -/** - * The id for the project board, saved statically for inserting new cards. - * you can query this with `projectV2(number: 1) { id }` - */ -const projectIdStatic = "PVT_kwDOADeBNM4AkH1q"; -/** - * The id for the Status field, which controls the column that the card appears in. - * This is the statically saved ID, used as a fallback if the field id isn't found dynamically. - */ -const fieldIdStatic = "PVTSSF_lADOADeBNM4AkH1qzgcYOEM"; - export async function executePrActions( actions: Actions, pr: PR_repository_pullRequest, diff --git a/packages/mergebot/src/pr-info.ts b/packages/mergebot/src/pr-info.ts index 75d4a90b57..026ad161bd 100644 --- a/packages/mergebot/src/pr-info.ts +++ b/packages/mergebot/src/pr-info.ts @@ -1,4 +1,4 @@ -import { ColumnName, PopularityLevel } from "./basic"; +import { BlessedColumnName, ColumnName, PopularityLevel, projectBoardNumber } from "./basic"; import { PR_repository_pullRequest, PR_repository_pullRequest_commits_nodes_commit_checkSuites, @@ -118,7 +118,7 @@ export interface PrInfo { /** * Name of column used if a maintainer blessed this PR */ - readonly maintainerBlessed?: ColumnName; + readonly maintainerBlessed?: BlessedColumnName; /** * The time we posted a merge offer, if any (required for merge request in addition to passing CI and a review) @@ -201,7 +201,7 @@ export async function deriveStateForPR( // (it would be bad to use `committedDate`/`authoredDate`, since these can be set to arbitrary values) const lastPushDate = new Date(headCommit.pushedDate || prInfo.createdAt); const lastCommentDate = getLastCommentishActivityDate(prInfo); - const blessing = getLastMaintainerBlessing(lastPushDate, prInfo.timelineItems); + const blessing = getLastMaintainerBlessing(lastPushDate, prInfo); const reopenedDate = getReopenedDate(prInfo.timelineItems); // we should generally have all files (except for draft PRs) const fileCount = prInfo.changedFiles; @@ -302,13 +302,35 @@ function getLastCommentishActivityDate(prInfo: PR_repository_pullRequest) { return max([...latestIssueCommentDate, ...latestReviewCommentDate]); } -function getLastMaintainerBlessing(after: Date, timelineItems: PR_repository_pullRequest_timelineItems) { +function getLastMaintainerBlessing(after: Date, pr: PR_repository_pullRequest): { date: Date | undefined; column: BlessedColumnName } | undefined { + const card = pr.projectItems.nodes?.find((card) => card?.project.number === projectBoardNumber); + const columnName = + card?.fieldValueByName?.__typename === "ProjectV2ItemFieldSingleSelectValue" && card.fieldValueByName.name; + if (columnName === "Waiting for Code Reviews (Blessed)" && card?.updatedAt) { + // Normally relying on the updatedAt of the card is not reliable, but in this case it's fine + // becuase the bot will never move the card into the blessed state, only out of it. + // If the card is already in a blessed state, the bot will not mutate the card. + const d = new Date(card.updatedAt); + if (d <= after) return undefined; + return { date: undefined, column: columnName }; + } + + // This doesn't work with the Projects V2, but is needed for old tests. + // If V2 ever adds an API for this, we should drop the special "blessed" column above + // and just reuse the below. + // https://github.com/orgs/community/discussions/49602 + // https://github.com/orgs/community/discussions/57326 + const timelineItems = pr.timelineItems; return ( someLast(timelineItems.nodes, (item) => { if (!(item.__typename === "MovedColumnsInProjectEvent" && authorNotBot(item))) return undefined; const d = new Date(item.createdAt); if (d <= after) return undefined; - return { date: d, column: item.projectColumnName as ColumnName }; + const columnName = item.projectColumnName as ColumnName; + if (columnName === "Waiting for Code Reviews") { + return { date: d, column: "Waiting for Code Reviews (Blessed)" }; + } + return undefined; }) || undefined ); } diff --git a/packages/mergebot/src/queries/pr-query.ts b/packages/mergebot/src/queries/pr-query.ts index 0c6dace1c7..c0df32673b 100644 --- a/packages/mergebot/src/queries/pr-query.ts +++ b/packages/mergebot/src/queries/pr-query.ts @@ -194,6 +194,7 @@ const getPRInfoQueryFirst: TypedDocumentNode = gql` } } } + updatedAt } } } diff --git a/packages/mergebot/src/queries/schema/PR.ts b/packages/mergebot/src/queries/schema/PR.ts index bf91711eb9..2533866481 100644 --- a/packages/mergebot/src/queries/schema/PR.ts +++ b/packages/mergebot/src/queries/schema/PR.ts @@ -573,6 +573,10 @@ export interface PR_repository_pullRequest_projectItems_nodes { * The field value of the first project field which matches the 'name' argument that is set on the item. */ fieldValueByName: PR_repository_pullRequest_projectItems_nodes_fieldValueByName | null; + /** + * Identifies the date and time when the object was last updated. + */ + updatedAt: any; } export interface PR_repository_pullRequest_projectItems {