Skip to content

Commit 86ff7c8

Browse files
committed
Added simplecov, codecov, and simplecov-console as new deps
Require codecov and simplecov before loading test/lib code This will be needed to report data to CodeCov and to the console Start running test suite with GitHub actions Set env variable to always check COVERAGE in CI (GitHub Actions) Move env definition to a higher level Add CODECOV_TOKEN
1 parent 638b081 commit 86ff7c8

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

.github/workflows/test.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# .github/workflows/ci.yml
2+
3+
name: Test
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
env:
12+
COVERAGE: true
13+
CODECOV_TOKEN: d7028c0e-97c5-485f-85e5-f63daabeef63
14+
jobs:
15+
test-ruby-2-4-x:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v1
20+
- name: Setup Ruby
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: 2.4
24+
bundler-cache: true
25+
- name: Build and run tests
26+
run: |
27+
gem install bundler
28+
bundle install --jobs 4 --retry 3
29+
bundle exec rake test
30+
test-ruby-2-5-x:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/checkout@v1
35+
- name: Setup Ruby
36+
uses: ruby/setup-ruby@v1
37+
with:
38+
ruby-version: 2.5
39+
bundler-cache: true
40+
- name: Build and run tests
41+
run: |
42+
gem install bundler
43+
bundle install --jobs 4 --retry 3
44+
bundle exec rake test
45+
test-ruby-2-6-x:
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- uses: actions/checkout@v1
50+
- name: Setup Ruby
51+
uses: ruby/setup-ruby@v1
52+
with:
53+
ruby-version: 2.6
54+
bundler-cache: true
55+
- name: Build and run tests
56+
run: |
57+
gem install bundler
58+
bundle install --jobs 4 --retry 3
59+
bundle exec rake test
60+
test-ruby-2-7-x:
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- uses: actions/checkout@v1
65+
- name: Setup Ruby
66+
uses: ruby/setup-ruby@v1
67+
with:
68+
ruby-version: 2.7
69+
bundler-cache: true
70+
- name: Build and run tests
71+
run: |
72+
gem install bundler
73+
bundle install --jobs 4 --retry 3
74+
bundle exec rake test
75+
test-ruby-3-0-x:
76+
runs-on: ubuntu-latest
77+
78+
steps:
79+
- uses: actions/checkout@v1
80+
- name: Setup Ruby
81+
uses: ruby/setup-ruby@v1
82+
with:
83+
ruby-version: 3.0
84+
bundler-cache: true
85+
- name: Build and run tests
86+
run: |
87+
gem install bundler
88+
bundle install --jobs 4 --retry 3
89+
bundle exec rake test

rails_stats.gemspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Gem::Specification.new do |spec|
2121
spec.add_dependency "rake"
2222
spec.add_development_dependency "bundler", ">= 1.6", "< 3.0"
2323
spec.add_development_dependency "byebug"
24+
spec.add_development_dependency "codecov"
2425
spec.add_development_dependency "minitest"
2526
spec.add_development_dependency "minitest-around"
27+
spec.add_development_dependency "simplecov"
28+
spec.add_development_dependency "simplecov-console"
2629
end

test/test_helper.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# frozen_string_literal: true
22

3+
if ENV["COVERAGE"] == "true"
4+
require "simplecov"
5+
require "simplecov-console"
6+
require "codecov"
7+
8+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
9+
SimpleCov::Formatter::HTMLFormatter,
10+
SimpleCov::Formatter::Console,
11+
SimpleCov::Formatter::Codecov,
12+
]
13+
14+
SimpleCov.start do
15+
track_files "lib/**/*.rb"
16+
end
17+
18+
puts "Using SimpleCov v#{SimpleCov::VERSION}"
19+
end
20+
321
require "byebug"
422

523
require "minitest/autorun"

0 commit comments

Comments
 (0)