Skip to content

Commit

Permalink
Collect coverage from all previous tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Oct 30, 2022
1 parent 38b75dc commit b478722
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 44 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/coverage.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,29 @@ jobs:

- name: Run tests
run: bundle exec rspec

- name: Upload test coverage folder for later reporting
uses: actions/upload-artifact@v3
with:
name: coverage-reports
path: ${{github.workspace}}/coverage-*/coverage.json
retention-days: 1

coverage:
name: Report coverage to Code Climate
runs-on: ubuntu-20.04
needs: test
if: success() && github.ref == 'refs/heads/main'
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
steps:
- uses: actions/checkout@v3

- name: Download coverage reports from the test job
uses: actions/download-artifact@v3
with:
name: coverage-reports

- uses: paambaati/codeclimate-action@v3.2.0
with:
coverageLocations: "coverage-*/coverage.json:simplecov"
15 changes: 15 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'openssl'
require 'simplecov_json_formatter'

SimpleCov.start do
command_name "Job #{File.basename(ENV['BUNDLE_GEMFILE'])}" if ENV['BUNDLE_GEMFILE']
project_name 'Ruby JWT - Ruby JSON Web Token implementation'
coverage_dir "coverage-#{::OpenSSL::Digest::SHA256.hexdigest(ENV['GITHUB_STEP_SUMMARY'])}" if ENV['GITHUB_STEP_SUMMARY']
add_filter 'spec'
end

if ENV['CI']
SimpleCov.formatters = SimpleCov::Formatter::JSONFormatter
end
14 changes: 5 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
require 'bundler/setup'
require 'bundler/gem_tasks'

begin
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

RSpec::Core::RakeTask.new(:test)
RuboCop::RakeTask.new(:rubocop)
RSpec::Core::RakeTask.new(:test)
RuboCop::RakeTask.new(:rubocop)

task default: %i[rubocop test]
rescue LoadError
puts 'RSpec rake tasks not available. Please run "bundle install" to install missing dependencies.'
end
task default: %i[rubocop test]
9 changes: 1 addition & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@

require 'rspec'
require 'simplecov'

SimpleCov.start do
root File.join(File.dirname(__FILE__), '..')
project_name 'Ruby JWT - Ruby JSON Web Token implementation'
add_filter 'spec'
end

require 'jwt'

puts "OpenSSL::VERSION: #{OpenSSL::VERSION}"
puts "OpenSSL::OPENSSL_VERSION: #{OpenSSL::OPENSSL_VERSION}"
puts "OpenSSL::OPENSSL_LIBRARY_VERSION: #{OpenSSL::OPENSSL_LIBRARY_VERSION}\n\n"

CERT_PATH = File.join(File.dirname(__FILE__), 'fixtures', 'certs')
CERT_PATH = File.join(__dir__, 'fixtures', 'certs')

RSpec.configure do |config|
config.expect_with :rspec do |c|
Expand Down

0 comments on commit b478722

Please sign in to comment.