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

Commit ed6d1d6

Browse files
committed
Add simplecov for code coverage
1 parent 2ead518 commit ed6d1d6

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

.github/workflows/ci.yml

+25
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,30 @@ jobs:
2525
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
2626
- name: Run Tests
2727
env:
28+
COVERAGE: true
2829
RUBYOPT: "-W:deprecated"
2930
run: bundle exec rake
31+
- name: Rename coverage file by matrix run
32+
run: mv coverage/coverage.xml coverage/coverage-ruby-${{ matrix.ruby }}.xml
33+
- uses: actions/upload-artifact@v4
34+
with:
35+
name: coverage-ruby-${{ matrix.ruby }}
36+
path: coverage
37+
if-no-files-found: error
38+
39+
upload_coverage:
40+
name: Upload Coverage
41+
runs-on: ubuntu-latest
42+
needs: [build]
43+
steps:
44+
- uses: actions/checkout@v4
45+
- uses: actions/download-artifact@v4
46+
with:
47+
path: coverage
48+
pattern: coverage-ruby-*
49+
merge-multiple: true
50+
- uses: codecov/codecov-action@v4
51+
with:
52+
token: ${{ secrets.CODECOV_TOKEN }}
53+
directory: coverage
54+
fail_ci_if_error: true

Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
22

33
# Specify your gem's dependencies in envied.gemspec
44
gemspec
5+
6+
group :test do
7+
gem "simplecov", require: false
8+
gem "simplecov-cobertura"
9+
end

Gemfile.lock

+13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ GEM
77
remote: https://rubygems.org/
88
specs:
99
diff-lcs (1.5.1)
10+
docile (1.4.0)
1011
rake (13.2.1)
12+
rexml (3.2.6)
1113
rspec (3.13.0)
1214
rspec-core (~> 3.13.0)
1315
rspec-expectations (~> 3.13.0)
@@ -21,6 +23,15 @@ GEM
2123
diff-lcs (>= 1.2.0, < 2.0)
2224
rspec-support (~> 3.13.0)
2325
rspec-support (3.13.1)
26+
simplecov (0.22.0)
27+
docile (~> 1.1)
28+
simplecov-html (~> 0.11)
29+
simplecov_json_formatter (~> 0.1)
30+
simplecov-cobertura (2.1.0)
31+
rexml
32+
simplecov (~> 0.19)
33+
simplecov-html (0.12.3)
34+
simplecov_json_formatter (0.1.4)
2435

2536
PLATFORMS
2637
ruby
@@ -30,6 +41,8 @@ DEPENDENCIES
3041
envied!
3142
rake (~> 13.0)
3243
rspec (~> 3.0)
44+
simplecov
45+
simplecov-cobertura
3346

3447
BUNDLED WITH
3548
2.3.10

codecov.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
threshold: 0.05%

spec/spec_helper.rb

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
if ENV.fetch("COVERAGE", false)
2+
require "simplecov"
3+
require "simplecov-cobertura"
4+
SimpleCov.start do
5+
add_filter %r{^/spec/}
6+
formatter SimpleCov::Formatter::CoberturaFormatter
7+
end
8+
end
9+
110
require "bundler/setup"
211
require "envied"
312

0 commit comments

Comments
 (0)