Skip to content

Commit

Permalink
⚗️ Test for CI System (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
soo-bak committed Jul 7, 2024
1 parent 0754905 commit f564612
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions .github/workflows/UnitTestsAndCodeCoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,36 +136,42 @@ jobs:
const lineCoverage = summary.Linecoverage[0];
const methodCoverage = summary.Methodcoverage[0];
let formattedLineCoverage = lineCoverage === "100"
? "$\\color{green}{" + lineCoverage + "\\%}$"
: "$\\color{red}{" + lineCoverage + "\\%}$";
let formattedMethodCoverage = methodCoverage === "100"
? "$\\color{green}{" + methodCoverage + "\\%}$"
: "$\\color{red}{" + methodCoverage + "\\%}$";
const formattedLineCoverage = formatCoverage(lineCoverage);
const formattedMethodCoverage = formatCoverage(methodCoverage);
return `
## 🍉 Code Coverage Summary 🧐
| Metric | Value |
|----------------------|------------------------------|
| Generated on | \${summary.Generatedon[0]} |
| Assemblies | \${summary.Assemblies[0]} |
| Classes | \${summary.Classes[0]} |
| Files | \${summary.Files[0]} |
| Covered Lines | \${summary.Coveredlines[0]} |
| Uncovered Lines | \${summary.Uncoveredlines[0]} |
| Coverable Lines | \${summary.Coverablelines[0]} |
| Total Lines | \${summary.Totallines[0]} |
| Line Coverage | \${formattedLineCoverage} |
| Covered Methods | \${summary.Coveredmethods[0]} |
| Total Methods | \${summary.Totalmethods[0]} |
| Method Coverage | \${formattedMethodCoverage} |
| Generated on | ${summary.Generatedon[0]} |
| Assemblies | ${summary.Assemblies[0]} |
| Classes | ${summary.Classes[0]} |
| Files | ${summary.Files[0]} |
| Covered Lines | ${summary.Coveredlines[0]} |
| Uncovered Lines | ${summary.Uncoveredlines[0]} |
| Coverable Lines | ${summary.Coverablelines[0]} |
| Total Lines | ${summary.Totallines[0]} |
| Line Coverage | ${formattedLineCoverage} |
| Covered Methods | ${summary.Coveredmethods[0]} |
| Total Methods | ${summary.Totalmethods[0]} |
| Method Coverage | ${formattedMethodCoverage} |
---
`;
}
function formatCoverage(coverage) {
const coverageNum = parseFloat(coverage);
if (coverageNum === 100) {
return `**${coverageNum}%**`;
} else if (coverageNum >= 80) {
return `_${coverageNum}%_`;
} else {
return `~~${coverageNum}%~~`;
}
}
async function deleteExistingCommentAndCreateNew(body) {
const { data: comments } = await github.rest.issues.listComments({
...context.repo,
Expand All @@ -185,12 +191,17 @@ jobs:
console.log('Deleted existing comment');
}
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body,
});
console.log('Created new comment');
try {
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body,
});
console.log('Created new comment');
} catch (error) {
console.error('Error creating comment:', error);
process.exit(1);
}
}
run();
Expand Down

0 comments on commit f564612

Please sign in to comment.