lib/slather/coverage_service/coveralls.rb in slather-1.5.5 vs lib/slather/coverage_service/coveralls.rb in slather-1.6.0
- old
+ new
@@ -9,10 +9,32 @@
def travis_job_id
ENV['TRAVIS_JOB_ID']
end
private :travis_job_id
+
+ def circleci_job_id
+ ENV['CIRCLE_BUILD_NUM']
+ end
+ private :circleci_job_id
+
+ def circleci_pull_request
+ ENV['CI_PULL_REQUEST']
+ end
+ private :circleci_pull_request
+
+ def circleci_git_info
+ {
+ :head => {
+ :id => (ENV['CIRCLE_SHA1'] || ""),
+ :author_name => (ENV['CIRCLE_USERNAME'] || ""),
+ :message => (`git log --format=%B -n 1 HEAD`.chomp || "")
+ },
+ :branch => (ENV['CIRCLE_BRANCH'] || "")
+ }
+ end
+ private :circleci_git_info
def coveralls_coverage_data
if ci_service == :travis_ci || ci_service == :travis_pro
if travis_job_id
if ci_service == :travis_ci
@@ -29,9 +51,27 @@
:source_files => coverage_files.map(&:as_json)
}.to_json
end
else
raise StandardError, "Environment variable `TRAVIS_JOB_ID` not set. Is this running on a travis build?"
+ end
+ elsif ci_service == :circleci
+ if circleci_job_id
+ coveralls_hash = {
+ :service_job_id => circleci_job_id,
+ :service_name => "circleci",
+ :repo_token => ci_access_token,
+ :source_files => coverage_files.map(&:as_json),
+ :git => circleci_git_info
+ }
+
+ if circleci_pull_request != nil && circleci_pull_request.length > 0
+ coveralls_hash[:service_pull_request] = circleci_pull_request.split("/").last
+ end
+
+ coveralls_hash.to_json
+ else
+ raise StandardError, "Environment variable `CIRCLE_BUILD_NUM` not set. Is this running on a circleci build?"
end
else
raise StandardError, "No support for ci named #{ci_service}"
end
end
\ No newline at end of file