@dragonshorn-studios/elyseum-cli 1.0.8 → 1.0.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"diff-coverage-command.d.ts","sourceRoot":"","sources":["../../src/commands/diff-coverage-command.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAe,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAMjD,qBAAa,mBAAoB,YAAW,OAAO;IACjD,IAAI,EAAE,MAAM,CAAmB;IAC/B,MAAM,CAAC,EAAE,YAAY,CA2BnB;gBACU,QAAQ,EAAE,UAAU;IAInB,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;YAqI5B,qBAAqB;YA2JrB,iBAAiB;YAajB,eAAe;CA4E9B"}
1
+ {"version":3,"file":"diff-coverage-command.d.ts","sourceRoot":"","sources":["../../src/commands/diff-coverage-command.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAe,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAMjD,qBAAa,mBAAoB,YAAW,OAAO;IACjD,IAAI,EAAE,MAAM,CAAmB;IAC/B,MAAM,CAAC,EAAE,YAAY,CA2BnB;gBACU,QAAQ,EAAE,UAAU;IAInB,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;YAqI5B,qBAAqB;YAgLrB,iBAAiB;YAajB,eAAe;CA4E9B"}
package/dist/index.js CHANGED
@@ -24993,6 +24993,10 @@ class GithubPRCommentCoverageReporter {
24993
24993
  type: "int",
24994
24994
  default: 50,
24995
24995
  },
24996
+ "fail-action-on-quality-gate": {
24997
+ help: "Mark the check as failed if the quality gate is not met",
24998
+ action: "store_true",
24999
+ },
24996
25000
  };
24997
25001
  }
24998
25002
  report(diffCoverage) {
@@ -25011,6 +25015,7 @@ class GithubPRCommentCoverageReporter {
25011
25015
  "reporter.coverage.quality-gate-fail",
25012
25016
  "reporter.coverage.github-pr-comment.quality-gate-fail",
25013
25017
  ], 50);
25018
+ const failActionOnQualityGate = Config$1.getInstance().getFirst(["reporter.coverage.github-pr-comment.fail-action-on-quality-gate"], false);
25014
25019
  const commentFilePath = Config$1.getInstance().getFirst(["reporter.coverage.github-pr-comment.comment-file-path"], "coverage/github.pr.coverage.md");
25015
25020
  const annotationFilePath = Config$1.getInstance().getFirst(["reporter.coverage.github-pr-comment.annotation-file-path"], "coverage/github.pr.annotations.json");
25016
25021
  let repoName = process.env.GITHUB_REPOSITORY || "";
@@ -25088,13 +25093,25 @@ class GithubPRCommentCoverageReporter {
25088
25093
  let annotations = [];
25089
25094
  if (createAnnotations) {
25090
25095
  for (const file of diffCoverage.files) {
25096
+ for (let lineBlock of file.lines.details || []) {
25097
+ if (lineBlock.hit === 0) {
25098
+ annotations.push({
25099
+ path: file.file,
25100
+ start_line: lineBlock.start,
25101
+ end_line: lineBlock.end,
25102
+ annotation_level: qualityGateFailed ? "failure" : "warning",
25103
+ title: "Lines not covered",
25104
+ message: `Lines not covered`,
25105
+ });
25106
+ }
25107
+ }
25091
25108
  for (let functionDetails of file.functions.details || []) {
25092
25109
  if (functionDetails.hit === 0) {
25093
25110
  annotations.push({
25094
25111
  path: file.file,
25095
25112
  start_line: functionDetails.line,
25096
25113
  end_line: functionDetails.line,
25097
- annotation_level: qualityGateFailed ? "warning" : "warning",
25114
+ annotation_level: qualityGateFailed ? "failure" : "warning",
25098
25115
  title: "Function not covered",
25099
25116
  message: `Function ${functionDetails.name} not covered`,
25100
25117
  });
@@ -25106,7 +25123,7 @@ class GithubPRCommentCoverageReporter {
25106
25123
  path: file.file,
25107
25124
  start_line: branchDetails.line,
25108
25125
  end_line: branchDetails.line,
25109
- annotation_level: qualityGateFailed ? "warning" : "warning",
25126
+ annotation_level: qualityGateFailed ? "failure" : "warning",
25110
25127
  title: "Branch not covered",
25111
25128
  message: `Branch not covered`,
25112
25129
  });
@@ -25121,7 +25138,9 @@ class GithubPRCommentCoverageReporter {
25121
25138
  head_sha: diffCoverage.headSha,
25122
25139
  status: "completed",
25123
25140
  conclusion: qualityGateFailed
25124
- ? "neutral"
25141
+ ? failActionOnQualityGate
25142
+ ? "failure"
25143
+ : "neutral"
25125
25144
  : qualityGateWarning
25126
25145
  ? "neutral"
25127
25146
  : "success",
@@ -54446,11 +54465,29 @@ class DiffCoverageCommand {
54446
54465
  let changedLineNumbers = new Set();
54447
54466
  let changedLineCount = 0;
54448
54467
  for (let hunk of file.diff.hunks) {
54468
+ let hunkLine = 0;
54449
54469
  for (let line = hunk.newStart; line < hunk.newStart + hunk.newLines; line++) {
54470
+ if (hunk.lines) {
54471
+ if (hunk.lines[hunkLine].startsWith("-")) {
54472
+ continue;
54473
+ }
54474
+ else if (hunk.lines[hunkLine].startsWith("+")) {
54475
+ // ignore comment lines
54476
+ const changedLine = hunk.lines[hunkLine].replace(/^\+/, "");
54477
+ if (changedLine.trim().startsWith("//") ||
54478
+ changedLine.trim() === "" ||
54479
+ changedLine.trim().startsWith("/*") ||
54480
+ changedLine.trim().startsWith("*")) {
54481
+ continue;
54482
+ }
54483
+ }
54484
+ }
54450
54485
  changedLineNumbers.add(line);
54486
+ hunkLine++;
54451
54487
  }
54452
- changedLineCount += hunk.newLines;
54453
54488
  }
54489
+ changedLineCount = changedLineNumbers.size;
54490
+ Logger.debug(`Changed line count for file ${normalizedPath}: ${changedLineCount}`);
54454
54491
  let coveredLines = 0;
54455
54492
  let coveredFunctions = 0;
54456
54493
  let totalFunctions = 0;