Dangerfile: warn when MR needs tests, thank when updating docs

environments/review-danger-4pi5yr/deployments/279
Alex Gleason 2 years ago
parent 30bac2b005
commit 2adf04d164
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -1,15 +1,13 @@
import { danger, warn } from 'danger';
import { danger, warn, message } from 'danger';
// No PR is too small to include a description of why you made a change
if (danger.gitlab.mr.description.length < 10) {
warn('Please include a description of your PR changes.');
}
const docs = danger.git.fileMatch('docs/**/*.md');
const app = danger.git.fileMatch('app/**/*.(js|ts|tsx)');
const tests = danger.git.fileMatch('*/__tests__/*');
// Check for a CHANGELOG entry
const hasChangelog = danger.git.modified_files.some(f => f === 'CHANGELOG.md');
const description = danger.gitlab.mr.description + danger.gitlab.mr.title;
const isTrivial = description.includes('#trivial');
if (docs.edited) {
message('Thanks - We :heart: our [documentarians](http://www.writethedocs.org/)!');
}
if (!hasChangelog && !isTrivial) {
warn('Please add a changelog entry for your changes.');
if (app.modified && !tests.modified) {
warn('You have app changes without tests.');
}

Loading…
Cancel
Save