Update to Danger 2.0

Summary:
See #17234 for discussion.
Closes https://github.com/facebook/react-native/pull/17310

Differential Revision: D6627914

Pulled By: hramos

fbshipit-source-id: 3d72fc69fe03c53706d2076ecf7b5321a00d1642
This commit is contained in:
Héctor Ramos 2017-12-22 09:47:06 -08:00 committed by Facebook Github Bot
parent 077c3ab349
commit b750e3b21b
2 changed files with 2 additions and 48 deletions

View File

@ -15,41 +15,6 @@ const minimatch = require('minimatch');
import { danger, fail, markdown, message, warn } from 'danger'; import { danger, fail, markdown, message, warn } from 'danger';
const isDocsFile = path => includes(path, 'docs/');
const editsDocs = danger.git.modified_files.filter(isDocsFile).length > 0;
const addsDocs = danger.git.created_files.filter(isDocsFile).length > 0;
if (addsDocs || editsDocs) {
// Note, this does not yet cover edits to the autogenerated docs
// (e.g. comments within JS source files)
const title = ':page_facing_up: Docs';
const idea = 'Thanks for your contribution to the docs!';
message(`${title} - <i>${idea}</i>`);
// Add the Documentation label via bot, as @facebook-open-source-bot does not have write privileges on the repo.
markdown('@facebook-github-bot label Documentation');
}
const isBlogFile = path => includes(path, 'blog/');
// Flags new blog posts. Note that mentions will not be parsed as the access token we're using does
// not belong to the Facebook org (on purpose)
const addsBlogPost = danger.git.created_files.filter(isBlogFile).length > 0;
if (addsBlogPost) {
const title = ':memo: Blog post';
const idea = 'This PR appears to add a new blog post, ' +
'and may require further review from the React Native team.';
warn(`${title} - <i>${idea}</i>`);
}
// Flags edits to blog posts
const editsBlogPost = danger.git.modified_files.filter(isBlogFile).length > 0;
if (editsBlogPost) {
const title = ':memo: Blog post';
const idea = 'This PR appears to edit an existing blog post, ' +
'and may require further review from the React Native team.';
warn(`${title} - <i>${idea}</i>`);
}
// Fails if the description is too short. // Fails if the description is too short.
if (!danger.github.pr.body || danger.github.pr.body.length < 10) { if (!danger.github.pr.body || danger.github.pr.body.length < 10) {
fail(':grey_question: This pull request needs a description.'); fail(':grey_question: This pull request needs a description.');
@ -74,19 +39,8 @@ if (packageChanged) {
} }
// Warns if a test plan is missing. // Warns if a test plan is missing.
const gettingStartedChanged = includes(danger.git.modified_files, 'docs/GettingStarted.md');
const includesTestPlan = danger.github.pr.body && danger.github.pr.body.toLowerCase().includes('test plan'); const includesTestPlan = danger.github.pr.body && danger.github.pr.body.toLowerCase().includes('test plan');
if (!includesTestPlan) {
// Warns if a test plan is missing, when editing the Getting Started guide. This page needs to be
// tested in all its permutations.
if (!includesTestPlan && gettingStartedChanged) {
const title = ':clipboard: Test Plan';
const idea = 'This PR appears to be missing a Test Plan.';
warn(`${title} - <i>${idea}</i>`);
markdown('@facebook-github-bot label Needs more information');
}
// Doc edits rarely require a test plan. We'll trust the reviewer to push back if one is needed.
if (!includesTestPlan && !editsDocs) {
const title = ':clipboard: Test Plan'; const title = ':clipboard: Test Plan';
const idea = 'This PR appears to be missing a Test Plan.'; const idea = 'This PR appears to be missing a Test Plan.';
warn(`${title} - <i>${idea}</i>`); warn(`${title} - <i>${idea}</i>`);

View File

@ -4,7 +4,7 @@
"danger": "node ./node_modules/.bin/danger" "danger": "node ./node_modules/.bin/danger"
}, },
"devDependencies": { "devDependencies": {
"danger": "^1.2.0", "danger": "^2.1.6",
"lodash.includes": "^4.3.0", "lodash.includes": "^4.3.0",
"minimatch": "^3.0.4" "minimatch": "^3.0.4"
} }