-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (56 loc) · 1.49 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const core = require("@actions/core");
const json2md = require("json2md");
const { runEvaluator } = require("./evaluator");
const titleByKeys = {
performance: "Média",
totalPercentage: "Percentual de cumprimento de requisitos",
sufficient: "Suficiente",
insufficient: "Insuficiente"
};
const iconByKey = {
positiveIcon: ":white_check_mark:",
negativeIcon: ":x:",
performance: "",
totalPercentage: "%",
};
try {
const testResultsInput = core.getInput("testResults");
const { testResults } = JSON.parse(testResultsInput);
const data = runEvaluator(testResults);
const rows = data.evaluations.map((value, index) => {
const row = [];
row.push(`${index + 1}-${value.description}`);
row.push(value.grade);
row.push(
value.grade === 1 ? iconByKey.positiveIcon : iconByKey.negativeIcon
);
return row;
});
const averageTableRows = Object.keys(data.evaluationByPercentage).map(
(key) => {
const row = [];
row.push(titleByKeys[key]);
row.push(`${titleByKeys[data.evaluationByPercentage[key]] || data.evaluationByPercentage[key]}${iconByKey[key]}`);
return row;
}
);
const report = json2md([
{ h1: "Resultado" },
{
table: {
headers: ["Descrição", "nota", ""],
rows,
},
},
{ h2: "Desempenho" },
{
table: {
headers: ["Item", ""],
rows: averageTableRows,
},
},
]);
core.setOutput("report", report);
} catch (error) {
core.setFailed(error.message);
}