**/test rating**  <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9796447291> > Commit: 456128bd61a357ada1b3e2cd3937a0ff47d89c26 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9796447291&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Rating` > <hr>Thu, 04 Jul 2024 15:11:09 UTC <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Added the current date and time in UTC to the status messages generated by the Cypress script. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
const HEADER = '<!-- This is an auto-generated comment: Cypress test results -->';
|
|
const FOOTER = '<!-- end of auto-generated comment: Cypress test results -->';
|
|
const PATTERN = new RegExp(HEADER + ".*?" + FOOTER, "ims");
|
|
|
|
// Ref: https://github.com/orgs/community/discussions/16925
|
|
const VALID_ALERT_TYPES = ["note", "tip", "important", "warning", "caution"]
|
|
|
|
const ALERT_PREFIXES = {
|
|
tip: "🟢 🟢 🟢 ",
|
|
important: "🟣 🟣 🟣 ",
|
|
caution: "🔴 🔴 🔴 ",
|
|
}
|
|
|
|
module.exports = async function({core, context, github}, alertType, note) {
|
|
if (!VALID_ALERT_TYPES.includes(alertType)) {
|
|
core.setFailed("Invalid alert type: '" + alertType + "'. Allowed: " + VALID_ALERT_TYPES.join(", ") + ".");
|
|
}
|
|
|
|
const prNumber = context.payload.pull_request?.number;
|
|
|
|
if (!prNumber) {
|
|
core.setFailed(
|
|
`No open pull request found for ${context.eventName}, ${context.sha}`,
|
|
);
|
|
return;
|
|
}
|
|
|
|
const response = await github.rest.pulls.get({
|
|
...context.repo,
|
|
pull_number: prNumber,
|
|
});
|
|
|
|
let body = response?.data?.body;
|
|
if (!body) {
|
|
core.setFailed(JSON.stringify(response, null, 2));
|
|
return;
|
|
}
|
|
|
|
note = [
|
|
HEADER,
|
|
`> [!${alertType.toUpperCase()}]`,
|
|
((ALERT_PREFIXES[alertType] ?? "") + note.trim()).replaceAll(/^/gm, "> "),
|
|
"> <hr>" + new Date().toUTCString().replace("GMT", "UTC"),
|
|
FOOTER,
|
|
].join("\n");
|
|
|
|
if (body.match(PATTERN)) {
|
|
body = body.replace(PATTERN, note);
|
|
} else {
|
|
body += "\n\n" + note + "\n";
|
|
}
|
|
|
|
await github.rest.pulls.update({
|
|
...context.repo,
|
|
pull_number: prNumber,
|
|
body,
|
|
});
|
|
}
|