Skip to content

Commit 0e59aaa

Browse files
committed
🚧 Tweak more stuff
1 parent d8781a6 commit 0e59aaa

3 files changed

Lines changed: 71 additions & 71 deletions

File tree

action/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

action/run.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export const run = async (): Promise<void> => {
6464
conclusion: "neutral",
6565
output: {
6666
title: `${coverage}% Coverage`,
67-
summary: `The following is the Typescript Coverage Report for this Pull Request
67+
summary: `The following is the **Typescript** Coverage Report for this Pull Request
68+
6869
### Indicators
6970
🟥 -> Indicates that the file has failed the type threshold (${threshold}%)
7071
🟩 -> Indicates that the file has passed the type threshold (${threshold}%)

src/lib/reporters/markdown.ts

Lines changed: 68 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,94 @@
22
import Table from "markdown-table";
33
import { CoverageData } from "../getCoverage";
44
import "colors";
5-
import * as core from "@actions/core";
65

76
const coverageTableArray: Array<Array<string>> = [];
87

98
const calculatePercantage = (correct: number, total: number): number => {
10-
if (total === 0) {
11-
return 100;
12-
}
9+
if (total === 0) {
10+
return 100;
11+
}
1312

14-
return (correct * 100) / total;
13+
return (correct * 100) / total;
1514
};
1615

1716
const calculatePercantageWithString = (
18-
correct: number,
19-
total: number
17+
correct: number,
18+
total: number
2019
): string => {
21-
return `${calculatePercantage(correct, total).toFixed(2)}%`;
20+
return `${calculatePercantage(correct, total).toFixed(2)}%`;
2221
};
2322

2423
export const generate = (
25-
{ fileCounts, percentage, total, covered, uncovered }: CoverageData,
26-
threshold: number,
27-
baseURL: string
24+
{ fileCounts, percentage, total, covered, uncovered }: CoverageData,
25+
threshold: number,
26+
baseURL: string
2827
): string => {
29-
let row = 1;
30-
const headers = [
31-
"status",
32-
"filenames" + ` (${fileCounts.size})`.gray,
33-
"percent" + ` (${percentage.toFixed(2)}%)`.gray,
34-
"total" + ` (${total})`.gray,
35-
"covered" + ` (${covered})`.gray,
36-
"uncovered" + ` (${uncovered})`.gray
37-
];
28+
let row = 1;
29+
const headers = [
30+
"status",
31+
"filenames" + ` (${fileCounts.size})`.gray,
32+
"percent" + ` (${percentage.toFixed(2)}%)`.gray,
33+
"total" + ` (${total})`.gray,
34+
"covered" + ` (${covered})`.gray,
35+
"uncovered" + ` (${uncovered})`.gray
36+
];
3837

39-
coverageTableArray.push(
40-
headers
41-
// headers.map(() => "---".gray)
42-
);
38+
coverageTableArray.push(
39+
headers
40+
// headers.map(() => "---".gray)
41+
);
4342

44-
// coverageTable.attrRange(
45-
// { column: [1, 5] },
46-
// {
47-
// align: "right"
48-
// }
49-
// );
43+
// coverageTable.attrRange(
44+
// { column: [1, 5] },
45+
// {
46+
// align: "right"
47+
// }
48+
// );
5049

51-
fileCounts.forEach(
52-
(
53-
{
54-
totalCount,
55-
correctCount
56-
}: { totalCount: number; correctCount: number },
57-
filename: string
58-
) => {
59-
row++;
50+
fileCounts.forEach(
51+
(
52+
{
53+
totalCount,
54+
correctCount
55+
}: { totalCount: number; correctCount: number },
56+
filename: string
57+
) => {
58+
row++;
6059

61-
const fileTypePercentage = Math.floor(
62-
calculatePercantage(correctCount, totalCount)
63-
);
60+
const fileTypePercentage = Math.floor(
61+
calculatePercantage(correctCount, totalCount)
62+
);
6463

65-
const thresholdPassed = fileTypePercentage >= threshold;
64+
const thresholdPassed = fileTypePercentage >= threshold;
6665

67-
const hyperlinedFileName = `[\`${filename}\`](${baseURL}/${filename})`;
66+
const hyperlinedFileName = `[\`${filename}\`](${baseURL}/${filename})`;
6867

69-
/**
70-
* Insert a 🟥 to indicate that this file has failed the threshold
71-
* or insert a 🟩
72-
*/
73-
coverageTableArray.push([
74-
thresholdPassed ? "🟩" : "🟥",
75-
hyperlinedFileName,
76-
calculatePercantageWithString(correctCount, totalCount),
77-
totalCount.toString(),
78-
correctCount.toString(),
79-
(totalCount - correctCount).toString()
80-
]);
68+
/**
69+
* Insert a 🟥 to indicate that this file has failed the threshold
70+
* or insert a 🟩
71+
*/
72+
coverageTableArray.push([
73+
thresholdPassed ? "🟩" : "🟥",
74+
hyperlinedFileName,
75+
calculatePercantageWithString(correctCount, totalCount),
76+
totalCount.toString(),
77+
correctCount.toString(),
78+
(totalCount - correctCount).toString()
79+
]);
8180

82-
// coverageTableArray.attrRange(
83-
// { row: [row] },
84-
// {
85-
// color:
86-
// Math.floor(calculatePercantage(correctCount, totalCount)) >=
87-
// threshold
88-
// ? "green"
89-
// : "red"
90-
// }
91-
// );
92-
}
93-
);
81+
// coverageTableArray.attrRange(
82+
// { row: [row] },
83+
// {
84+
// color:
85+
// Math.floor(calculatePercantage(correctCount, totalCount)) >=
86+
// threshold
87+
// ? "green"
88+
// : "red"
89+
// }
90+
// );
91+
}
92+
);
9493

95-
return Table(coverageTableArray);
94+
return Table(coverageTableArray);
9695
};

0 commit comments

Comments
 (0)