@dragonshorn-studios/elyseum-cli 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/diff-coverage-command.d.ts.map +1 -1
- package/dist/index.js +54 -25
- package/dist/index.js.map +1 -1
- package/dist/types/coverage-result.d.ts +2 -0
- package/dist/types/coverage-result.d.ts.map +1 -1
- package/dist/utils/reporters/coverage/github-pr-comment.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff-coverage-command.d.ts","sourceRoot":"","sources":["../../src/commands/diff-coverage-command.ts"],"names":[],"mappings":"AAaA,qBAAa,mBAAmB;;IAGjB,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"diff-coverage-command.d.ts","sourceRoot":"","sources":["../../src/commands/diff-coverage-command.ts"],"names":[],"mappings":"AAaA,qBAAa,mBAAmB;;IAGjB,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;YAuD5B,qBAAqB;YAuIrB,iBAAiB;YAYjB,eAAe;CA4E9B"}
|
package/dist/index.js
CHANGED
|
@@ -38910,21 +38910,40 @@ class GithubPRCommentCoverageReporter {
|
|
|
38910
38910
|
this.quality_gate_failed = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm8.036-4.024a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042L10.939 12l-2.963 2.963a.749.749 0 0 0 .326 1.275.749.749 0 0 0 .734-.215L12 13.06l2.963 2.964a.75.75 0 0 0 1.061-1.06L13.061 12l2.963-2.964a.749.749 0 0 0-.326-1.275.749.749 0 0 0-.734.215L12 10.939Z"></path></svg>`;
|
|
38911
38911
|
}
|
|
38912
38912
|
report(diffCoverage) {
|
|
38913
|
-
|
|
38913
|
+
// check if we have github ci environment variables, and if not, return
|
|
38914
|
+
if (!process.env.GITHUB_ACTIONS || !process.env.GITHUB_EVENT_NAME) {
|
|
38915
|
+
console.error("Not running in GitHub CI environment, skipping GitHub PR comment coverage reporter");
|
|
38916
|
+
return;
|
|
38917
|
+
}
|
|
38918
|
+
const reportPath = Config.getInstance().getFirst(["reporter.coverage.github-pr-comment.comment-file-path"], "coverage/github.pr.coverage.md");
|
|
38919
|
+
const commentName = Config.getInstance().getFirst(["reporter.coverage.github-pr-comment.comment-name"], "coverage/github.pr.coverage.md");
|
|
38914
38920
|
const qualityGate = Config.getInstance().getFirst(["reporter.coverage.qualityGate"], 80);
|
|
38921
|
+
let repoName = process.env.GITHUB_REPOSITORY;
|
|
38922
|
+
let runId = process.env.GITHUB_RUN_ID;
|
|
38923
|
+
let markdown = `## ${commentName}\n\n`;
|
|
38924
|
+
// lines, functions, branches average percentage must be greater than or equal to qualityGate
|
|
38925
|
+
const qualityGateFailed = diffCoverage.lines.percent < qualityGate ||
|
|
38926
|
+
diffCoverage.functions.percent < qualityGate ||
|
|
38927
|
+
diffCoverage.branches.percent < qualityGate;
|
|
38928
|
+
let coverageQualityText = ``;
|
|
38929
|
+
if (qualityGate) {
|
|
38930
|
+
if (qualityGateFailed) {
|
|
38931
|
+
coverageQualityText += `> [!CAUTION]\n### Coverage Quality Gate Failed ${qualityGateFailed}`;
|
|
38932
|
+
}
|
|
38933
|
+
else {
|
|
38934
|
+
coverageQualityText += `> [!TIP]\n### Coverage Quality Gate Passed ${qualityGateFailed}`;
|
|
38935
|
+
}
|
|
38936
|
+
coverageQualityText += `> ${this.getIcon(diffCoverage.lines.percent)} Lines: ${diffCoverage.lines.percent.toFixed(2)}% (baseline: ${qualityGate}%)\n`;
|
|
38937
|
+
coverageQualityText += `> ${this.getIcon(diffCoverage.functions.percent)} Functions: ${diffCoverage.functions.percent.toFixed(2)}% (baseline: ${qualityGate}%)\n`;
|
|
38938
|
+
coverageQualityText += `> ${this.getIcon(diffCoverage.branches.percent)} Branches: ${diffCoverage.branches.percent.toFixed(2)}% (baseline: ${qualityGate}%)\n\n`;
|
|
38939
|
+
}
|
|
38915
38940
|
let summary = `| Type | Total | Covered | Percent |\n`;
|
|
38916
38941
|
summary += `|-----------|-------|---------|---------|\n`;
|
|
38917
38942
|
summary += `| Lines | ${diffCoverage.lines.total} | ${diffCoverage.lines.covered} | ${this.getIcon(diffCoverage.lines.percent)} ${diffCoverage.lines.percent.toFixed(2)}% |\n`;
|
|
38918
38943
|
summary += `| Functions | ${diffCoverage.functions.total} | ${diffCoverage.functions.covered} | ${this.getIcon(diffCoverage.functions.percent)} ${diffCoverage.functions.percent.toFixed(2)}% |\n`;
|
|
38919
38944
|
summary += `| Branches | ${diffCoverage.branches.total} | ${diffCoverage.branches.covered} | ${this.getIcon(diffCoverage.branches.percent)} ${diffCoverage.branches.percent.toFixed(2)}% |\n`;
|
|
38920
|
-
|
|
38921
|
-
|
|
38922
|
-
const qualityGateFailed = diffCoverage.lines.percent < qualityGate ||
|
|
38923
|
-
diffCoverage.functions.percent < qualityGate ||
|
|
38924
|
-
diffCoverage.branches.percent < qualityGate;
|
|
38925
|
-
markdown += `\n\n### Coverage Quality Gate: ${qualityGateFailed
|
|
38926
|
-
? `Failed <span style='color: #cb2431;'>${this.quality_gate_failed}</span>`
|
|
38927
|
-
: `Passed <span style='color: #28a745;'>${this.quality_gate_passed}</span>`}`;
|
|
38945
|
+
markdown += `### Coverage Summary\n\n${summary}`;
|
|
38946
|
+
markdown += coverageQualityText;
|
|
38928
38947
|
let detailsTable = `\n<details>\n<summary>Coverage Details</summary>\n\n`;
|
|
38929
38948
|
detailsTable += `| File | Lines (%) | Functions (%) | Branches (%) |\n`;
|
|
38930
38949
|
detailsTable += `|------|-----------|---------------|--------------|\n`;
|
|
@@ -38933,10 +38952,15 @@ class GithubPRCommentCoverageReporter {
|
|
|
38933
38952
|
}
|
|
38934
38953
|
detailsTable += `\n</details>\n`;
|
|
38935
38954
|
markdown += detailsTable;
|
|
38936
|
-
|
|
38937
|
-
|
|
38955
|
+
let reportInfo = `Report for commit ${diffCoverage.headSha}`;
|
|
38956
|
+
if (diffCoverage.baseSha) {
|
|
38957
|
+
reportInfo += ` against base commit ${diffCoverage.baseSha}`;
|
|
38938
38958
|
}
|
|
38939
|
-
|
|
38959
|
+
reportInfo += ` (triggering run: <a href="/${repoName}/actions/runs/${runId}">${runId}</a>)`;
|
|
38960
|
+
fs$1.mkdirSync(reportPath.substring(0, reportPath.lastIndexOf("/")), {
|
|
38961
|
+
recursive: true,
|
|
38962
|
+
});
|
|
38963
|
+
fs$1.writeFileSync(reportPath, markdown);
|
|
38940
38964
|
}
|
|
38941
38965
|
getIcon(percent) {
|
|
38942
38966
|
if (percent >= 80) {
|
|
@@ -38989,17 +39013,17 @@ class DiffCoverageCommand {
|
|
|
38989
39013
|
"**/*.vue",
|
|
38990
39014
|
];
|
|
38991
39015
|
try {
|
|
38992
|
-
|
|
38993
|
-
|
|
38994
|
-
|
|
38995
|
-
|
|
38996
|
-
|
|
38997
|
-
|
|
38998
|
-
|
|
38999
|
-
|
|
39000
|
-
|
|
39001
|
-
|
|
39002
|
-
let files = await this.getChangedFiles(process.cwd(),
|
|
39016
|
+
let headSha = await git.resolveRef({
|
|
39017
|
+
fs: fs$2,
|
|
39018
|
+
dir: process.cwd(),
|
|
39019
|
+
ref: args.head || process.env.GITHUB_SHA || "HEAD",
|
|
39020
|
+
});
|
|
39021
|
+
let baseSha = await git.resolveRef({
|
|
39022
|
+
fs: fs$2,
|
|
39023
|
+
dir: process.cwd(),
|
|
39024
|
+
ref: args.base || process.env.GITHUB_BASE_REF || "origin/main",
|
|
39025
|
+
});
|
|
39026
|
+
let files = await this.getChangedFiles(process.cwd(), headSha, baseSha);
|
|
39003
39027
|
files = files.filter((file) => {
|
|
39004
39028
|
return (!coverageExcludes.some((exclude) => {
|
|
39005
39029
|
return minimatch(file.path.replace(/^\//, ""), exclude);
|
|
@@ -39009,7 +39033,10 @@ class DiffCoverageCommand {
|
|
|
39009
39033
|
}));
|
|
39010
39034
|
});
|
|
39011
39035
|
let coverage = await this.getCoverageReport("coverage/lcov.info");
|
|
39012
|
-
let diffCoverage = await this.calculateDiffCoverage(files, coverage
|
|
39036
|
+
let diffCoverage = await this.calculateDiffCoverage(files, coverage, {
|
|
39037
|
+
headSha,
|
|
39038
|
+
baseSha,
|
|
39039
|
+
});
|
|
39013
39040
|
for (let reporter of getCoverageReportersFromArgs(args)) {
|
|
39014
39041
|
reporter.report(diffCoverage);
|
|
39015
39042
|
}
|
|
@@ -39018,8 +39045,10 @@ class DiffCoverageCommand {
|
|
|
39018
39045
|
console.error(error);
|
|
39019
39046
|
}
|
|
39020
39047
|
}
|
|
39021
|
-
async calculateDiffCoverage(files, coverage) {
|
|
39048
|
+
async calculateDiffCoverage(files, coverage, { headSha, baseSha }) {
|
|
39022
39049
|
const diffCoverageResult = {
|
|
39050
|
+
headSha,
|
|
39051
|
+
baseSha,
|
|
39023
39052
|
lines: {
|
|
39024
39053
|
total: 0,
|
|
39025
39054
|
covered: 0,
|