From 9877c088558ad0c4ca9b313074e57c6eb370cce6 Mon Sep 17 00:00:00 2001 From: Trevor Brindle Date: Fri, 13 Oct 2017 13:26:38 -0700 Subject: [PATCH] add release notes/changelog requirement to PR Template Summary: grabbou has to write release notes for every release, and that's getting ridonc. Have you seen the changelog from 0.48? PR writers need to do their own, hopefully in a standardized format so it can be scripted. Just a PR template change, just proofreading needed. Please mention if have missed or added any extra Categories, Types, or Where columns. Here's a sample: [GENERAL] [ENHANCEMENT] [PULL_REQUEST_TEMPLATE.md] - added release notes/changelog requirement to PR Template Closes https://github.com/facebook/react-native/pull/15874 Differential Revision: D6054557 Pulled By: hramos fbshipit-source-id: 5741b98a0efdb1a6aaaeedaa292403b82ce713f6 --- .github/PULL_REQUEST_TEMPLATE.md | 30 ++++++++++++++++++++++++++++++ danger/dangerfile.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 05161b55a05169..126b18a9854ac3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,8 +9,38 @@ Happy contributing! --> +## Motivation + (Write your motivation here.) ## Test Plan (Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!) + +## Release Notes + diff --git a/danger/dangerfile.js b/danger/dangerfile.js index 23ad03ff7dc6cc..13c1ed85d863d9 100644 --- a/danger/dangerfile.js +++ b/danger/dangerfile.js @@ -93,6 +93,35 @@ if (!includesTestPlan && !editsDocs) { markdown('@facebook-github-bot label Needs more information'); } +// Regex looks for given categories, types, a file/framework/component, and a message - broken into 4 capture groups +const releaseNotesRegex = /\[(ANDROID|CLI|DOCS|GENERAL|INTERNAL|IOS|TVOS|WINDOWS)\]\s*?\[(BREAKING|BUGFIX|ENHANCEMENT|FEATURE|MINOR)\]\s*?\[(.*)\]\s*?\-\s*?(.*)/ig; +const includesReleaseNotes = danger.github.pr.body.toLowerCase().includes('release notes'); +const correctlyFormattedReleaseNotes = releaseNotesRegex.test(danger.github.pr.body); +const releaseNotesCaptureGroups = releaseNotesRegex.exec(danger.github.pr.body); + +if (!includesReleaseNotes) { + const title = ':clipboard: Release Notes'; + const idea = 'This PR appears to be missing Release Notes.'; + warn(`${title} - ${idea}`); + markdown('@facebook-github-bot label Needs more information'); +} else if (!correctlyFormattedReleaseNotes) { + const title = ':clipboard: Release Notes'; + const idea = 'This PR may have incorrectly formatted Release Notes.'; + warn(`${title} - ${idea}`); + markdown('@facebook-github-bot label Needs more information'); +} else if (releaseNotesCaptureGroups) { + const category = releaseNotesCaptureGroups[1].toLowerCase(); + + // Use Release Notes to Tag PRs appropriately + if (category === 'ios' ){ + markdown('@facebook-github-bot label iOS'); + } + + if (category === 'android' ){ + markdown('@facebook-github-bot label Android'); + } +} + // Tags PRs that have been submitted by a core contributor. // TODO: Switch to using an actual MAINTAINERS file. const taskforce = fs.readFileSync('../bots/IssueCommands.txt', 'utf8').split('\n')[0].split(':')[1];