Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Specify gem version only once #40

Merged
merged 8 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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/version.rb | grep 'LATEST = ' | cut -d\' -f2))
git tag v$(VERSION) -m ""
git push origin v$(VERSION)
gem build codecov.gemspec
Expand Down
6 changes: 5 additions & 1 deletion codecov.gemspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'version'

Gem::Specification.new do |s|
s.name = 'codecov'
s.version = '0.2.3'
s.version = Version::LATEST
s.platform = Gem::Platform::RUBY
s.authors = ['codecov']
s.email = ['hello@codecov.io']
Expand Down
10 changes: 5 additions & 5 deletions lib/codecov.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
require 'colorize'
require 'zlib'

class SimpleCov::Formatter::Codecov
VERSION = '0.2.3'
require 'version'

class SimpleCov::Formatter::Codecov
### CIs
RECOGNIZED_CIS = [
APPVEYOR = 'Appveyor CI',
Expand Down Expand Up @@ -41,7 +41,7 @@ def display_header
'| | / _ \ / _\`|/ _ \/ __/ _ \ \ / /',
'| |___| (_) | (_| | __/ (_| (_) \ V /',
' \_____\___/ \__,_|\___|\___\___/ \_/',
" Ruby-#{VERSION}",
" Ruby-#{Version::LATEST}",
''
].join("\n")
end
Expand Down Expand Up @@ -98,7 +98,7 @@ def build_params(ci)
params = {
'token' => ENV['CODECOV_TOKEN'],
'flags' => ENV['CODECOV_FLAG'] || ENV['CODECOV_FLAGS'],
'package' => "ruby-#{VERSION}"
'package' => "ruby-#{Version::LATEST}"
}

case ci
Expand Down Expand Up @@ -317,7 +317,7 @@ def retry_request(req, https)
def create_report(report)
result = {
'meta' => {
'version' => 'codecov-ruby/v' + SimpleCov::Formatter::Codecov::VERSION
'version' => 'codecov-ruby/v' + Version::LATEST
}
}
result.update(result_to_codecov(report))
Expand Down
5 changes: 5 additions & 0 deletions lib/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class Version
LATEST = '0.2.3'
end
10 changes: 4 additions & 6 deletions test/test_codecov.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def url

def test_defined
assert defined?(SimpleCov::Formatter::Codecov)
assert defined?(SimpleCov::Formatter::Codecov::VERSION)
assert defined?(Version::LATEST)
end

def stub_file(filename, coverage)
Expand All @@ -50,7 +50,7 @@ def stub_file(filename, coverage)
stub('SimpleCov::SourceFile', filename: filename, lines: lines)
end

def upload(success=true)
def upload(success = true)
formatter = SimpleCov::Formatter::Codecov.new
result = stub('SimpleCov::Result', files: [
stub_file('/path/lib/something.rb', [1, 0, 0, nil, 1, nil]),
Expand All @@ -61,9 +61,7 @@ def upload(success=true)
data = formatter.format(result, false)
puts data
puts data['params']
if success
assert_successful_upload(data)
end
assert_successful_upload(data) if success
WebMock.reset!
data
end
Expand All @@ -85,7 +83,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' + Version::LATEST)
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]
Expand Down