Merge branch 'dangerjs/mr_area_labels' into 'master'

add(ci:danger) Check MR area labels

Closes IDF-7075

See merge request espressif/esp-idf!22845
This commit is contained in:
Tomas Sebestik 2023-03-23 19:58:14 +08:00
commit 005ba675f9
2 changed files with 24 additions and 1 deletions

View File

@ -9,7 +9,7 @@ async function runChecks() {
// Checks for merge request description
require("./mrDescriptionLongEnough.js")();
require("./mrDescriptionHasReleaseNotes.js")();
await require('./mrDescriptionJiraLinks.js')();
await require("./mrDescriptionJiraLinks.js")();
// Checks for documentation
require("./mrDocsTranslation.js")();
@ -21,6 +21,9 @@ async function runChecks() {
// Checks for MR code
require("./mrSizeTooLarge.js")();
// Checks for MR area labels
await require("./mrAreaLabels.js")();
// Add success log if no issues
if (
results.fails.length === 0 &&

View File

@ -0,0 +1,20 @@
/**
* Check if MR has area labels (light blue labels)
*
* @dangerjs WARN
*/
module.exports = async function () {
const projectId = 103; // ESP-IDF
const areaLabelColor = "#d2eBFA";
const projectLabels = await danger.gitlab.api.Labels.all(projectId); // Get all project labels
const areaLabels = projectLabels
.filter((label) => label.color === areaLabelColor)
.map((label) => label.name); // Filter only area labels
const mrLabels = danger.gitlab.mr.labels; // Get MR labels
if (!mrLabels.some((label) => areaLabels.includes(label))) {
warn(
`Please add some [area labels](${process.env.DANGER_GITLAB_HOST}/espressif/esp-idf/-/labels) to this MR.`
);
}
};