Created
March 26, 2018 15:24
-
-
Save markmur/43d852e347133698b373d4e821846b8d to your computer and use it in GitHub Desktop.
Example Dangerfile
This file contains hidden or 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
const jest = require('danger-plugin-jest').default; | |
const { message, danger, warn } = require('danger'); | |
// Output all modified files in the PR | |
const modified = danger.git.modified_files; | |
message('Changed Files in this PR: \n' + modified.map(file => `- ${file}\n`)); | |
// Encourage smaller PRs | |
let errorCount = 0; | |
const bigPRThreshold = 600; | |
const thresholdErrorMessage = | |
'Pull Request size seems quite large. If the PR contains multiple changes, try splitting each change into a separate PR to aid faster, easier reviews.'; | |
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) { | |
warn( | |
`:exclamation: PR is too big (${++errorCount}) - ${thresholdErrorMessage}` | |
); | |
} | |
// Run jest test suites | |
jest(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment