diff --git a/bin/can-merge b/bin/can-merge index 54abbc9..482bc9f 100755 --- a/bin/can-merge +++ b/bin/can-merge @@ -115,7 +115,7 @@ function outputStatus(response) { if (NODE_ENV === 'DEBUG') { console.log(JSON.stringify(response, null, 2)); } - const prs = parsePullRequest(response.repository); + const prs = parsePullRequest(response); if (prs.length === 0) { console.info(chalk.redBright(`⚠ This remote repository does not contain any pull requests matching sha: ${args.sha}`)); process.exitCode = 1; diff --git a/test/mocks/evalPR.js b/test/mocks/evalPR.js index 0ee5c39..1bf827b 100644 --- a/test/mocks/evalPR.js +++ b/test/mocks/evalPR.js @@ -6,747 +6,714 @@ const pullRequestStatus = require("../../utils/models/pullRequestStatus"); module.exports = [ { - "res": { - "repository": { - "branchProtectionRules": { - "nodes": [] - }, - "pullRequest": { - "state": "OPEN", - "url": "https://github.com/facebook/react/pull/21829", - "title": "[package:react-dom] updateREADME's Class Component to Function Component", - "number": 21829, - "merged": false, - "mergeable": "MERGEABLE", - "reviewDecision": null, - "potentialMergeCommit": { - "commitUrl": "https://github.com/facebook/react/commit/2b565ef0bf81d5964a577ee5f07bb093d0358828" - }, - "commits": { - "nodes": [ - { - "commit": { - "statusCheckRollup": { - "state": "FAILURE", - "contexts": { - "totalCount": 33, - "pageInfo": { - "endCursor": "MzM", - "hasNextPage": false - }, - "nodes": [ - { - "__typename": "StatusContext", - "state": "FAILURE", - "context": "ci/circleci: get_base_build", - "description": "Your tests failed on CircleCI" - }, - { - "__typename": "StatusContext", - "state": "FAILURE", - "context": "ci/circleci: sync_reconciler_forks", - "description": "Your tests failed on CircleCI" - }, - { - "__typename": "CheckRun", - "status": "COMPLETED", - "name": "Facebook CLA Check", - "conclusion": "SUCCESS" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_test_dom_fixtures", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: build_devtools_and_process_artifacts", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: build_devtools_scheduling_profiler", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: process_artifacts_combined", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: setup", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_build_combined", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_flow", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_lint", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_lint_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=experimental --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=experimental --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=stable --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=stable --env=development --persistent", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=stable --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build---project=devtools -r=experimental", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=experimental --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=experimental --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=stable --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=stable --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/codesandbox", - "description": "Building packages succeeded." - } - ] + "pullRequest": { + "state": "OPEN", + "url": "https://github.com/facebook/react/pull/21829", + "title": "[package:react-dom] updateREADME's Class Component to Function Component", + "number": 21829, + "merged": false, + "mergeable": "MERGEABLE", + "reviewDecision": null, + "potentialMergeCommit": { + "commitUrl": "https://github.com/facebook/react/commit/2b565ef0bf81d5964a577ee5f07bb093d0358828" + }, + "commits": { + "nodes": [ + { + "commit": { + "statusCheckRollup": { + "state": "FAILURE", + "contexts": { + "totalCount": 33, + "pageInfo": { + "endCursor": "MzM", + "hasNextPage": false + }, + "nodes": [ + { + "__typename": "StatusContext", + "state": "FAILURE", + "context": "ci/circleci: get_base_build", + "description": "Your tests failed on CircleCI" + }, + { + "__typename": "StatusContext", + "state": "FAILURE", + "context": "ci/circleci: sync_reconciler_forks", + "description": "Your tests failed on CircleCI" + }, + { + "__typename": "CheckRun", + "status": "COMPLETED", + "name": "Facebook CLA Check", + "conclusion": "SUCCESS" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_test_dom_fixtures", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: build_devtools_and_process_artifacts", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: build_devtools_scheduling_profiler", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: process_artifacts_combined", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: setup", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_build_combined", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_flow", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_lint", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_lint_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=experimental --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=experimental --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=stable --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=stable --env=development --persistent", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=stable --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build---project=devtools -r=experimental", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=experimental --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=experimental --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=stable --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=stable --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/codesandbox", + "description": "Building packages succeeded." } - } + ] } } - ] + } } - } - }, - "rateLimit": { - "cost": 1, - "remaining": 4997 + ] } }, "expected": pullRequestStatus.STATUS_FAILURE, "description": "evaluation of a PR with FAILURE should return STATUS_FAILURE" }, { - "res": { - "repository": { - "branchProtectionRules": { - "nodes": [] - }, - "pullRequest": { - "state": "OPEN", - "url": "https://github.com/facebook/react/pull/21770", - "title": "Bump ini from 1.3.4 to 1.3.8 in /scripts/bench", - "number": 21770, - "merged": false, - "mergeable": "MERGEABLE", - "reviewDecision": null, - "potentialMergeCommit": { - "commitUrl": "https://github.com/facebook/react/commit/1dd6f0b8c2d792a784134458c2897c12de86895b" - }, - "commits": { - "nodes": [ - { - "commit": { - "statusCheckRollup": { - "state": "PENDING", - "contexts": { - "totalCount": 34, - "pageInfo": { - "endCursor": "MzQ", - "hasNextPage": false - }, - "nodes": [ - { - "__typename": "StatusContext", - "state": "PENDING", - "context": "ci/circleci: sync_reconciler_forks", - "description": "CircleCI is running your tests" - }, - { - "__typename": "StatusContext", - "state": "PENDING", - "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=true", - "description": "CircleCI is running your tests" - }, - { - "__typename": "CheckRun", - "status": "COMPLETED", - "name": "Facebook CLA Check", - "conclusion": "SUCCESS" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_test_dom_fixtures", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: build_devtools_and_process_artifacts", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: build_devtools_scheduling_profiler", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: get_base_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: process_artifacts_combined", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: setup", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: sizebot", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_build_combined", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_flow", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_lint", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_lint_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=experimental --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=experimental --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=stable --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=stable --env=development --persistent", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=stable --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build---project=devtools -r=experimental", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=experimental --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=experimental --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=stable --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=stable --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/codesandbox", - "description": "Building packages succeeded." - } - ] + "pullRequest": { + "state": "OPEN", + "url": "https://github.com/facebook/react/pull/21770", + "title": "Bump ini from 1.3.4 to 1.3.8 in /scripts/bench", + "number": 21770, + "merged": false, + "mergeable": "MERGEABLE", + "reviewDecision": null, + "potentialMergeCommit": { + "commitUrl": "https://github.com/facebook/react/commit/1dd6f0b8c2d792a784134458c2897c12de86895b" + }, + "commits": { + "nodes": [ + { + "commit": { + "statusCheckRollup": { + "state": "PENDING", + "contexts": { + "totalCount": 34, + "pageInfo": { + "endCursor": "MzQ", + "hasNextPage": false + }, + "nodes": [ + { + "__typename": "StatusContext", + "state": "PENDING", + "context": "ci/circleci: sync_reconciler_forks", + "description": "CircleCI is running your tests" + }, + { + "__typename": "StatusContext", + "state": "PENDING", + "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=true", + "description": "CircleCI is running your tests" + }, + { + "__typename": "CheckRun", + "status": "COMPLETED", + "name": "Facebook CLA Check", + "conclusion": "SUCCESS" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_test_dom_fixtures", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: build_devtools_and_process_artifacts", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: build_devtools_scheduling_profiler", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: get_base_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: process_artifacts_combined", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: setup", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: sizebot", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_build_combined", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_flow", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_lint", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_lint_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=experimental --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=experimental --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=stable --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=stable --env=development --persistent", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=stable --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build---project=devtools -r=experimental", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=experimental --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=experimental --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=stable --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=stable --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/codesandbox", + "description": "Building packages succeeded." } - } + ] } } - ] + } } - } - }, - "rateLimit": { - "cost": 1, - "remaining": 4994 + ] } }, "expected": pullRequestStatus.STATUS_PENDING, "description": "evalutation of a PR with PENDING should return STATUS_PENDING" }, { - "res": { - "repository": { - "branchProtectionRules": { - "nodes": [] - }, - "pullRequest": { - "state": "OPEN", - "url": "https://github.com/facebook/react/pull/21766", - "title": "fix: restore execution context after RetryAfterError completed", - "number": 21766, - "merged": false, - "mergeable": "MERGEABLE", - "reviewDecision": null, - "potentialMergeCommit": { - "commitUrl": "https://github.com/facebook/react/commit/6a02a00cd0356e43978b4ce090b7c25ad9be86c1" - }, - "commits": { - "nodes": [ - { - "commit": { - "statusCheckRollup": { - "state": "SUCCESS", - "contexts": { - "totalCount": 34, - "pageInfo": { - "endCursor": "MzQ", - "hasNextPage": false - }, - "nodes": [ - { - "__typename": "CheckRun", - "status": "COMPLETED", - "name": "Facebook CLA Check", - "conclusion": "SUCCESS" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_test_dom_fixtures", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: build_devtools_and_process_artifacts", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: build_devtools_scheduling_profiler", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: get_base_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: process_artifacts_combined", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: setup", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: sizebot", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: sync_reconciler_forks", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_build_combined", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_flow", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_lint", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_lint_build", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=experimental --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=experimental --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=stable --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=stable --env=development --persistent", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=stable --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=false", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=true", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build---project=devtools -r=experimental", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=experimental --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=experimental --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=stable --env=development", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/circleci: yarn_test_build--r=stable --env=production", - "description": "Your tests passed on CircleCI!" - }, - { - "__typename": "StatusContext", - "state": "SUCCESS", - "context": "ci/codesandbox", - "description": "Building packages succeeded." - } - ] + "pullRequest": { + "state": "OPEN", + "url": "https://github.com/facebook/react/pull/21766", + "title": "fix: restore execution context after RetryAfterError completed", + "number": 21766, + "merged": false, + "mergeable": "MERGEABLE", + "reviewDecision": null, + "potentialMergeCommit": { + "commitUrl": "https://github.com/facebook/react/commit/6a02a00cd0356e43978b4ce090b7c25ad9be86c1" + }, + "commits": { + "nodes": [ + { + "commit": { + "statusCheckRollup": { + "state": "SUCCESS", + "contexts": { + "totalCount": 34, + "pageInfo": { + "endCursor": "MzQ", + "hasNextPage": false + }, + "nodes": [ + { + "__typename": "CheckRun", + "status": "COMPLETED", + "name": "Facebook CLA Check", + "conclusion": "SUCCESS" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: RELEASE_CHANNEL_stable_yarn_test_dom_fixtures", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: build_devtools_and_process_artifacts", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: build_devtools_scheduling_profiler", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: get_base_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: process_artifacts_combined", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: setup", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: sizebot", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: sync_reconciler_forks", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_build_combined", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_flow", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_lint", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_lint_build", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=experimental --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=experimental --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=stable --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=stable --env=development --persistent", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=stable --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=development --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-classic --env=production --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=development --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=false", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test--r=www-modern --env=production --variant=true", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build---project=devtools -r=experimental", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=experimental --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=experimental --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=stable --env=development", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/circleci: yarn_test_build--r=stable --env=production", + "description": "Your tests passed on CircleCI!" + }, + { + "__typename": "StatusContext", + "state": "SUCCESS", + "context": "ci/codesandbox", + "description": "Building packages succeeded." } - } + ] } } - ] + } } - } - }, - "rateLimit": { - "cost": 1, - "remaining": 4992 + ] } }, "expected": pullRequestStatus.MERGEABLE, diff --git a/test/mocks/parsePR.json b/test/mocks/parsePR.json index 87e7afd..354f10b 100644 --- a/test/mocks/parsePR.json +++ b/test/mocks/parsePR.json @@ -1,56 +1,45 @@ [ { - - "repository": { - "branchProtectionRules": { - "nodes": [] - }, - "pullRequests": { - "nodes": [] + "response": { + "search": { + "edges": [] } }, - "rateLimit": { - "cost": 2, - "remaining": 4959 - }, - "expected": [], "description": "No pr found: No pr found in repository should return an empty array" }, { - - "repository": { - "branchProtectionRules": { - "nodes": [] - }, - "pullRequest": { - "state": "OPEN", - "url": "https://github.com/MeghalBisht/dummy-repo/pull/1", - "title": "dummy PR", - "number": 1, - "merged": false, - "mergeable": "MERGEABLE", - "reviewDecision": null, - "potentialMergeCommit": { - "commitUrl": - "https://github.com/MeghalBisht/dummy-repo/commit/1f197b41bfd76a2fb5480a6af5a6bc6d06a7f6e7" - }, - "commits": { - "nodes": [ - { - "commit": { - "statusCheckRollup": null + "response": { + "search": { + "edges": [ + { + "node": [ + { + "state": "OPEN", + "url": "https://github.com/MeghalBisht/dummy-repo/pull/1", + "title": "dummy PR", + "number": 1, + "merged": false, + "mergeable": "MERGEABLE", + "reviewDecision": null, + "potentialMergeCommit": { + "commitUrl": "https://github.com/MeghalBisht/dummy-repo/commit/1f197b41bfd76a2fb5480a6af5a6bc6d06a7f6e7" + }, + "commits": { + "nodes": [ + { + "commit": { + "statusCheckRollup": null + } + } + ] + } } - } - ] - } + ] + } + ] } }, - "rateLimit": { - "cost": 2, - "remaining": 4945 - }, - "expected": [ { "state": "OPEN", @@ -61,8 +50,7 @@ "mergeable": "MERGEABLE", "reviewDecision": null, "potentialMergeCommit": { - "commitUrl": - "https://github.com/MeghalBisht/dummy-repo/commit/1f197b41bfd76a2fb5480a6af5a6bc6d06a7f6e7" + "commitUrl": "https://github.com/MeghalBisht/dummy-repo/commit/1f197b41bfd76a2fb5480a6af5a6bc6d06a7f6e7" }, "commits": { "nodes": [ @@ -78,100 +66,91 @@ "description": "One pr found: One pr found should return an array of length === 1" }, { - - "repository": { - "branchProtectionRules": { - "nodes": [] - }, - "commit": { - "associatedPullRequests": { - "edges": [ - { - "node": [ - { - "state": "OPEN", - "url": "https://github.com/MeghalBisht/dummy-repo/pull/1", - "title": "dummy PR", - "number": 1, - "merged": false, - "mergeable": "MERGEABLE", - "reviewDecision": null, - "potentialMergeCommit": { - "commitUrl": - "https://github.com/MeghalBisht/dummy-repo/commit/1f197b41bfd76a2fb5480a6af5a6bc6d06a7f6e7" - }, - "commits": { - "nodes": [ - { - "commit": { - "statusCheckRollup": null - } + "response": { + "search": { + "edges": [ + { + "node": [ + { + "state": "OPEN", + "url": "https://github.com/MeghalBisht/dummy-repo/pull/1", + "title": "dummy PR", + "number": 1, + "merged": false, + "mergeable": "MERGEABLE", + "reviewDecision": null, + "potentialMergeCommit": { + "commitUrl": "https://github.com/MeghalBisht/dummy-repo/commit/1f197b41bfd76a2fb5480a6af5a6bc6d06a7f6e7" + }, + "commits": { + "nodes": [ + { + "commit": { + "statusCheckRollup": null } - ] - } + } + ] } - ] - }, - { - "node": [ - { - "state": "OPEN", - "url": "https://github.com/MeghalBisht/dummy-repo/pull/2", - "title": "dummy PR 2", - "number": 2, - "merged": false, - "mergeable": "MERGEABLE", - "reviewDecision": null, - "potentialMergeCommit": { - "commitUrl": - "https://github.com/MeghalBisht/dummy-repo/commit/636e6f943e0dd719b49aeec53991a0e7384a684d" - }, - "commits": { - "nodes": [ - { - "commit": { - "statusCheckRollup": null - } + } + ] + }, + { + "node": [ + { + "state": "OPEN", + "url": "https://github.com/MeghalBisht/dummy-repo/pull/2", + "title": "dummy PR 2", + "number": 2, + "merged": false, + "mergeable": "MERGEABLE", + "reviewDecision": null, + "potentialMergeCommit": { + "commitUrl": "https://github.com/MeghalBisht/dummy-repo/commit/636e6f943e0dd719b49aeec53991a0e7384a684d" + }, + "commits": { + "nodes": [ + { + "commit": { + "statusCheckRollup": null } - ] - } + } + ] } - ] - }, - { - "node": [ - { - "state": "OPEN", - "url": "https://github.com/MeghalBisht/dummy-repo/pull/3", - "title": "dummy PR 3", - "number": 3, - "merged": false, - "mergeable": "MERGEABLE", - "reviewDecision": null, - "potentialMergeCommit": { - "commitUrl": - "https://github.com/MeghalBisht/dummy-repo/commit/0ffc1461f1ad736fa27ee1c38856cff5611673e1" - }, - "commits": { - "nodes": [ - { - "commit": { - "statusCheckRollup": null - } + } + ] + }, + { + "node": [ + { + "state": "OPEN", + "url": "https://github.com/MeghalBisht/dummy-repo/pull/3", + "title": "dummy PR 3", + "number": 3, + "merged": false, + "mergeable": "MERGEABLE", + "reviewDecision": null, + "potentialMergeCommit": { + "commitUrl": "https://github.com/MeghalBisht/dummy-repo/commit/0ffc1461f1ad736fa27ee1c38856cff5611673e1" + }, + "commits": { + "nodes": [ + { + "commit": { + "statusCheckRollup": null } - ] - } + } + ] } - ] - } - ] - } + } + ] + } + ] + }, + "rateLimit": { + "cost": 2, + "remaining": 4997 } }, - "rateLimit": { - "cost": 2, - "remaining": 4997 - }, "expected": [ { "state": "OPEN", @@ -182,8 +161,7 @@ "mergeable": "MERGEABLE", "reviewDecision": null, "potentialMergeCommit": { - "commitUrl": - "https://github.com/MeghalBisht/dummy-repo/commit/1f197b41bfd76a2fb5480a6af5a6bc6d06a7f6e7" + "commitUrl": "https://github.com/MeghalBisht/dummy-repo/commit/1f197b41bfd76a2fb5480a6af5a6bc6d06a7f6e7" }, "commits": { "nodes": [ @@ -204,8 +182,7 @@ "mergeable": "MERGEABLE", "reviewDecision": null, "potentialMergeCommit": { - "commitUrl": - "https://github.com/MeghalBisht/dummy-repo/commit/636e6f943e0dd719b49aeec53991a0e7384a684d" + "commitUrl": "https://github.com/MeghalBisht/dummy-repo/commit/636e6f943e0dd719b49aeec53991a0e7384a684d" }, "commits": { "nodes": [ @@ -226,8 +203,7 @@ "mergeable": "MERGEABLE", "reviewDecision": null, "potentialMergeCommit": { - "commitUrl": - "https://github.com/MeghalBisht/dummy-repo/commit/0ffc1461f1ad736fa27ee1c38856cff5611673e1" + "commitUrl": "https://github.com/MeghalBisht/dummy-repo/commit/0ffc1461f1ad736fa27ee1c38856cff5611673e1" }, "commits": { "nodes": [ diff --git a/test/utils.test.js b/test/utils.test.js index 841ae6c..d304ece 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -20,7 +20,7 @@ const iter = (iterable) => { test('evaluatePullRequest', (t) => { mockEvalPR.forEach((mock) => { - t.equal(evaluatePullRequest(mock.res.repository.pullRequest), mock.expected, mock.description); + t.equal(evaluatePullRequest(mock.pullRequest), mock.expected, mock.description); }); t.end(); @@ -28,7 +28,7 @@ test('evaluatePullRequest', (t) => { test('parsePullRequest', (t) => { mockParsePR.forEach((mock) => { - t.deepEqual(parsePullRequest(mock.repository), mock.expected, mock.description); + t.deepEqual(parsePullRequest(mock.response), mock.expected, mock.description); }); t.end(); diff --git a/utils/buildQuery.js b/utils/buildQuery.js index e8f5ac1..c3cb9a6 100644 --- a/utils/buildQuery.js +++ b/utils/buildQuery.js @@ -50,36 +50,16 @@ module.exports = function buildQuery({ }) { return ` { - repository(owner: "${owner}", name: "${name}") { - branchProtectionRules(first: 10) { - nodes { - requiresStatusChecks - requiredApprovingReviewCount - requiredStatusCheckContexts - } - } - ${pr ? `pullRequest(number: ${pr}) { - ${pullRequestQuery()} - }` : sha ? `commit: object(expression: "${sha}") { - ... on Commit { - associatedPullRequests(first:50){ - edges{ - node{ - ${pullRequestQuery()} - } - } - } - } - }` : `pullRequests(first: 100) { - nodes { + search(query: "is:open is:pr repo:${owner}/${name} ${sha ? `sha:${sha}` : ''} ${pr ? `pr: ${pr}` : ''}", type:ISSUE, first: 100) { + issueCount + edges { + node { + ... on PullRequest { ${pullRequestQuery()} + } } - }`} - } - rateLimit { - cost - remaining + } } } - `; + `; }; diff --git a/utils/parsePullRequest.js b/utils/parsePullRequest.js index 700f423..53a4d22 100644 --- a/utils/parsePullRequest.js +++ b/utils/parsePullRequest.js @@ -1,9 +1,5 @@ 'use strict'; module.exports = function parsePullRequest(response) { - return response.pullRequest - ? [response.pullRequest] - : response.commit?.associatedPullRequests.edges.flatMap(({ node }) => node) - || response.pullRequests?.nodes - || []; + return response.search.edges.flatMap(({ node }) => node) || []; };