Skip to content

Commit

Permalink
Update to Danger 2.0
Browse files Browse the repository at this point in the history
Summary:
See #17234 for discussion.
Closes #17310

Differential Revision: D6627914

Pulled By: hramos

fbshipit-source-id: 3d72fc69fe03c53706d2076ecf7b5321a00d1642
  • Loading branch information
hramos authored and facebook-github-bot committed Dec 22, 2017
1 parent 077c3ab commit b750e3b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
48 changes: 1 addition & 47 deletions danger/dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,6 @@ const minimatch = require('minimatch');

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.
if (!danger.github.pr.body || danger.github.pr.body.length < 10) {
fail(':grey_question: This pull request needs a description.');
Expand All @@ -74,19 +39,8 @@ if (packageChanged) {
}

// 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');

// 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) {
if (!includesTestPlan) {
const title = ':clipboard: Test Plan';
const idea = 'This PR appears to be missing a Test Plan.';
warn(`${title} - <i>${idea}</i>`);
Expand Down
2 changes: 1 addition & 1 deletion danger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"danger": "node ./node_modules/.bin/danger"
},
"devDependencies": {
"danger": "^1.2.0",
"danger": "^2.1.6",
"lodash.includes": "^4.3.0",
"minimatch": "^3.0.4"
}
Expand Down

0 comments on commit b750e3b

Please sign in to comment.