From c41f0dd0cf283e204afdf906435ceba35d86c35a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 29 Jul 2022 15:13:55 +0200 Subject: [PATCH 1/3] Do not request PR created by Dependabot to include a Sign-off. Dependabot includes a sign-off in its commits, but if the team adds extra commits, we will have the warning that a sign off is required. --- tools/danger/dangerfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/danger/dangerfile.js b/tools/danger/dangerfile.js index 407cedc34b..8c0fc23830 100644 --- a/tools/danger/dangerfile.js +++ b/tools/danger/dangerfile.js @@ -50,6 +50,7 @@ const allowList = [ "BillCarsonFr", "bmarty", "Claire1817", + "dependabot[bot]", "ericdecanini", "fedrunov", "Florian14", From d60695806f89b5e0b35e4d650b0a84cde46680e0 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 29 Jul 2022 15:18:04 +0200 Subject: [PATCH 2/3] Do not require a changelog file for PR created by Dependabot. --- tools/danger/dangerfile.js | 40 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/tools/danger/dangerfile.js b/tools/danger/dangerfile.js index 8c0fc23830..e6dd3c47cb 100644 --- a/tools/danger/dangerfile.js +++ b/tools/danger/dangerfile.js @@ -8,6 +8,8 @@ const {danger, warn} = require('danger') // warn(JSON.stringify(danger)) const pr = danger.github.pr +// User who has created the PR. +const user = pr.user.login const modified = danger.git.modified_files const created = danger.git.created_files let editedFiles = [...modified, ...created] @@ -23,21 +25,29 @@ if (editedFiles.length > 50) { } // Request a changelog for each PR -let changelogFiles = editedFiles.filter(file => file.startsWith("changelog.d/")) +const changelogAllowList = [ + "dependabot[bot]", +] -if (changelogFiles.length == 0) { - warn("Please add a changelog. See instructions [here](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog)") -} else { - const validTowncrierExtensions = [ - "bugfix", - "doc", - "feature", - "misc", - "sdk", - "wip", - ] - if (!changelogFiles.every(file => validTowncrierExtensions.includes(file.split(".").pop()))) { - fail("Invalid extension for changelog. See instructions [here](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog)") +let requiresChangelog = !changelogAllowList.includes(user) + +if (requiresChangelog) { + let changelogFiles = editedFiles.filter(file => file.startsWith("changelog.d/")) + + if (changelogFiles.length == 0) { + warn("Please add a changelog. See instructions [here](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog)") + } else { + const validTowncrierExtensions = [ + "bugfix", + "doc", + "feature", + "misc", + "sdk", + "wip", + ] + if (!changelogFiles.every(file => validTowncrierExtensions.includes(file.split(".").pop()))) { + fail("Invalid extension for changelog. See instructions [here](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog)") + } } } @@ -66,7 +76,7 @@ const allowList = [ "yostyle", ] -let requiresSignOff = !allowList.includes(pr.user.login) +let requiresSignOff = !allowList.includes(user) if (requiresSignOff) { let hasPRBodySignOff = pr.body.includes(signOff) From 725ed007591f6907b9da6e8b9531ebd49f34b5ee Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 29 Jul 2022 15:41:36 +0200 Subject: [PATCH 3/3] Change some severities --- tools/danger/dangerfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/danger/dangerfile.js b/tools/danger/dangerfile.js index e6dd3c47cb..44b97d77c4 100644 --- a/tools/danger/dangerfile.js +++ b/tools/danger/dangerfile.js @@ -21,7 +21,7 @@ if (pr.body.length == 0) { // Warn when there is a big PR if (editedFiles.length > 50) { - warn("This pull request seems relatively large. Please consider splitting it into multiple smaller ones.") + message("This pull request seems relatively large. Please consider splitting it into multiple smaller ones.") } // Request a changelog for each PR @@ -102,5 +102,5 @@ if (hasPngs) { // Check for reviewers if (pr.requested_reviewers.length == 0 && !pr.draft) { - fail("Please add a reviewer to your PR.") + warn("Please add a reviewer to your PR.") }