Skip to content

Commit

Permalink
Initial commit - pull coverage check action out of local project
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli Fatsi committed Jul 29, 2021
0 parents commit 54d4839
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
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"]
14 changes: 14 additions & 0 deletions action.yml
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'
14 changes: 14 additions & 0 deletions check_coverage.rb
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

0 comments on commit 54d4839

Please sign in to comment.