Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Avoid redundant pings #367

Merged
merged 2 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/_tests/fixtures/43695-duplicate-comment/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"variables": {
"input": {
"subjectId": "MDExOlB1bGxSZXF1ZXN0NDAwMTAwMTk2",
"body": "It has been more than two weeks and this PR still has no reviews.\n\nI'll bump it to the DT maintainer queue. Thank you for your patience, @alexandercerutti.\n\n(Ping «anyone?».)\n<!--typescript_bot_Unreviewed:done-->"
"body": "It has been more than two weeks and this PR still has no reviews.\n\nI'll bump it to the DT maintainer queue. Thank you for your patience, @alexandercerutti.\n\n(Ping @«anyone?».)\n<!--typescript_bot_Unreviewed:done-->"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/_tests/fixtures/43695-duplicate-comment/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
{
"tag": "Unreviewed:done",
"status": "It has been more than two weeks and this PR still has no reviews.\n\nI'll bump it to the DT maintainer queue. Thank you for your patience, @alexandercerutti.\n\n(Ping «anyone?».)"
"status": "It has been more than two weeks and this PR still has no reviews.\n\nI'll bump it to the DT maintainer queue. Thank you for your patience, @alexandercerutti.\n\n(Ping @«anyone?».)"
}
],
"shouldClose": false,
Expand Down
2 changes: 1 addition & 1 deletion src/_tests/fixtures/44989-14days/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"variables": {
"input": {
"subjectId": "MDExOlB1bGxSZXF1ZXN0NDIyMDc5Mjk3",
"body": "Re-ping @petr-motejlek / @TheHandsomeCoder, @donnut, @mdekrey, @sbking, @afharo, @teves-castro, @1M0reBug, @hojberg, @samsonkeung, @angeloocana, @raynerd, @moshensky, @ethanresnick, @deftomat, @blimusiek, @biern, @rayhaneh, @rgm, @drewwyatt, @jottenlips, @minitesh, @krantisinh, @pirix-gh, @brekk, @nemo108, @jituanlin, @Philippe-mills, @Saul-Mirone, @Nicholaiii:\n\nThis PR has been ready to merge for over a week, and I haven't seen any requests to merge it. I will close it on Jun 22nd (in three weeks) if this doesn't happen.\n\n(If there's no reason to avoid merging it, please do so. Otherwise, if it shouldn't be merged or if it needs more time, please close it or turn it into a draft.)\n<!--typescript_bot_Unmerged:nearly:2020-05-23-->"
"body": "Re-ping @petr-motejlek / @TheHandsomeCoder, @donnut, @mdekrey, @sbking, @afharo, @teves-castro, @1M0reBug, @hojberg, @samsonkeung, @angeloocana, @raynerd, @moshensky, @ethanresnick, @deftomat, @blimusiek, @biern, @rayhaneh, @rgm, @drewwyatt, @jottenlips, @minitesh, @krantisinh, @pirix-gh, @brekk, @nemo108, @jituanlin, @Philippe-mills, @Saul-Mirone:\n\nThis PR has been ready to merge for over a week, and I haven't seen any requests to merge it. I will close it on Jun 22nd (in three weeks) if this doesn't happen.\n\n(If there's no reason to avoid merging it, please do so. Otherwise, if it shouldn't be merged or if it needs more time, please close it or turn it into a draft.)\n<!--typescript_bot_Unmerged:nearly:2020-05-23-->"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/_tests/fixtures/44989-14days/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
{
"tag": "Unmerged:nearly:2020-05-23",
"status": "Re-ping @petr-motejlek / @TheHandsomeCoder, @donnut, @mdekrey, @sbking, @afharo, @teves-castro, @1M0reBug, @hojberg, @samsonkeung, @angeloocana, @raynerd, @moshensky, @ethanresnick, @deftomat, @blimusiek, @biern, @rayhaneh, @rgm, @drewwyatt, @jottenlips, @minitesh, @krantisinh, @pirix-gh, @brekk, @nemo108, @jituanlin, @Philippe-mills, @Saul-Mirone, @Nicholaiii:\n\nThis PR has been ready to merge for over a week, and I haven't seen any requests to merge it. I will close it on Jun 22nd (in three weeks) if this doesn't happen.\n\n(If there's no reason to avoid merging it, please do so. Otherwise, if it shouldn't be merged or if it needs more time, please close it or turn it into a draft.)"
"status": "Re-ping @petr-motejlek / @TheHandsomeCoder, @donnut, @mdekrey, @sbking, @afharo, @teves-castro, @1M0reBug, @hojberg, @samsonkeung, @angeloocana, @raynerd, @moshensky, @ethanresnick, @deftomat, @blimusiek, @biern, @rayhaneh, @rgm, @drewwyatt, @jottenlips, @minitesh, @krantisinh, @pirix-gh, @brekk, @nemo108, @jituanlin, @Philippe-mills, @Saul-Mirone:\n\nThis PR has been ready to merge for over a week, and I haven't seen any requests to merge it. I will close it on Jun 22nd (in three weeks) if this doesn't happen.\n\n(If there's no reason to avoid merging it, please do so. Otherwise, if it shouldn't be merged or if it needs more time, please close it or turn it into a draft.)"
}
],
"shouldClose": false,
Expand Down
2 changes: 1 addition & 1 deletion src/_tests/fixtures/49548/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"variables": {
"input": {
"subjectId": "MDExOlB1bGxSZXF1ZXN0NTIwODA1MjIx",
"body": "Re-ping «anyone?»:\n\nThis PR has been out for over a week, yet I haven't seen any reviews.\n\nCould someone please give it some attention? Thanks!\n<!--typescript_bot_Unreviewed:nearly:2020-11-16-->"
"body": "Re-ping @«anyone?»:\n\nThis PR has been out for over a week, yet I haven't seen any reviews.\n\nCould someone please give it some attention? Thanks!\n<!--typescript_bot_Unreviewed:nearly:2020-11-16-->"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/_tests/fixtures/49548/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"tag": "Unreviewed:nearly:2020-11-16",
"status": "Re-ping «anyone?»:\n\nThis PR has been out for over a week, yet I haven't seen any reviews.\n\nCould someone please give it some attention? Thanks!"
"status": "Re-ping @«anyone?»:\n\nThis PR has been out for over a week, yet I haven't seen any reviews.\n\nCould someone please give it some attention? Thanks!"
}
],
"shouldClose": false,
Expand Down
3 changes: 3 additions & 0 deletions src/_tests/fixtures/51338/_downloads.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"koa": 5708514
}
6 changes: 6 additions & 0 deletions src/_tests/fixtures/51338/_files.json

Large diffs are not rendered by default.

306 changes: 306 additions & 0 deletions src/_tests/fixtures/51338/_response.json

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions src/_tests/fixtures/51338/derived.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"type": "info",
"now": "2021-03-02T21:43:39.396Z",
"pr_number": 51338,
"author": "pkuczynski",
"headCommitOid": "4a7712f61d17eb33e89171f317deeb31b3d555ae",
"lastPushDate": "2021-02-19T17:22:27.000Z",
"lastActivityDate": "2021-02-20T14:48:26.000Z",
"maintainerBlessed": false,
"hasMergeConflict": false,
"isFirstContribution": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "koa",
"kind": "edit",
"files": [
{
"path": "types/koa/index.d.ts",
"kind": "definition"
},
{
"path": "types/koa/tsconfig.json",
"kind": "package-meta",
"suspect": "not [the expected form](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-tsconfigjson) and not moving towards it"
}
],
"owners": [
"DavidCai1993",
"jkeylu",
"brikou",
"harryparkdotio",
"chatoo2412",
"tellnes",
"pkuczynski"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "tellnes",
"date": "2021-02-20T14:48:26.000Z",
"isMaintainer": false
}
],
"ciResult": "pass"
}
31 changes: 31 additions & 0 deletions src/_tests/fixtures/51338/mutations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
{
"mutation": "mutation ($input: AddLabelsToLabelableInput!) {\n addLabelsToLabelable(input: $input) {\n __typename\n }\n}\n",
"variables": {
"input": {
"labelIds": [
"MDU6TGFiZWwyNDYyODA0MzE1"
],
"labelableId": "MDExOlB1bGxSZXF1ZXN0NTc2NTk4OTQ2"
}
}
},
{
"mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n",
"variables": {
"input": {
"id": "MDEyOklzc3VlQ29tbWVudDc4MjIxMzI4Nw==",
"body": "@pkuczynski Thank you for submitting this PR!\n\n***This is a live comment which I will keep updated.***\n\n## 1 package in this PR\n\n* `koa` [on npm](https://www.npmjs.com/package/koa), [on unpkg](https://unpkg.com/browse/koa@latest/) (author is owner)\n - owner-approval: @tellnes\n - Config files to check:\n - [`koa/tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/51338/files/4a7712f61d17eb33e89171f317deeb31b3d555ae#diff-1730c5405d0220a98f28feeec2de3f5a511ebc6a04ceadf12415b81de841672e): not [the expected form](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-tsconfigjson) and not moving towards it\n\n## Code Reviews\n\nBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged.\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * ❌ A DT maintainer needs to approve changes which affect module config files\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n## Inactive\n\nThis PR has been inactive for 11 days — please try to get reviewers!\n\n----------------------\n... diagnostics scrubbed ...\n<!--typescript_bot_welcome-->"
}
}
},
{
"mutation": "mutation ($input: AddCommentInput!) {\n addComment(input: $input) {\n __typename\n }\n}\n",
"variables": {
"input": {
"subjectId": "MDExOlB1bGxSZXF1ZXN0NTc2NTk4OTQ2",
"body": "Re-ping @DavidCai1993, @jkeylu, @brikou, @harryparkdotio, @chatoo2412:\n\nThis PR has been out for over a week, yet I haven't seen any reviews.\n\nCould someone please give it some attention? Thanks!\n<!--typescript_bot_Unreviewed:nearly:2021-02-19-->"
}
}
}
]
28 changes: 28 additions & 0 deletions src/_tests/fixtures/51338/result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"projectColumn": "Needs Maintainer Review",
"labels": [
"Critical package",
"Owner Approved",
"Author is Owner",
"Check Config",
"Untested Change",
"Unreviewed"
],
"responseComments": [
{
"tag": "suggest-testing",
"status": "Hey @pkuczynski,\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. This can potentially save days of time for you."
},
{
"tag": "welcome",
"status": "@pkuczynski Thank you for submitting this PR!\n\n***This is a live comment which I will keep updated.***\n\n## 1 package in this PR\n\n* `koa` [on npm](https://www.npmjs.com/package/koa), [on unpkg](https://unpkg.com/browse/koa@latest/) (author is owner)\n - owner-approval: @tellnes\n - Config files to check:\n - [`koa/tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/51338/files/4a7712f61d17eb33e89171f317deeb31b3d555ae#diff-1730c5405d0220a98f28feeec2de3f5a511ebc6a04ceadf12415b81de841672e): not [the expected form](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-tsconfigjson) and not moving towards it\n\n## Code Reviews\n\nBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged.\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * ❌ A DT maintainer needs to approve changes which affect module config files\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n## Inactive\n\nThis PR has been inactive for 11 days — please try to get reviewers!\n\n----------------------\n... diagnostics scrubbed ..."
},
{
"tag": "Unreviewed:nearly:2021-02-19",
"status": "Re-ping @DavidCai1993, @jkeylu, @brikou, @harryparkdotio, @chatoo2412:\n\nThis PR has been out for over a week, yet I haven't seen any reviews.\n\nCould someone please give it some attention? Thanks!"
}
],
"shouldClose": false,
"shouldMerge": false,
"shouldUpdateLabels": true
}
10 changes: 5 additions & 5 deletions src/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ export const StalenessExplanations: { [k: string]: string } = {
};

// Comments to post for the staleness timeline (the tag is computed in `makeStaleness`)
export const StalenessComment = (author: string, otherOwners: string[], expires: string) => {
const owners = otherOwners.length === 0 ? "«anyone?»" : otherOwners.map(o => "@"+o).join(", ");
export const StalenessComment = (author: string, ownersToPing: string[], expires: string) => {
const ownerPing = ownersToPing.map(o => "@"+o).join(", ");
return {
// --Unmerged--
"Unmerged:nearly": `Re-ping @${author} / ${owners}:
"Unmerged:nearly": `Re-ping @${author} / ${ownerPing}:

This PR has been ready to merge for over a week, and I haven't seen any requests to merge it. I will close it on ${expires} (in three weeks) if this doesn't happen.

Expand All @@ -111,7 +111,7 @@ This PR has been ready to merge for over a week, and I haven't seen any requests
"Abandoned:nearly": `@${author} I haven't seen any activity on this PR in more than three weeks, and it still has problems that prevent it from being merged. The PR will be closed on ${expires} (in a week) if the issues aren't addressed.`,
"Abandoned:done": `@${author} To keep things tidy, we have to close PRs that aren't mergeable and don't have activity in the last month. No worries, though — please open a new PR if you'd like to continue with this change. Thank you!`,
// --Unreviewed--
"Unreviewed:nearly": `Re-ping ${owners}:
"Unreviewed:nearly": `Re-ping ${ownerPing}:

This PR has been out for over a week, yet I haven't seen any reviews.

Expand All @@ -120,5 +120,5 @@ Could someone please give it some attention? Thanks!`,

I'll bump it to the DT maintainer queue. Thank you for your patience, @${author}.

(Ping ${owners}.)`} as { [k: string]: string };
(Ping ${ownerPing}.)`} as { [k: string]: string };
};
8 changes: 5 additions & 3 deletions src/compute-pr-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ function extendPrInfo(info: PrInfo): ExtendedPrInfo {

// Staleness timeline configurations (except for texts that are all in `comments.ts`)
function getStaleness() {
const mkStaleness = makeStaleness(info.now, info.author, otherOwners);
const ownersToPing = otherOwners.length === 0 ? ["«anyone?»"]
: otherOwners.filter(o => !approvedReviews.some(r => o === r.reviewer));
const mkStaleness = makeStaleness(info.now, info.author, ownersToPing);
if (canBeSelfMerged && info.mergeOfferDate) return mkStaleness(
"Unmerged", info.mergeOfferDate, 4, 9, 30, "CLOSE");
if (needsAuthorAction) return mkStaleness(
Expand Down Expand Up @@ -351,7 +353,7 @@ export function process(prInfo: BotResult,
return actions;
}

function makeStaleness(now: Date, author: string, otherOwners: string[]) { // curried for convenience
function makeStaleness(now: Date, author: string, ownersToPing: string[]) { // curried for convenience
return (kind: StalenessKind, since: Date,
freshDays: number, attnDays: number, nearDays: number,
doneColumn: ColumnName | "CLOSE") => {
Expand All @@ -360,7 +362,7 @@ function makeStaleness(now: Date, author: string, otherOwners: string[]) { // cu
const kindAndState = `${kind}:${state}`;
const explanation = Comments.StalenessExplanations[kindAndState];
const expires = dayjs(since).add(nearDays, "days").format("MMM Do");
const comment = Comments.StalenessComment(author, otherOwners, expires)[kindAndState];
const comment = Comments.StalenessComment(author, ownersToPing, expires)[kindAndState];
const doTimelineActions = (actions: Actions) => {
if (comment !== undefined) {
const tag = state === "done" ? kindAndState
Expand Down