Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/slather
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Clamp do
option ["--travis", "-t"], :flag, "Indicate that the builds are running on Travis CI"
option ["--circleci"], :flag, "Indicate that the builds are running on CircleCI"
option ["--jenkins"], :flag, "Indicate that the builds are running on Jenkins"
option ["--buildkite"], :flag, "Indicate that the builds are running on Buildkite"

option ["--coveralls", "-c"], :flag, "Post coverage results to coveralls"
option ["--simple-output", "-s"], :flag, "Output coverage results to the terminal"
Expand Down Expand Up @@ -65,6 +66,8 @@ Clamp do
project.ci_service = :circleci
elsif jenkins?
project.ci_service = :jenkins
elsif buildkite?
project.ci_service = :buildkite
end
end

Expand Down
42 changes: 41 additions & 1 deletion lib/slather/coverage_service/coveralls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ def jenkins_branch_name
end
private :jenkins_branch_name

def buildkite_job_id
ENV['BUILDKITE_BUILD_NUMBER']
end
private :buildkite_job_id

def buildkite_pull_request
ENV['BUILDKITE_PULL_REQUEST']
end
private :buildkite_pull_request

def jenkins_git_info
{
head: {
Expand Down Expand Up @@ -66,6 +76,22 @@ def circleci_git_info
end
private :circleci_git_info

def buildkite_git_info
{
:head => {
:id => ENV['BUILDKITE_COMMIT'],
:author_name => (`git log --format=%an -n 1 HEAD`.chomp || ""),
:author_email => (`git log --format=%ae -n 1 HEAD`.chomp || ""),
:message => (`git log --format=%s -n 1 HEAD`.chomp || "")
},
:branch => ENV['BUILDKITE_BRANCH']
}
end

def buildkite_build_url
"https://buildkite.com/" + ENV['BUILDKITE_PROJECT_SLUG'] + "/builds/" + ENV['BUILDKITE_BUILD_NUMBER'] + "#"
end

def coveralls_coverage_data
if ci_service == :travis_ci || ci_service == :travis_pro
if travis_job_id
Expand Down Expand Up @@ -117,6 +143,20 @@ def coveralls_coverage_data
else
raise StandardError, "Environment variable `BUILD_ID` not set. Is this running on a jenkins build?"
end
elsif ci_service == :buildkite
if buildkite_job_id
{
:service_job_id => buildkite_job_id,
:service_name => "buildkite",
:repo_token => coverage_access_token,
:source_files => coverage_files.map(&:as_json),
:git => buildkite_git_info,
:service_build_url => buildkite_build_url,
:service_pull_request => buildkite_pull_request
}.to_json
else
raise StandardError, "Environment variable `BUILDKITE_BUILD_NUMBER` not set. Is this running on a buildkite build?"
end
else
raise StandardError, "No support for ci named #{ci_service}"
end
Expand All @@ -143,4 +183,4 @@ def coveralls_api_jobs_path

end
end
end
end