-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Add danger to start automating some code review tasks #1251
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7bb724f
Add danger to start automating some code review tasks
shilman 5bb5fd9
Check for "do not merge" and required pr-log labels
shilman f936a16
Warn about missing labels instead of failing
shilman bbbdf54
Merge branch 'master' into danger-check-pr-labels
shilman 3682655
Update danger to post status rather than break the build
shilman 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
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,26 @@ | ||
import { fail, danger } from 'danger'; | ||
import { flatten, intersection, isEmpty, includes } from 'lodash'; | ||
|
||
const pkg = require('./package.json'); // eslint-disable-line import/newline-after-import | ||
const prLogConfig = pkg['pr-log']; | ||
|
||
const checkRequiredLabels = labels => { | ||
const requiredLabels = flatten([ | ||
prLogConfig.skipLabels || [], | ||
Object.keys(prLogConfig.validLabels || {}), | ||
]); | ||
|
||
if (includes(labels, 'do not merge')) { | ||
fail('PR is marked with "do not merge" label.'); | ||
} | ||
|
||
const foundLabels = intersection(requiredLabels, labels); | ||
if (isEmpty(foundLabels)) { | ||
fail(`PR is not labeled with one of: ${JSON.stringify(requiredLabels)}`); | ||
} | ||
}; | ||
|
||
if (prLogConfig) { | ||
const { labels } = danger.github.issue; | ||
checkRequiredLabels(labels.map(l => l.name)); | ||
} |
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.
This makes sense, but only if you consider that an org contributor can set labels - so an OSS contribution wouldn't be able to do this - so it might be worth changing it to warn ( or to check whether the PR author is in the storybooks org )