From 140dbda421eecef6729d688085a71d892c64c966 Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Thu, 3 Aug 2023 02:17:57 +0800 Subject: [PATCH] ci(dangerjs): fixed html comments not ignored issue Fixed issues: 1. Always produce a warning caused by the pre-inserted blank line. 2. Line started by other character but contains bullet treated as valid entry 3. No release note entry hidden in the html comment still recognized. --- .gitlab/dangerjs/dangerfile.js | 2 +- ...easeNotes.js => mrDescriptionReleaseNotes.js} | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) rename .gitlab/dangerjs/{mrDescriptionHasReleaseNotes.js => mrDescriptionReleaseNotes.js} (81%) diff --git a/.gitlab/dangerjs/dangerfile.js b/.gitlab/dangerjs/dangerfile.js index 570bf882a5..d6084cf45c 100644 --- a/.gitlab/dangerjs/dangerfile.js +++ b/.gitlab/dangerjs/dangerfile.js @@ -8,7 +8,7 @@ async function runChecks() { // Checks for merge request description require("./mrDescriptionLongEnough.js")(); - require("./mrDescriptionHasReleaseNotes.js")(); + require("./mrDescriptionReleaseNotes.js")(); await require("./mrDescriptionJiraLinks.js")(); // Checks for documentation diff --git a/.gitlab/dangerjs/mrDescriptionHasReleaseNotes.js b/.gitlab/dangerjs/mrDescriptionReleaseNotes.js similarity index 81% rename from .gitlab/dangerjs/mrDescriptionHasReleaseNotes.js rename to .gitlab/dangerjs/mrDescriptionReleaseNotes.js index 0f764a9b9e..e8691b8509 100644 --- a/.gitlab/dangerjs/mrDescriptionHasReleaseNotes.js +++ b/.gitlab/dangerjs/mrDescriptionReleaseNotes.js @@ -10,16 +10,18 @@ module.exports = function () { const wiki_link = `${process.env.DANGER_GITLAB_HOST}/espressif/esp-idf/-/wikis/rfc/How-to-write-release-notes-properly`; const regexSectionReleaseNotes = /## Release notes([\s\S]*?)(?=## |$)/; - const regexValidEntry = /\s*[-*+]\s+.+/; + const regexValidEntry = /^\s*[-*+]\s+.+/; const regexNoReleaseNotes = /no release note/i; const sectionReleaseNotes = mrDescription.match(regexSectionReleaseNotes); if (!sectionReleaseNotes) { - warn('The `Release Notes` section seems to be missing. Please check if the section header in MR description is present and in the correct markdown format ("## Release Notes").\n\nSee Release Notes Format Rules).'); + warn(`The \`Release Notes\` section seems to be missing. Please check if the section header in MR description is present and in the correct markdown format ("## Release Notes").\n\nSee [Release Notes Format Rules](${wiki_link}).`); return null; } - const lines = sectionReleaseNotes[1].split("\n").filter(s => s.trim().length > 0); + const releaseNotesLines = sectionReleaseNotes[1].replace(//g, '') + + const lines = releaseNotesLines.split("\n").filter(s => s.trim().length > 0); let valid_entries_found = 0; let no_release_notes_found = false; let violations = []; @@ -36,7 +38,7 @@ module.exports = function () { } }); - let error_output = ['']; // Add blank line on purpose, to avoid first line to be indented by dangerjs. + let error_output = []; if (violations.length > 0) { error_output = [...error_output, 'Invalid release note entries:', violations.join('\n')]; } @@ -51,8 +53,8 @@ module.exports = function () { } if (error_output.length > 0) { - //paragraphs joined by double `\n`s. - error_output = [...error_output, `See Release Notes Format Guide.`].join('\n\n'); + // Paragraphs joined by double `\n`s. + error_output = [...error_output, `See [Release Notes Format Guide](${wiki_link}).`].join('\n\n'); warn(error_output); } return null; @@ -72,7 +74,7 @@ function check_entry(entry) { return [entry_str, `${indent}- Please specify the [area] to which the change belongs (see guide). If this line is just a comment, remove the bullet.`].join('\n'); } - const area = match[2]; + // area is in match[2] const description = match[3].trim(); let violations = [];