From 0daa40f3ad98b04a3d21367ad06356e3b56e61ae Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Wed, 22 Feb 2023 10:07:11 +0800 Subject: [PATCH 1/2] dangerjs: add success log --- .gitlab/dangerfile.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitlab/dangerfile.js b/.gitlab/dangerfile.js index 9dafd00a82..f7cf13d31f 100644 --- a/.gitlab/dangerfile.js +++ b/.gitlab/dangerfile.js @@ -1,4 +1,4 @@ -import { danger, warn, message } from "danger" +import { danger, warn, message, results } from "danger" /** * Check if MR Title contains prefix "Draft: ... or "WIP: ...". @@ -177,3 +177,10 @@ function addRetryLink() { return markdown(`***\n#### :repeat: If you want to run these checks again, please retry this [DangerJS job](${retryLink})\n***`); } addRetryLink(); + +function printSuccessLog() { + if (results.fails.length === 0 && results.warnings.length === 0 && results.messages.length === 0) { + return message('Good Job! All checks are passing!') + } +} +printSuccessLog(); From 04209244a9590e2309f529c18b9586490d0111a3 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Wed, 22 Feb 2023 10:07:35 +0800 Subject: [PATCH 2/2] dangerjs: support "No related issues" under "Related" section --- .gitlab/dangerfile.js | 5 +++++ .gitlab/merge_request_templates/Minimal_Template.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab/dangerfile.js b/.gitlab/dangerfile.js index f7cf13d31f..945360e3e4 100644 --- a/.gitlab/dangerfile.js +++ b/.gitlab/dangerfile.js @@ -62,10 +62,15 @@ function checkMrJiraLinks() { const mrCommitMessages = danger.gitlab.commits.map(commit => commit.message); const matchBlockRelated = mrDescription.match(/\#\# Related.*$/s); // Match MR description starting with line ## Related till the end of MR description + const noRelatedIssues = /No related issues/.test(matchBlockRelated ? matchBlockRelated[0] : ''); // Check if there is "No related issues" const testJiraLabels = /[A-Z]+-[0-9]+/.test(matchBlockRelated ? matchBlockRelated[0] : ''); // Test if pattern of Jira label "JIRA-1234" or "RDT-311" is in section Related const ghIssueTicket = /IDFGH-[0-9]+/.test(matchBlockRelated ? matchBlockRelated[0] : ''); // Check if there is JIRA link starts with "IDFGH-*" in MR description, section "Related" const testGithubLink = /Closes https:\/\/github\.com\/espressif\/esp-idf\/issues\/[0-9]+/ + if (mrDescription.toUpperCase().includes("## RELATED") && noRelatedIssues) { + return + } + if (!mrDescription.toUpperCase().includes("## RELATED") || !testJiraLabels) { // Missing section "Related" or missing links to JIRA tickets return warn("Please add links to JIRA issues to the MR description section `Related`."); diff --git a/.gitlab/merge_request_templates/Minimal_Template.md b/.gitlab/merge_request_templates/Minimal_Template.md index c65b0bc57a..b020d3cba5 100644 --- a/.gitlab/merge_request_templates/Minimal_Template.md +++ b/.gitlab/merge_request_templates/Minimal_Template.md @@ -7,7 +7,7 @@ ## Related - + ## Release notes