-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (32 loc) · 1.21 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
const core = require('@actions/core');
const xmlParser = require('./xmlParser');
const computation = require('./computation');
const reporter = require('./reporter');
async function run() {
const xmlReportPath = core.getInput('xml-report-path');
const threshold = parseInt(core.getInput('threshold'));
const failWorkflow = /true/i.test(core.getInput('fail-workflow'));
const maxAnnotations = parseInt(core.getInput('max-annotations'));
if (threshold < 0 || threshold > 100) {
core.setFailed(
`Threshold must be a number between 0 and 100. Invalid value: ${threshold}`
);
}
if (maxAnnotations < 0 || maxAnnotations > 50) {
core.setFailed(
`GitHub API does not allow to create more than 50 annotations. Invalid value: ${maxAnnotations}`
);
}
const mutations = xmlParser.readFile(xmlReportPath);
const result = computation.computeResult(mutations, threshold);
await reporter.reportMutationTesting(result, maxAnnotations);
if (failWorkflow && result.pass === false) {
core.setFailed(
`Test strength is not good enough: ${result.testStrength}% (required was ${result.threshold}%)`
);
}
}
run().catch((error) => core.setFailed(error.message));
module.exports = {
run,
};