Skip to content

feat , check for min_coverage run time type and show proper error based on the result #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function run() {
const excluded = core.getInput('exclude');
const excludedFiles = excluded.split(' ');

if (!canParse(lcovPath)) {
if (!canParse(lcovPath) || !canUseMinCoverage(minCoverage)) {
return;
}

Expand Down Expand Up @@ -54,7 +54,7 @@ function run() {
if (!isValidBuild) {
core.setFailed(
`${coverage} is less than min_coverage ${minCoverage}\n\n` +
linesMissingCoverageMessage
linesMissingCoverageMessage
);
} else {
var resultMessage = `Coverage: ${coverage}%.\n`;
Expand Down Expand Up @@ -107,4 +107,15 @@ you have no test files or your tests are not generating any coverage data.
return true;
}

function canUseMinCoverage(minCoverage) {
if (typeof minCoverage == 'number') return true;

if (minCoverage.toString().includes('%')) {
core.setFailed('❌ Failed to use min_coverage remove the `%` symbol');
return false;
}
core.setFailed('❌ Failed to use min_coverage value make sure you added a number');
return false;
Comment on lines +111 to +118
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not just parse the value as a int and see if we can? Instead of having "checks" for different cases

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wolfenrain I don't get your point!

}

run();