Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Add simplecov for code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
javierjulio committed Apr 16, 2024
1 parent 2ead518 commit ed6d1d6
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,30 @@ jobs:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run Tests
env:
COVERAGE: true
RUBYOPT: "-W:deprecated"
run: bundle exec rake
- name: Rename coverage file by matrix run
run: mv coverage/coverage.xml coverage/coverage-ruby-${{ matrix.ruby }}.xml
- uses: actions/upload-artifact@v4
with:
name: coverage-ruby-${{ matrix.ruby }}
path: coverage
if-no-files-found: error

upload_coverage:
name: Upload Coverage
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: coverage
pattern: coverage-ruby-*
merge-multiple: true
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: coverage
fail_ci_if_error: true
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in envied.gemspec
gemspec

group :test do
gem "simplecov", require: false
gem "simplecov-cobertura"
end
13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.5.1)
docile (1.4.0)
rake (13.2.1)
rexml (3.2.6)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand All @@ -21,6 +23,15 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-cobertura (2.1.0)
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)

PLATFORMS
ruby
Expand All @@ -30,6 +41,8 @@ DEPENDENCIES
envied!
rake (~> 13.0)
rspec (~> 3.0)
simplecov
simplecov-cobertura

BUNDLED WITH
2.3.10
5 changes: 5 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage:
status:
project:
default:
threshold: 0.05%
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
if ENV.fetch("COVERAGE", false)
require "simplecov"
require "simplecov-cobertura"
SimpleCov.start do
add_filter %r{^/spec/}
formatter SimpleCov::Formatter::CoberturaFormatter
end
end

require "bundler/setup"
require "envied"

Expand Down

0 comments on commit ed6d1d6

Please sign in to comment.