diff --git a/packages/mergebot/src/_tests/fixtures/74980/_downloads.json b/packages/mergebot/src/_tests/fixtures/74980/_downloads.json new file mode 100644 index 0000000000..01bd38c59c --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/74980/_downloads.json @@ -0,0 +1,3 @@ +{ + "bluebird": 10914323 +} diff --git a/packages/mergebot/src/_tests/fixtures/74980/_files.json b/packages/mergebot/src/_tests/fixtures/74980/_files.json new file mode 100644 index 0000000000..1eca57c245 --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/74980/_files.json @@ -0,0 +1,4 @@ +{ + "c6d1344b3c7e49f62f4befd1aaa8665eb6bd6864:types/bluebird/package.json": "{\n \"private\": true,\n \"name\": \"@types/bluebird\",\n \"version\": \"3.5.9999\",\n \"projects\": [\n \"https://github.com/petkaantonov/bluebird\"\n ],\n \"devDependencies\": {\n \"@types/bluebird\": \"workspace:.\"hjhbjkbkvhjc\n },\n \"owners\": xe[\n {\n \"name\": \"Leonard Hecker\",\n \"githubUsername\": \"lhecker\"\n }\n ]\n}\n", + "84efd8820459db1cdaad122f2347683b7db023ee:types/bluebird/package.json": "{\n \"private\": true,\n \"name\": \"@types/bluebird\",\n \"version\": \"3.5.9999\",\n \"projects\": [\n \"https://github.com/petkaantonov/bluebird\"\n ],\n \"devDependencies\": {\n \"@types/bluebird\": \"workspace:.\"\n },\n \"owners\": [\n {\n \"name\": \"Leonard Hecker\",\n \"githubUsername\": \"lhecker\"\n }\n ]\n}\n" +} diff --git a/packages/mergebot/src/_tests/fixtures/74980/_response.json b/packages/mergebot/src/_tests/fixtures/74980/_response.json new file mode 100644 index 0000000000..35954ba288 --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/74980/_response.json @@ -0,0 +1,139 @@ +{ + "data": { + "repository": { + "id": "MDEwOlJlcG9zaXRvcnk2MDkzMzE2", + "pullRequest": { + "id": "PR_kwDOAFz6BM7aQ8jd", + "title": "just Update package.json", + "createdAt": "2026-05-11T13:20:01Z", + "author": { + "login": "justinkrn68-droid", + "__typename": "User" + }, + "authorAssociation": "FIRST_TIME_CONTRIBUTOR", + "baseRef": { + "name": "master", + "__typename": "Ref" + }, + "labels": { + "nodes": [], + "__typename": "LabelConnection" + }, + "isDraft": false, + "mergeable": "MERGEABLE", + "number": 74980, + "state": "OPEN", + "headRefOid": "c6d1344b3c7e49f62f4befd1aaa8665eb6bd6864", + "baseRefOid": "84efd8820459db1cdaad122f2347683b7db023ee", + "changedFiles": 1, + "additions": 2, + "deletions": 2, + "commitIds": { + "totalCount": 1, + "nodes": [ + { + "commit": { + "oid": "c6d1344b3c7e49f62f4befd1aaa8665eb6bd6864", + "parents": { + "nodes": [ + { + "oid": "84efd8820459db1cdaad122f2347683b7db023ee", + "__typename": "Commit" + } + ], + "__typename": "CommitConnection" + }, + "__typename": "Commit" + }, + "__typename": "PullRequestCommit" + } + ], + "__typename": "PullRequestCommitConnection" + }, + "timelineItems": { + "nodes": [], + "__typename": "PullRequestTimelineItemsConnection" + }, + "reviews": { + "totalCount": 0, + "nodes": [], + "__typename": "PullRequestReviewConnection" + }, + "commits": { + "totalCount": 1, + "nodes": [ + { + "commit": { + "checkSuites": { + "nodes": [ + { + "databaseId": 68415365071, + "app": { + "name": "GitHub Actions", + "__typename": "App" + }, + "conclusion": "ACTION_REQUIRED", + "resourcePath": "/DefinitelyTyped/DefinitelyTyped/commit/c6d1344b3c7e49f62f4befd1aaa8665eb6bd6864/checks?check_suite_id=68415365071", + "status": "COMPLETED", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/c6d1344b3c7e49f62f4befd1aaa8665eb6bd6864/checks?check_suite_id=68415365071", + "checkRuns": { + "nodes": [], + "__typename": "CheckRunConnection" + }, + "createdAt": "2026-05-11T13:20:11Z", + "workflowRun": { + "file": { + "path": ".github/workflows/CI.yml", + "__typename": "WorkflowRunFile" + }, + "__typename": "WorkflowRun" + }, + "__typename": "CheckSuite" + } + ], + "__typename": "CheckSuiteConnection" + }, + "status": null, + "authoredDate": "2026-05-11T13:19:36Z", + "committedDate": "2026-05-11T13:19:36Z", + "pushedDate": null, + "oid": "c6d1344b3c7e49f62f4befd1aaa8665eb6bd6864", + "__typename": "Commit" + }, + "__typename": "PullRequestCommit" + } + ], + "__typename": "PullRequestCommitConnection" + }, + "comments": { + "totalCount": 0, + "nodes": [], + "__typename": "IssueCommentConnection" + }, + "files": { + "totalCount": 1, + "nodes": [ + { + "path": "types/bluebird/package.json", + "additions": 2, + "deletions": 2, + "__typename": "PullRequestChangedFile" + } + ], + "pageInfo": { + "hasNextPage": false, + "endCursor": "MQ", + "__typename": "PageInfo" + }, + "__typename": "PullRequestChangedFileConnection" + }, + "projectItems": { + "nodes": [], + "__typename": "ProjectV2ItemConnection" + }, + "__typename": "PullRequest" + }, + "__typename": "Repository" + } + } +} diff --git a/packages/mergebot/src/_tests/fixtures/74980/derived.json b/packages/mergebot/src/_tests/fixtures/74980/derived.json new file mode 100644 index 0000000000..5bacda6149 --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/74980/derived.json @@ -0,0 +1,41 @@ +{ + "type": "info", + "now": "2026-06-09T18:11:33.900Z", + "pr_number": 74980, + "author": "justinkrn68-droid", + "headCommitOid": "c6d1344b3c7e49f62f4befd1aaa8665eb6bd6864", + "mergeBaseOid": "84efd8820459db1cdaad122f2347683b7db023ee", + "lastPushDate": "2026-05-11T13:20:01.000Z", + "lastActivityDate": "2026-05-11T13:20:01.000Z", + "hasMergeConflict": false, + "isFirstContribution": true, + "tooManyFiles": false, + "hugeChange": false, + "tooManyCommits": false, + "tooManyReviews": false, + "popularityLevel": "Critical", + "pkgInfo": [ + { + "name": "bluebird", + "kind": "edit", + "files": [ + { + "path": "types/bluebird/package.json", + "kind": "package-meta", + "suspect": "couldn't parse json" + } + ], + "owners": [ + "lhecker" + ], + "addedOwners": [], + "deletedOwners": [], + "popularityLevel": "Critical" + } + ], + "reviews": [], + "ciResult": "action_required", + "reRunCheckSuiteIDs": [ + 68415365071 + ] +} diff --git a/packages/mergebot/src/_tests/fixtures/74980/mutations.json b/packages/mergebot/src/_tests/fixtures/74980/mutations.json new file mode 100644 index 0000000000..aa7dadc76b --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/74980/mutations.json @@ -0,0 +1,68 @@ +[ + { + "mutation": "mutation ($input: AddCommentInput!) {\n addComment(input: $input) {\n __typename\n }\n}", + "variables": { + "input": { + "subjectId": "PR_kwDOAFz6BM7aQ8jd", + "body": "@justinkrn68-droid 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\n## 1 package in this PR\n\n* `bluebird` — [on npm](https://www.npmjs.com/package/bluebird), [on unpkg](https://unpkg.com/browse/bluebird@latest/)\n - Config files to check:\n - [`bluebird/package.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/74980/files/c6d1344b3c7e49f62f4befd1aaa8665eb6bd6864#diff-a7758061c91486db4772fdf646baf1596c98b99a50204a6b3185b4a7e021fb9f): couldn't parse json\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\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=74980&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 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 29 days — it is *still* unreviewed!\n\n----------------------\n... diagnostics scrubbed ...\n" + } + } + }, + { + "mutation": "mutation ($input: AddLabelsToLabelableInput!) {\n addLabelsToLabelable(input: $input) {\n __typename\n }\n}", + "variables": { + "input": { + "labelIds": [ + "MDU6TGFiZWwxNjA4NjM0NDg0", + "MDU6TGFiZWwyMTU0ODE2NTQ5", + "MDU6TGFiZWwyNDYyODA0MzE1" + ], + "labelableId": "PR_kwDOAFz6BM7aQ8jd" + } + } + }, + { + "mutation": "mutation ($input: AddProjectV2ItemByIdInput!) {\n addProjectV2ItemById(input: $input) {\n __typename\n item {\n id\n }\n }\n}", + "variables": { + "input": { + "contentId": "PR_kwDOAFz6BM7aQ8jd", + "projectId": "PVT_kwDOADeBNM4AkH1q" + } + } + }, + { + "mutation": "mutation ($input: UpdateProjectV2ItemFieldValueInput!) {\n updateProjectV2ItemFieldValue(input: $input) {\n __typename\n }\n}", + "variables": { + "input": { + "itemId": "TEST", + "projectId": "PVT_kwDOADeBNM4AkH1q", + "fieldId": "PVTSSF_lADOADeBNM4AkH1qzgcYOEM", + "value": { + "singleSelectOptionId": "f75ad846" + } + } + } + }, + { + "mutation": "mutation ($input: AddCommentInput!) {\n addComment(input: $input) {\n __typename\n }\n}", + "variables": { + "input": { + "subjectId": "PR_kwDOAFz6BM7aQ8jd", + "body": "🔔 @lhecker — please [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/74980/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" + } + } + }, + { + "mutation": "mutation ($input: AddCommentInput!) {\n addComment(input: $input) {\n __typename\n }\n}", + "variables": { + "input": { + "subjectId": "PR_kwDOAFz6BM7aQ8jd", + "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, @justinkrn68-droid.\n\n(Ping @lhecker.)\n" + } + } + }, + { + "method": "POST", + "op": "check-suites/68415365071/rerequest" + } +] diff --git a/packages/mergebot/src/_tests/fixtures/74980/result.json b/packages/mergebot/src/_tests/fixtures/74980/result.json new file mode 100644 index 0000000000..de644e0a48 --- /dev/null +++ b/packages/mergebot/src/_tests/fixtures/74980/result.json @@ -0,0 +1,28 @@ +{ + "projectColumn": "Needs Maintainer Action", + "labels": [ + "Critical package", + "Check Config", + "Unreviewed" + ], + "responseComments": [ + { + "tag": "welcome", + "status": "@justinkrn68-droid 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\n## 1 package in this PR\n\n* `bluebird` — [on npm](https://www.npmjs.com/package/bluebird), [on unpkg](https://unpkg.com/browse/bluebird@latest/)\n - Config files to check:\n - [`bluebird/package.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/74980/files/c6d1344b3c7e49f62f4befd1aaa8665eb6bd6864#diff-a7758061c91486db4772fdf646baf1596c98b99a50204a6b3185b4a7e021fb9f): couldn't parse json\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\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=74980&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 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 29 days — it is *still* unreviewed!\n\n----------------------\n... diagnostics scrubbed ..." + }, + { + "tag": "pinging-reviewers", + "status": "🔔 @lhecker — please [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/74980/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." + }, + { + "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, @justinkrn68-droid.\n\n(Ping @lhecker.)" + } + ], + "shouldClose": false, + "shouldMerge": false, + "shouldUpdateLabels": true, + "reRunActionsCheckSuiteIDs": [ + 68415365071 + ] +} diff --git a/packages/mergebot/src/pr-info.ts b/packages/mergebot/src/pr-info.ts index 6c06d4ded9..4022f58e79 100644 --- a/packages/mergebot/src/pr-info.ts +++ b/packages/mergebot/src/pr-info.ts @@ -561,14 +561,10 @@ function makeChecker( ) { const diffFromExpected = (text: string) => { let data: any; - if (options?.parse) { - data = options.parse(text); - } else { - try { - data = JSON.parse(text); - } catch (e) { - return "couldn't parse json"; - } + try { + data = options?.parse ? options.parse(text) : JSON.parse(text); + } catch (e) { + return "couldn't parse json"; } options?.ignore?.(data); try {