Skip to content

Commit

Permalink
Merge branch 'ci/dangerjs_success_log' into 'master'
Browse files Browse the repository at this point in the history
dangerjs: add success log

See merge request espressif/esp-idf!22470
  • Loading branch information
hfudev committed Feb 23, 2023
2 parents 5297dd2 + 0420924 commit 0d97eeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion .gitlab/dangerfile.js
Original file line number Diff line number Diff line change
@@ -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: ...".
Expand Down Expand Up @@ -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`.");

Expand Down Expand Up @@ -177,3 +182,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();
2 changes: 1 addition & 1 deletion .gitlab/merge_request_templates/Minimal_Template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Add description of the change here --><!-- Mandatory -->

## Related <!-- Optional -->
<!-- Related Jira issues and Github issues -->
<!-- Related Jira issues and Github issues or write "No related issues"-->

## Release notes <!-- Mandatory -->
<!-- Either state release notes or write "No release notes" -->
Expand Down

0 comments on commit 0d97eeb

Please sign in to comment.