From 8638dc013690848432edad9e8d21953fe1e66cb3 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Tue, 1 Dec 2020 23:10:47 +0300 Subject: [PATCH 1/2] Return version constant, don't duplicate version value Kind of revert 6c2856ec4dda8a61b637b8dc1e6ca341c06d95d3 without regression of #84 because of `require_relative` instead of `$LOAD_PATH.unshift`. --- Makefile | 2 +- codecov.gemspec | 4 +++- lib/codecov.rb | 10 +++++----- lib/codecov/version.rb | 5 +++++ test/helper.rb | 2 +- test/test_codecov.rb | 6 +++--- 6 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 lib/codecov/version.rb 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 73436d3..323a0c4 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 = ['codecov'] @@ -13,7 +15,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>=2.4' s.summary = 'hosted code coverage ruby/rails reporter' s.test_files = ['test/test_codecov.rb'] - s.version = '0.2.12' + s.version = ::Codecov::VERSION s.add_dependency 'simplecov' diff --git a/lib/codecov.rb b/lib/codecov.rb index 6acfa16..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.12' +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..efd46b7 --- /dev/null +++ b/lib/codecov/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Codecov + VERSION = '0.2.12' +end \ No newline at end of file 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] From fc0cfce7d4bd57b6e50e8279786dd3021f446c42 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Wed, 9 Dec 2020 21:47:27 -0500 Subject: [PATCH 2/2] Update lib/codecov/version.rb --- lib/codecov/version.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/codecov/version.rb b/lib/codecov/version.rb index efd46b7..ea867ed 100644 --- a/lib/codecov/version.rb +++ b/lib/codecov/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Codecov - VERSION = '0.2.12' -end \ No newline at end of file + VERSION = '0.2.13' +end