From 2adf04d16400c004bc621ba5d1456c35e3c444ca Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 15 Jun 2022 18:16:08 -0500 Subject: [PATCH] Dangerfile: warn when MR needs tests, thank when updating docs --- dangerfile.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/dangerfile.ts b/dangerfile.ts index b52a4e49f..cf842bb8d 100644 --- a/dangerfile.ts +++ b/dangerfile.ts @@ -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__/*'); + +if (docs.edited) { + message('Thanks - We :heart: our [documentarians](http://www.writethedocs.org/)!'); } -// 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 (!hasChangelog && !isTrivial) { - warn('Please add a changelog entry for your changes.'); +if (app.modified && !tests.modified) { + warn('You have app changes without tests.'); }