Skip to content

Commit

Permalink
Added simplecov, codecov, and simplecov-console as new deps
Browse files Browse the repository at this point in the history
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
  • Loading branch information
etagwerker committed Sep 22, 2021
1 parent 638b081 commit 5828b3a
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# .github/workflows/ci.yml

name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
COVERAGE: true
CODECOV_TOKEN: d7028c0e-97c5-485f-85e5-f63daabeef63
jobs:
test-ruby-2-4-x:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.4
bundler-cache: true
- name: Build and run tests
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rake test
test-ruby-2-5-x:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.5
bundler-cache: true
- name: Build and run tests
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rake test
test-ruby-2-6-x:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
bundler-cache: true
- name: Build and run tests
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rake test
test-ruby-2-7-x:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Build and run tests
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rake test
test-ruby-3-0-x:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true
- name: Build and run tests
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rake test
3 changes: 3 additions & 0 deletions rails_stats.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Gem::Specification.new do |spec|
spec.add_dependency "rake"
spec.add_development_dependency "bundler", ">= 1.6", "< 3.0"
spec.add_development_dependency "byebug"
spec.add_development_dependency "codecov"
spec.add_development_dependency "minitest"
spec.add_development_dependency "minitest-around"
spec.add_development_dependency "simplecov"
spec.add_development_dependency "simplecov-console"
end
18 changes: 18 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# frozen_string_literal: true

if ENV["COVERAGE"] == "true"
require "simplecov"
require "simplecov-console"
require "codecov"

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Console,
SimpleCov::Formatter::Codecov,
]

SimpleCov.start do
track_files "lib/**/*.rb"
end

puts "Using SimpleCov v#{SimpleCov::VERSION}"
end

require "byebug"

require "minitest/autorun"
Expand Down

0 comments on commit 5828b3a

Please sign in to comment.