simplecov_s3_codeclimate
Sample Usage:
Gemfile
group :test do
gem 'simplecov_s3_codeclimate'
end
config/environment.rb
require File.('../application', __FILE__)
if Rails.env.test?
require File.("../../spec/coverage_helper", __FILE__)
end
spec/coverage_helper.rb
unless ENV["SKIP_COVERAGE"]
require 'simplecov'
SimpleCov.start(:rails)
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
SimpleCov.at_exit do
SimpleCov.result.format!
end
# Yes this is a hack, the most reliable way to ensure that simplecov doesn't de-dupe your coverage results for having the same command_name: "rspec"
command_name "Test #{ARGV[0]}"
SimpleCov.merge_timeout 3600
end
lib/tasks/codeclimate_coverage.rake
task :coverage do
require File.("../spec/coverage_helper", __FILE__)
cov = SimpleCov::S3::Codeclimate.new(
:fog => {
provider: 'AWS',
aws_access_key_id: "AWS_ACCESS_KEY_ID",
aws_secret_access_key: "AWS_SECRET_ACCESS_KEY",
region: "us-east-1",
},
project_name: "PROJECT_NAME",
build_id: "BUILD_ID", # Unique identifier for a CI build
build_unit: "BUILD_UNIT", # Unique identifier for a test run within a CI build
build_units: 1, # Total number of build_units within a CI build
bucket_name: "S3_BUCKET_NAME",
shared_secret: "XXXXXXXXXXXX", # Used so build units can find each other,
subfolder: 'OPTIONAL_SUBFOLDER' # Subfolder in S3 Bucket to store temp data
)
cov.push_partial
cov.pull_merge_and_push_full
end
.gitinore:
#ignore generated coverage results
coverage
You must also have CODECLIMATE_REPO_TOKEN
in your environment. See their documentation for more info.