diff --git a/Makefile b/Makefile index 4603ed7..860481c 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: test install build deploy deploy: - $(eval VERSION := $(shell cat lib/codecov.rb | grep 'VERSION = ' | cut -d\' -f2)) + $(eval VERSION := $(shell cat lib/codecov/version.rb | grep 'VERSION = ' | cut -d\' -f2)) git tag v$(VERSION) -m "" git push origin v$(VERSION) gem build codecov.gemspec diff --git a/codecov.gemspec b/codecov.gemspec index 5932b28..fbebe09 100644 --- a/codecov.gemspec +++ b/codecov.gemspec @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative 'lib/codecov/version' + Gem::Specification.new do |s| s.name = 'codecov' s.authors = ['Steve Peak', 'Tom Hu'] @@ -11,7 +13,7 @@ Gem::Specification.new do |s| s.license = 'MIT' s.platform = Gem::Platform::RUBY s.required_ruby_version = '~> 2.4' - s.version = '0.2.13' + s.version = ::Codecov::VERSION s.add_dependency 'simplecov', '~> 0.18.0' diff --git a/lib/codecov.rb b/lib/codecov.rb index 109d879..885aa91 100644 --- a/lib/codecov.rb +++ b/lib/codecov.rb @@ -6,9 +6,9 @@ require 'simplecov' require 'zlib' -class SimpleCov::Formatter::Codecov - VERSION = '0.2.13' +require_relative 'codecov/version' +class SimpleCov::Formatter::Codecov ### CIs RECOGNIZED_CIS = [ APPVEYOR = 'Appveyor CI', @@ -41,7 +41,7 @@ def display_header '| | / _ \ / _\`|/ _ \/ __/ _ \ \ / /', '| |___| (_) | (_| | __/ (_| (_) \ V /', ' \_____\___/ \__,_|\___|\___\___/ \_/', - " Ruby-#{VERSION}", + " Ruby-#{::Codecov::VERSION}", '' ].join("\n") end @@ -100,7 +100,7 @@ def build_params(ci) params = { 'token' => ENV['CODECOV_TOKEN'], 'flags' => ENV['CODECOV_FLAG'] || ENV['CODECOV_FLAGS'], - 'package' => "ruby-#{VERSION}" + 'package' => "ruby-#{::Codecov::VERSION}" } case ci @@ -336,7 +336,7 @@ def retry_request(req, https) def create_report(report) result = { 'meta' => { - 'version' => 'codecov-ruby/v' + VERSION + 'version' => 'codecov-ruby/v' + ::Codecov::VERSION } } result.update(result_to_codecov(report)) diff --git a/lib/codecov/version.rb b/lib/codecov/version.rb new file mode 100644 index 0000000..ea867ed --- /dev/null +++ b/lib/codecov/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Codecov + VERSION = '0.2.13' +end diff --git a/test/helper.rb b/test/helper.rb index 91ba5f2..55a99ca 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -7,7 +7,7 @@ SimpleCov.start do add_filter '/test/' end -require 'codecov' +require_relative '../lib/codecov' SimpleCov.formatter = SimpleCov::Formatter::Codecov if ENV['CI'] == 'true' require 'minitest/autorun' diff --git a/test/test_codecov.rb b/test/test_codecov.rb index db74b8a..5940cc1 100644 --- a/test/test_codecov.rb +++ b/test/test_codecov.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'helper' +require_relative 'helper' class TestCodecov < Minitest::Test CI = SimpleCov::Formatter::Codecov.new.detect_ci @@ -47,7 +47,7 @@ def url def test_defined assert defined?(SimpleCov::Formatter::Codecov) - assert defined?(SimpleCov::Formatter::Codecov::VERSION) + assert defined?(::Codecov::VERSION) end def stub_file(filename, coverage) @@ -96,7 +96,7 @@ def success_stubs def assert_successful_upload(data) assert_equal(data['result']['uploaded'], true) assert_equal(data['result']['message'], 'Coverage reports upload successfully') - assert_equal(data['meta']['version'], 'codecov-ruby/v' + SimpleCov::Formatter::Codecov::VERSION) + assert_equal(data['meta']['version'], 'codecov-ruby/v' + ::Codecov::VERSION) assert_equal(data['coverage'].to_json, { 'lib/something.rb' => [nil, 1, 0, 0, nil, 1, nil], 'lib/somefile.rb' => [nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil]