Skip to content

Commit

Permalink
Pull totals out into their own summary.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgillick committed Jan 5, 2023
1 parent 3ad6698 commit 96a14cd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 19 deletions.
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27040,7 +27040,7 @@ function getTemplateVars(report, failureMessage, inputs) {
commitSha,
commitUrl,
prIdentifier: PR_COMMENT_IDENTIFIER,
renderFileSummary: renderFileSummaryFactory(inputs),
renderFileSummaryTableRow: renderFileSummaryFactory(inputs),
};
const { stripPathPrefix } = inputs;
const failFileReduced = inputs.failFileReduced > 0
Expand Down Expand Up @@ -27173,7 +27173,7 @@ exports.createSummary = createSummary;
function renderFileSummaryFactory(inputs) {
var _a;
const hasDiffs = ((_a = inputs.baseCoveragePath) === null || _a === void 0 ? void 0 : _a.length) > 0;
return function renderFileSummary(summary) {
return function renderFileSummaryTableRow(summary) {
const linePercent = Number(summary.lines.percent);
let status = ":red_circle:";
if (linePercent > 80) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions dist/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Commit: <%= commitSha %>
<%= customMessage %>
<% } %>

<!-- Summary -->
Summary

| Name | Stmts | Branch | Funcs | Lines |
| ---- | ----- | ------ | ----- | ----- |
<%= renderFileSummaryTableRow(total) %>

<!-- All files, if diffs aren't present -->

<% if (!hasDiffs && all.length){ %>
Expand All @@ -25,8 +32,7 @@ All files

| Name | Stmts | Branch | Funcs | Lines |
| ---- | ----- | ------ | ----- | ----- |
<%= renderFileSummary(total) %>
<%= all.map((fileSummary) => renderFileSummary(fileSummary)).join('\n') %>
<%= all.map((fileSummary) => renderFileSummaryTableRow(fileSummary)).join('\n') %>

</details>
<% } %>
Expand All @@ -37,8 +43,7 @@ All files

| Name | Stmts | Branch | Funcs | Lines |
| ---- | ----- | ------ | ----- | ----- |
<%= renderFileSummary(total) %>
<%= changed.map((fileSummary) => renderFileSummary(fileSummary)).join('\n') %>
<%= changed.map((fileSummary) => renderFileSummaryTableRow(fileSummary)).join('\n') %>
<% } %>

<!-- Unchanged files -->
Expand All @@ -52,10 +57,10 @@ Unchanged files

| Name | Stmts | Branch | Funcs | Lines |
| ---- | ----- | ------ | ----- | ----- |
<%= unchanged.map((fileSummary) => renderFileSummary(fileSummary)).join('\n') %>
<%= unchanged.map((fileSummary) => renderFileSummaryTableRow(fileSummary)).join('\n') %>

</details>
<% } %>

<!-- Footer -->
<p align="right">Generated by <a href="https://github.com/jgillick/test-coverage-reporter">Test Coverage Reporter</a> from commit <%= commitSha %></p>
<p align="right">Generated by <a href="https://github.com/jgillick/test-coverage-reporter">Test Coverage Reporter</a> for commit <%= commitSha %></p>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "test-coverage-reporter",
"version": "1.0.6",
"version": "1.0.7",
"description": "Generate a test coverage report for a PR",
"main": "dist/index.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function getTemplateVars(
commitUrl,
prIdentifier: PR_COMMENT_IDENTIFIER,

renderFileSummary: renderFileSummaryFactory(inputs),
renderFileSummaryTableRow: renderFileSummaryFactory(inputs),
};
const { stripPathPrefix } = inputs;
const failFileReduced =
Expand Down Expand Up @@ -235,7 +235,8 @@ export function createSummary(output: string, failed: boolean, inputs: Inputs) {
*/
function renderFileSummaryFactory(inputs: Inputs) {
const hasDiffs = inputs.baseCoveragePath?.length > 0;
return function renderFileSummary(summary: TemplateDiffSummary) {

return function renderFileSummaryTableRow(summary: TemplateDiffSummary) {
const linePercent = Number(summary.lines.percent);

let status = ":red_circle:";
Expand Down
17 changes: 11 additions & 6 deletions src/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Commit: <%= commitSha %>
<%= customMessage %>
<% } %>

<!-- Summary -->
Summary

| Name | Stmts | Branch | Funcs | Lines |
| ---- | ----- | ------ | ----- | ----- |
<%= renderFileSummaryTableRow(total) %>

<!-- All files, if diffs aren't present -->

<% if (!hasDiffs && all.length){ %>
Expand All @@ -25,8 +32,7 @@ All files

| Name | Stmts | Branch | Funcs | Lines |
| ---- | ----- | ------ | ----- | ----- |
<%= renderFileSummary(total) %>
<%= all.map((fileSummary) => renderFileSummary(fileSummary)).join('\n') %>
<%= all.map((fileSummary) => renderFileSummaryTableRow(fileSummary)).join('\n') %>

</details>
<% } %>
Expand All @@ -37,8 +43,7 @@ All files

| Name | Stmts | Branch | Funcs | Lines |
| ---- | ----- | ------ | ----- | ----- |
<%= renderFileSummary(total) %>
<%= changed.map((fileSummary) => renderFileSummary(fileSummary)).join('\n') %>
<%= changed.map((fileSummary) => renderFileSummaryTableRow(fileSummary)).join('\n') %>
<% } %>

<!-- Unchanged files -->
Expand All @@ -52,10 +57,10 @@ Unchanged files

| Name | Stmts | Branch | Funcs | Lines |
| ---- | ----- | ------ | ----- | ----- |
<%= unchanged.map((fileSummary) => renderFileSummary(fileSummary)).join('\n') %>
<%= unchanged.map((fileSummary) => renderFileSummaryTableRow(fileSummary)).join('\n') %>

</details>
<% } %>

<!-- Footer -->
<p align="right">Generated by <a href="https://github.com/jgillick/test-coverage-reporter">Test Coverage Reporter</a> from commit <%= commitSha %></p>
<p align="right">Generated by <a href="https://github.com/jgillick/test-coverage-reporter">Test Coverage Reporter</a> for commit <%= commitSha %></p>
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export type TemplateVars = {
unchanged: TemplateDiffSummary[];
all: TemplateDiffSummary[];

renderFileSummary: Function;
renderFileSummaryTableRow: Function;
};

export type TemplateDiffTotals = {
Expand Down

0 comments on commit 96a14cd

Please sign in to comment.