Skip to content

Commit

Permalink
check standard CI env vars for config; version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmerwin committed Apr 2, 2015
1 parent 6b250f9 commit bb40b39
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
20 changes: 10 additions & 10 deletions lib/coveralls/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def self.configuration
set_service_params_for_tddium(config)
elsif ENV['COVERALLS_RUN_LOCALLY'] || Coveralls.testing
set_service_params_for_coveralls_local(config)
# standardized env vars
elsif ENV['CI_NAME']
set_service_params_for_generic_ci(config)
end

# standardized env vars
set_standard_service_params_for_generic_ci(config)

config
end

Expand Down Expand Up @@ -89,13 +89,13 @@ def self.set_service_params_for_coveralls_local(config)
config[:service_event_type] = 'manual'
end

def self.set_service_params_for_generic_ci(config)
config[:service_name] = ENV['CI_NAME']
config[:service_number] = ENV['CI_BUILD_NUMBER']
config[:service_job_id] = ENV['CI_JOB_ID']
config[:service_build_url] = ENV['CI_BUILD_URL']
config[:service_branch] = ENV['CI_BRANCH']
config[:service_pull_request] = (ENV['CI_PULL_REQUEST'] || "")[/(\d+)$/,1]
def self.set_standard_service_params_for_generic_ci(config)
config[:service_name] ||= ENV['CI_NAME']
config[:service_number] ||= ENV['CI_BUILD_NUMBER']
config[:service_job_id] ||= ENV['CI_JOB_ID']
config[:service_build_url] ||= ENV['CI_BUILD_URL']
config[:service_branch] ||= ENV['CI_BRANCH']
config[:service_pull_request] ||= (ENV['CI_PULL_REQUEST'] || "")[/(\d+)$/,1]
end

def self.yaml_config
Expand Down
2 changes: 1 addition & 1 deletion lib/coveralls/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Coveralls
VERSION = "0.7.12"
VERSION = "0.8.0"
end
18 changes: 11 additions & 7 deletions spec/coveralls/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci)
Coveralls::Configuration.configuration
end
end
Expand All @@ -82,7 +82,7 @@
Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci)
Coveralls::Configuration.configuration
end
end
Expand All @@ -98,7 +98,7 @@
Coveralls::Configuration.should_receive(:set_service_params_for_semaphore)
Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci)
Coveralls::Configuration.configuration
end
end
Expand All @@ -114,7 +114,7 @@
Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
Coveralls::Configuration.should_receive(:set_service_params_for_jenkins)
Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci)
Coveralls::Configuration.configuration
end
end
Expand All @@ -130,7 +130,7 @@
Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
Coveralls::Configuration.should_receive(:set_service_params_for_coveralls_local)
Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci)
Coveralls::Configuration.configuration
end
end
Expand All @@ -146,7 +146,7 @@
Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
Coveralls::Configuration.should_receive(:set_service_params_for_generic_ci)
Coveralls::Configuration.should_receive(:set_standard_service_params_for_generic_ci).with(anything)
Coveralls::Configuration.configuration
end
end
Expand Down Expand Up @@ -208,16 +208,20 @@
end

describe '.set_service_params_for_jenkins' do
let(:service_pull_request) { '1234' }
let(:build_num) { SecureRandom.hex(4) }
before do
ENV.stub(:[]).with('CI_PULL_REQUEST').and_return(service_pull_request)
ENV.stub(:[]).with('BUILD_NUMBER').and_return(build_num)
end

it 'should set the expected parameters' do
config = {}
Coveralls::Configuration.set_service_params_for_jenkins(config)
Coveralls::Configuration.set_standard_service_params_for_generic_ci(config)
config[:service_name].should eq('jenkins')
config[:service_number].should eq(build_num)
config[:service_pull_request].should eq(service_pull_request)
end
end

Expand Down Expand Up @@ -248,7 +252,7 @@

it 'should set the expected parameters' do
config = {}
Coveralls::Configuration.set_service_params_for_generic_ci(config)
Coveralls::Configuration.set_standard_service_params_for_generic_ci(config)
config[:service_name].should eq(service_name)
config[:service_number].should eq(service_number)
config[:service_build_url].should eq(service_build_url)
Expand Down

0 comments on commit bb40b39

Please sign in to comment.