diff --git a/.circleci/config.yml b/.circleci/config.yml index cc86a51c4..7ef8e3be5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -547,8 +547,9 @@ jobs: - run: name: Analyze Pull Request command: | + # DANGER_GITHUB_API_TOKEN=Facebook-Open-Source-Bot public_repo access token if [ -n "$CIRCLE_PR_NUMBER" ]; then - cd bots && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" yarn danger + cd bots && DANGER_GITHUB_API_TOKEN="b186c9a82bab3b08ec80""c0818117619eec6f281a" yarn danger else echo "Skipping pull request analysis." fi @@ -556,6 +557,7 @@ jobs: - run: name: Analyze Code command: | + # GITHUB_TOKEN=eslint-bot public_repo access token if [ -n "$CIRCLE_PR_NUMBER" ]; then cat <(echo eslint; yarn --silent lint --format=json; echo flow; yarn --silent flow check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js else diff --git a/bots/README.md b/bots/README.md index 58cf901f8..985687f38 100644 --- a/bots/README.md +++ b/bots/README.md @@ -9,10 +9,10 @@ If you'd like to make changes to the Dangerfile, find an existing PR on the Reac Then, run from the React Native root directory: ``` -cd .circleci +cd bots npm install .. -node .circleci/node_modules/.bin/danger pr https://github.com/facebook/react-native/pull/1 +node bots/node_modules/.bin/danger pr https://github.com/facebook/react-native/pull/1 ``` And you will get the responses from parsing the Dangerfile. diff --git a/bots/dangerfile.js b/bots/dangerfile.js index fc727e2f0..bd625afb3 100644 --- a/bots/dangerfile.js +++ b/bots/dangerfile.js @@ -45,7 +45,7 @@ if (!includesTestPlan) { // Regex looks for given categories, types, a file/framework/component, and a message - broken into 4 capture groups const releaseNotesRegex = /\[(ANDROID|CLI|DOCS|GENERAL|INTERNAL|IOS|TVOS|WINDOWS)\]\s*?\[(BREAKING|BUGFIX|ENHANCEMENT|FEATURE|MINOR)\]\s*?\[(.*)\]\s*?\-\s*?(.*)/ig; -const includesReleaseNotes = danger.github.pr.body.toLowerCase().includes('release notes'); +const includesReleaseNotes = danger.github.pr.body && danger.github.pr.body.toLowerCase().includes('release notes'); const correctlyFormattedReleaseNotes = releaseNotesRegex.test(danger.github.pr.body); const releaseNotesCaptureGroups = releaseNotesRegex.exec(danger.github.pr.body); @@ -86,8 +86,7 @@ if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) { warn(`${title} - ${idea}`); // markdown('@facebook-github-bot large-pr'); -} -if (danger.git.modified_files + danger.git.added_files + danger.git.deleted_files > bigPRThreshold) { +} else if (danger.git.modified_files + danger.git.added_files + danger.git.deleted_files > bigPRThreshold) { const title = ':exclamation: Big PR'; const idea = `This PR is extremely unlikely to get reviewed because it touches ${danger.git.modified_files + danger.git.added_files + danger.git.deleted_files} files.`; warn(`${title} - ${idea}`); @@ -95,15 +94,6 @@ if (danger.git.modified_files + danger.git.added_files + danger.git.deleted_file // markdown('@facebook-github-bot large-pr'); } -// Warns if the bots whitelist file is updated. -const issueCommandsFileModified = includes(danger.git.modified_files, 'bots/IssueCommands.txt'); -if (issueCommandsFileModified) { - const title = ':exclamation: Bots'; - const idea = 'This PR appears to modify the list of people that may issue ' + - 'commands to the GitHub bot.'; - warn(`${title} - ${idea}`); -} - // Warns if the PR is opened against stable, as commits need to be cherry picked and tagged by a release maintainer. // Fails if the PR is opened against anything other than `master` or `-stable`. const isMergeRefMaster = danger.github.pr.base.ref === 'master';