-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Danger #14956
Closed
Closed
[WIP] Danger #14956
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
740bec7
Adds Danger support
hramos 9f9f994
Additional Dangerfile rules, and actually run in CI.
hramos efdedad
Force another run in Circle
hramos 0e48ea4
Use correct script location.
hramos f91e84e
Merge branch 'master' of github.com:facebook/react-native into add-da…
hramos b2b63fa
Force another run
hramos dbb1c59
Fix parsing of taskforce users.
hramos 8b8afc6
Flag Getting Started edits.
hramos 337b7b9
Add comments
hramos b91940f
Pass on API token.
hramos 68fd826
Add token in plain text - it's safe, as this is from a public bot.
hramos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright (c) 2016-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
// Removed require | ||
const fs = require('fs'); | ||
const includes = require('lodash.includes'); | ||
|
||
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) | ||
markdown(`:page_facing_up: Thanks for your contribution to the docs!`); | ||
} | ||
|
||
const isBlogFile = path => includes(path, 'blog/'); | ||
|
||
// Flags new blog posts. | ||
const addsBlogPost = danger.git.created_files.filter(isBlogFile).length > 0; | ||
if (addsBlogPost) { | ||
const message = ':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(`${message} - <i>${idea}</i>`); | ||
markdown(`:memo: This PR requires attention from the @facebook/react-native team.`); | ||
} | ||
|
||
// Flags edits to blog posts | ||
const editsBlogPost = danger.git.modified_files.filter(isBlogFile).length > 0; | ||
if (editsBlogPost) { | ||
const message = ':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(`${message} - <i>${idea}</i>`); | ||
markdown(`This PR requires attention from the @facebook/react-native team.`); | ||
} | ||
|
||
// Fails if the description is too short. | ||
if (danger.github.pr.body.length < 10) { | ||
fail(':grey_question: This pull request needs a description.') | ||
} | ||
|
||
// Warns if the PR title contains [WIP] | ||
const isWIP = includes(danger.github.pr.title, '[WIP]') | ||
if (isWIP) { | ||
const message = ':construction_worker: Work In Progress'; | ||
const idea = 'Do not merge yet.'; | ||
warn(`${message} - <i>${idea}</i>`); | ||
} | ||
|
||
// Warns if there are changes to package.json, and tags the team. | ||
const packageChanged = includes(danger.git.modified_files, 'package.json'); | ||
if (packageChanged) { | ||
const message = ':lock: Changes were made to package.json'; | ||
const idea = 'This will require a manual import. Once approved, a Facebook employee should import the PR, then run `yarn add` for any new packages.'; | ||
warn(`${message} - <i>${idea}</i>`); | ||
markdown(`This PR requires attention from the @facebook/react-native team.`); | ||
} | ||
|
||
// Warns if a test plan is missing. | ||
const gettingStartedChanged = includes(danger.git.modified_files, 'docs/GettingStarted.md'); | ||
const includesTestPlan = 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 message = ':clipboard: Test Plan'; | ||
const idea = 'This PR appears to be missing a Test Plan.'; | ||
warn(`${message} - <i>${idea}</i>`); | ||
} | ||
// Doc edits rarely require a test plan. We'll trust the reviewer to push back if one is needed. | ||
if (!includesTestPlan && !editsDocs) { | ||
const message = ':clipboard: Test Plan'; | ||
const idea = 'This PR appears to be missing a Test Plan.'; | ||
warn(`${message} - <i>${idea}</i>`); | ||
} | ||
|
||
// Tags the React Native team is the PR is submitted by a core contributor | ||
const taskforce = fs.readFileSync('bots/IssueCommands.txt', 'utf8').split('\n')[0].split(':')[1]; | ||
const isSubmittedByTaskforce = includes(taskforce, danger.github.pr.user.login); | ||
if (isSubmittedByTaskforce) { | ||
markdown(`This PR has been submitted by a core contributor. Notifying @facebook/react-native.`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not merge until we can remove this. This is only necessary until a new release of Jest is cut. See danger/danger-js#261