Skip to content

Commit

Permalink
Merge pull request #32 from unipept/codecov
Browse files Browse the repository at this point in the history
Add workflow for computation of code coverage
  • Loading branch information
tibvdm authored Mar 19, 2024
2 parents beee804 + ebf1203 commit c20c0d2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ jobs:
- 3306:3306
options: --health-cmd "mysqladmin ping -h localhost" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use ruby from .ruby-version
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run tests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
bundle exec rails db:test:prepare
bundle exec rails test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ruby "3.1.2"
gem "rails", "~> 7.0.3", ">= 7.0.3.1"

# Use mysql as the database for Active Record
gem "mysql2", "~> 0.5"
gem "mysql2", "~> 0.5", "> 0.5.5"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"
Expand Down Expand Up @@ -39,6 +39,10 @@ gem "bootsnap", require: false
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]

#Codecov for coverage processing
gem 'simplecov'
gem 'simplecov-cobertura'
end

group :development do
Expand Down
16 changes: 14 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ GEM
irb (>= 1.3.6)
reline (>= 0.3.1)
digest (3.1.0)
docile (1.4.0)
erubi (1.11.0)
faraday (2.5.2)
faraday-net_http (>= 2.0, < 3.1)
Expand Down Expand Up @@ -118,7 +119,7 @@ GEM
minitest (5.18.0)
msgpack (1.5.6)
multi_json (1.15.0)
mysql2 (0.5.4)
mysql2 (0.5.6)
net-imap (0.2.3)
digest
net-protocol
Expand Down Expand Up @@ -216,6 +217,15 @@ GEM
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
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)
sshkit (1.21.3)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
Expand Down Expand Up @@ -243,7 +253,7 @@ DEPENDENCIES
debug
jbuilder
multi_json (~> 1.15.0)
mysql2 (~> 0.5)
mysql2 (~> 0.5, > 0.5.5)
octokit (~> 5.4)
oj (~> 3.13)
puma (~> 5.0)
Expand All @@ -252,6 +262,8 @@ DEPENDENCIES
responders (~> 3.0)
rubocop (~> 1.36)
rubocop-rails (~> 2.18)
simplecov
simplecov-cobertura
stathat (~> 0.1.7)
tzinfo-data

Expand Down
14 changes: 14 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@
require_relative "../config/environment"
require "rails/test_help"

require 'simplecov'
SimpleCov.start 'rails'

require 'simplecov-cobertura'
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter

class ActiveSupport::TestCase
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors)

parallelize_setup do |worker|
SimpleCov.command_name "#{SimpleCov.command_name}-#{worker}"
end

parallelize_teardown do |_worker|
SimpleCov.result
end

# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all

Expand Down

0 comments on commit c20c0d2

Please sign in to comment.