Created
September 18, 2012 06:29
-
-
Save oisin/3741569 to your computer and use it in GitHub Desktop.
CircleCI coverage retrieval - Rake task to email coverage figures and CircleCI config to trigger post-build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test: | |
post: | |
- bundle exec rake email_coverage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pony' | |
require 'zip/zip' | |
desc "Email the coverage to someone who gives a damn" | |
task :email_coverage do | |
archive = "test-coverage.zip" | |
Zip::ZipFile.open(archive, 'w') do |zipfile| | |
Dir["coverage/**/**"].reject{ |f| f == archive}.each do |file| | |
zipfile.add(file.sub('coverage/',''),file) | |
end | |
end | |
Pony.mail({ | |
:to => "[email protected]", | |
:from => "[email protected]", | |
:subject => "Coverage for latest CircleCI build", | |
:body => "Ermahgerd kerverage. Unzip the attachment and load test-coverage/index.html to read.", | |
:attachments => {"test-coverage.zip" => File.read(archive)}, | |
:via => :smtp, | |
:via_options => { | |
:address => 'smtp.sendgrid.net', | |
:port => '587', | |
:domain => 'yourdomain.com', | |
:user_name => ENV['SENDGRID_USERNAME'], | |
:password => ENV['SENDGRID_PASSWORD'], | |
:authentication => :plain, | |
:enable_starttls_auto => true | |
} | |
}) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment