-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit - pull coverage check action out of local project
- Loading branch information
Eli Fatsi
committed
Jul 29, 2021
0 parents
commit 54d4839
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM ruby:2.6.5-alpine | ||
|
||
COPY check_coverage.rb /check_coverage.rb | ||
|
||
CMD ["ruby", "/check_coverage.rb"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: 'SimpleCov Check' | ||
description: 'Ensure code coverage is at 100%' | ||
inputs: | ||
minimum_coverage: | ||
description: 'Percentage required to pass' | ||
required: true | ||
default: "100" | ||
coverage_path: | ||
description: 'Percentage required to pass' | ||
required: true | ||
default: "coverage/.last_run.json" | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'json' | ||
|
||
minimum_coverage = ENV['INPUT_MINIMUM_COVERAGE'].to_i | ||
last_run = JSON.parse File.read(ENV['INPUT_COVERAGE_PATH']) | ||
|
||
actual_coverage = last_run.dig("result", "line") | ||
|
||
if actual_coverage >= minimum_coverage | ||
STDOUT.puts("Line coverage (#{actual_coverage}%) meets the expected minimum: #{minimum_coverage}%.") | ||
exit(0) | ||
else | ||
STDERR.puts("Line coverage (#{actual_coverage}%) is below the expected minimum: #{minimum_coverage}%.") | ||
exit(1) | ||
end |