forked from espressif/esp-idf
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from tasmota/main_work
Main work
- Loading branch information
Showing
632 changed files
with
20,249 additions
and
9,966 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
let outputStatuses = []; | ||
|
||
/** | ||
* Logs the status of a rule with padded formatting and stores it in the `outputStatuses` array. | ||
* If the rule already exists in the array, its status is updated. | ||
* @param message The name of the rule | ||
* @param status The output (exit) status of the rule | ||
*/ | ||
function recordRuleExitStatus(message, status) { | ||
// Check if the rule already exists in the array | ||
const existingRecord = outputStatuses.find( | ||
(rule) => rule.message === message | ||
); | ||
|
||
if (existingRecord) { | ||
// Update the status of the existing rule | ||
existingRecord.status = status; | ||
} else { | ||
// If the rule doesn't exist, add it to the array | ||
outputStatuses.push({ message, status }); | ||
} | ||
} | ||
|
||
/** | ||
* Displays all the rule output statuses stored in the `outputStatuses` array. | ||
* Filters out any empty lines, sorts them alphabetically, and prints the statuses | ||
* with a header and separator. | ||
* These statuses are later displayed in CI job tracelog. | ||
*/ | ||
function displayAllOutputStatuses() { | ||
const lineLength = 100; | ||
const sortedStatuses = outputStatuses.sort((a, b) => | ||
a.message.localeCompare(b.message) | ||
); | ||
|
||
const formattedLines = sortedStatuses.map((statusObj) => { | ||
const paddingLength = | ||
lineLength - statusObj.message.length - statusObj.status.length; | ||
const paddedMessage = statusObj.message.padEnd( | ||
statusObj.message.length + paddingLength, | ||
"." | ||
); | ||
return `${paddedMessage} ${statusObj.status}`; | ||
}); | ||
|
||
console.log( | ||
"DangerJS checks (rules) output states:\n" + "=".repeat(lineLength + 2) | ||
); | ||
console.log(formattedLines.join("\n")); | ||
console.log("=".repeat(lineLength + 2)); | ||
} | ||
|
||
module.exports = { | ||
displayAllOutputStatuses, | ||
recordRuleExitStatus, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
const { recordRuleExitStatus } = require("./configParameters.js"); | ||
|
||
/** | ||
* Check if the author is accidentally making a commit using a personal email | ||
* | ||
* @dangerjs INFO | ||
*/ | ||
module.exports = function () { | ||
const ruleName = 'Commits from outside Espressif'; | ||
const mrCommitAuthorEmails = danger.gitlab.commits.map(commit => commit.author_email); | ||
const mrCommitCommitterEmails = danger.gitlab.commits.map(commit => commit.committer_email); | ||
const emailPattern = /.*@espressif\.com/; | ||
const filteredEmails = [...mrCommitAuthorEmails, ...mrCommitCommitterEmails].filter((email) => !emailPattern.test(email)); | ||
if (filteredEmails.length) { | ||
recordRuleExitStatus(ruleName, "Failed"); | ||
return message( | ||
`Some of the commits were authored or committed by developers outside Espressif: ${filteredEmails.join(', ')}. Please check if this is expected.` | ||
); | ||
} | ||
|
||
// At this point, the rule has passed | ||
recordRuleExitStatus(ruleName, 'Passed'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
const { recordRuleExitStatus } = require("./configParameters.js"); | ||
|
||
/** | ||
* Check if MR has not an excessive numbers of commits (if squashed) | ||
* | ||
* @dangerjs INFO | ||
*/ | ||
module.exports = function () { | ||
const ruleName = 'Number of commits in merge request'; | ||
const tooManyCommitThreshold = 2; // above this number of commits, squash commits is suggested | ||
const mrCommits = danger.gitlab.commits; | ||
|
||
if (mrCommits.length > tooManyCommitThreshold) { | ||
recordRuleExitStatus(ruleName, "Passed (with suggestions)"); | ||
return message( | ||
`You might consider squashing your ${mrCommits.length} commits (simplifying branch history).` | ||
); | ||
} | ||
|
||
// At this point, the rule has passed | ||
recordRuleExitStatus(ruleName, 'Passed'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
const { recordRuleExitStatus } = require("./configParameters.js"); | ||
|
||
/** | ||
* Check if MR Description has accurate description". | ||
* | ||
* @dangerjs WARN | ||
*/ | ||
module.exports = function () { | ||
const ruleName = "Merge request sufficient description"; | ||
const mrDescription = danger.gitlab.mr.description; | ||
const descriptionChunk = mrDescription.match(/^([^#]*)/)[1].trim(); // Extract all text before the first section header (i.e., the text before the "## Release notes") | ||
|
||
const shortMrDescriptionThreshold = 50; // Description is considered too short below this number of characters | ||
|
||
if (descriptionChunk.length < shortMrDescriptionThreshold) { | ||
recordRuleExitStatus(ruleName, "Failed"); | ||
return warn( | ||
"The MR description looks very brief, please check if more details can be added." | ||
); | ||
} | ||
|
||
// At this point, the rule has passed | ||
recordRuleExitStatus(ruleName, "Passed"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
const { recordRuleExitStatus } = require("./configParameters.js"); | ||
|
||
/** | ||
* Check if MR is too large (more than 1000 lines of changes) | ||
* | ||
* @dangerjs INFO | ||
*/ | ||
module.exports = async function () { | ||
const ruleName = "Merge request size (number of changed lines)"; | ||
const bigMrLinesOfCodeThreshold = 1000; | ||
const totalLines = await danger.git.linesOfCode(); | ||
|
||
if (totalLines > bigMrLinesOfCodeThreshold) { | ||
recordRuleExitStatus(ruleName, "Passed (with suggestions)"); | ||
return message( | ||
`This MR seems to be quite large (total lines of code: ${totalLines}), you might consider splitting it into smaller MRs` | ||
); | ||
} | ||
|
||
// At this point, the rule has passed | ||
recordRuleExitStatus(ruleName, "Passed"); | ||
}; |
Oops, something went wrong.