From ebf120332bacc5592e334762aca2c8158c26fad9 Mon Sep 17 00:00:00 2001 From: tibvdm Date: Tue, 19 Mar 2024 16:41:44 +0100 Subject: [PATCH] add workflow --- .github/workflows/test.yml | 8 +++++++- Gemfile | 6 +++++- Gemfile.lock | 16 ++++++++++++++-- test/test_helper.rb | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3c2a0a..3eca0da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} diff --git a/Gemfile b/Gemfile index 91164bd..757c4fa 100644 --- a/Gemfile +++ b/Gemfile @@ -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" @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 0e0f5bf..c1fe9b1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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 @@ -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) @@ -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) @@ -252,6 +262,8 @@ DEPENDENCIES responders (~> 3.0) rubocop (~> 1.36) rubocop-rails (~> 2.18) + simplecov + simplecov-cobertura stathat (~> 0.1.7) tzinfo-data diff --git a/test/test_helper.rb b/test/test_helper.rb index d713e37..4939e14 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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