Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | import * as core from '@actions/core';
import { writeFile } from 'fs/promises';
import { makeBadge } from 'badge-maker';
import { inputs } from './config/inputs';
import { coverage, color } from './utils/parsers';
import { decimals } from './utils/numbers';
async function run(): Promise<void> {
try {
const { input, output, label, style } = await inputs();
core.info(`Reading coverage information from "${input}"`);
const { branches } = await coverage(input);
const percentage = decimals(branches * 100, 2);
core.info(`Detected ${percentage}% coverage`);
const result = makeBadge({
label,
style,
color: color(percentage),
message: `${percentage}%`,
});
await writeFile(output, result, 'utf-8');
core.info(`Successfully wrote badge out to "${output}"!`);
core.setOutput('file', output);
} catch (error) {
core.setFailed(`${(error as any)?.message ?? error}`);
}
}
run();
|