Skip to content

Commit b478722

Browse files
committed
Collect coverage from all previous tests
1 parent 38b75dc commit b478722

File tree

5 files changed

+47
-44
lines changed

5 files changed

+47
-44
lines changed

.github/workflows/coverage.yml

-27
This file was deleted.

.github/workflows/test.yml

+26
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,29 @@ jobs:
7373

7474
- name: Run tests
7575
run: bundle exec rspec
76+
77+
- name: Upload test coverage folder for later reporting
78+
uses: actions/upload-artifact@v3
79+
with:
80+
name: coverage-reports
81+
path: ${{github.workspace}}/coverage-*/coverage.json
82+
retention-days: 1
83+
84+
coverage:
85+
name: Report coverage to Code Climate
86+
runs-on: ubuntu-20.04
87+
needs: test
88+
if: success() && github.ref == 'refs/heads/main'
89+
env:
90+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
91+
steps:
92+
- uses: actions/checkout@v3
93+
94+
- name: Download coverage reports from the test job
95+
uses: actions/download-artifact@v3
96+
with:
97+
name: coverage-reports
98+
99+
- uses: paambaati/[email protected]
100+
with:
101+
coverageLocations: "coverage-*/coverage.json:simplecov"

.simplecov

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
require 'openssl'
4+
require 'simplecov_json_formatter'
5+
6+
SimpleCov.start do
7+
command_name "Job #{File.basename(ENV['BUNDLE_GEMFILE'])}" if ENV['BUNDLE_GEMFILE']
8+
project_name 'Ruby JWT - Ruby JSON Web Token implementation'
9+
coverage_dir "coverage-#{::OpenSSL::Digest::SHA256.hexdigest(ENV['GITHUB_STEP_SUMMARY'])}" if ENV['GITHUB_STEP_SUMMARY']
10+
add_filter 'spec'
11+
end
12+
13+
if ENV['CI']
14+
SimpleCov.formatters = SimpleCov::Formatter::JSONFormatter
15+
end

Rakefile

+5-9
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
require 'bundler/setup'
44
require 'bundler/gem_tasks'
55

6-
begin
7-
require 'rspec/core/rake_task'
8-
require 'rubocop/rake_task'
6+
require 'rspec/core/rake_task'
7+
require 'rubocop/rake_task'
98

10-
RSpec::Core::RakeTask.new(:test)
11-
RuboCop::RakeTask.new(:rubocop)
9+
RSpec::Core::RakeTask.new(:test)
10+
RuboCop::RakeTask.new(:rubocop)
1211

13-
task default: %i[rubocop test]
14-
rescue LoadError
15-
puts 'RSpec rake tasks not available. Please run "bundle install" to install missing dependencies.'
16-
end
12+
task default: %i[rubocop test]

spec/spec_helper.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,13 @@
22

33
require 'rspec'
44
require 'simplecov'
5-
6-
SimpleCov.start do
7-
root File.join(File.dirname(__FILE__), '..')
8-
project_name 'Ruby JWT - Ruby JSON Web Token implementation'
9-
add_filter 'spec'
10-
end
11-
125
require 'jwt'
136

147
puts "OpenSSL::VERSION: #{OpenSSL::VERSION}"
158
puts "OpenSSL::OPENSSL_VERSION: #{OpenSSL::OPENSSL_VERSION}"
169
puts "OpenSSL::OPENSSL_LIBRARY_VERSION: #{OpenSSL::OPENSSL_LIBRARY_VERSION}\n\n"
1710

18-
CERT_PATH = File.join(File.dirname(__FILE__), 'fixtures', 'certs')
11+
CERT_PATH = File.join(__dir__, 'fixtures', 'certs')
1912

2013
RSpec.configure do |config|
2114
config.expect_with :rspec do |c|

0 commit comments

Comments
 (0)