simplecov-s3 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +48 -2
- data/lib/simplecov-s3.rb +18 -1
- data/lib/simplecov-s3/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
Sample Usage:
|
4
4
|
|
5
|
+
Gemile
|
6
|
+
|
7
|
+
group :test do
|
8
|
+
gem 'simplecov-s3'
|
9
|
+
end
|
10
|
+
|
5
11
|
config/environment.rb
|
6
12
|
|
7
13
|
require File.expand_path('../application', __FILE__)
|
@@ -10,7 +16,7 @@ config/environment.rb
|
|
10
16
|
require File.expand_path("../../spec/coverage_helper", __FILE__)
|
11
17
|
end
|
12
18
|
|
13
|
-
coverage_helper.rb
|
19
|
+
spec/coverage_helper.rb
|
14
20
|
|
15
21
|
unless ENV["SKIP_COVERAGE"]
|
16
22
|
require 'simplecov'
|
@@ -19,11 +25,45 @@ coverage_helper.rb
|
|
19
25
|
SimpleCov.at_exit do
|
20
26
|
SimpleCov.result.format!
|
21
27
|
end
|
28
|
+
# 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"
|
22
29
|
SimpleCov.command_name("HAX#{Time.now.to_i}")
|
23
30
|
SimpleCov.merge_timeout 86400
|
24
31
|
end
|
25
32
|
|
26
|
-
Rakefile
|
33
|
+
Rakefile (basic, 1 build unit)
|
34
|
+
|
35
|
+
if defined?(RSpec) #don't load this task in production
|
36
|
+
|
37
|
+
require 'simplecov-s3'
|
38
|
+
|
39
|
+
task :spec_with_coverage do
|
40
|
+
require File.expand_path("../spec/coverage_helper", __FILE__)
|
41
|
+
cov = SimpleCov::S3.new(
|
42
|
+
:fog => {
|
43
|
+
:provider => 'AWS',
|
44
|
+
:aws_access_key_id => "XXXXXX",
|
45
|
+
:aws_secret_access_key => "XXXXXXXXXXXXX",
|
46
|
+
:region => "us-east-1",
|
47
|
+
},
|
48
|
+
:project_name => ENV["TRAVIS_REPO_SLUG"],
|
49
|
+
:build_id => ENV["TRAVIS_BUILD_ID"],
|
50
|
+
:job_id => ENV["TRAVIS_JOB_ID"],
|
51
|
+
:bucket_name => "somebucket",
|
52
|
+
:public_url_base => "http://somebucket.s3-website-us-east-1.amazonaws.com/",
|
53
|
+
:assets_url => "http://somebucket.s3-website-us-east-1.amazonaws.com/assets",
|
54
|
+
:shared_secret => "XXXXXXXXXXXX", #used so build units can find each other, and for covereage postback
|
55
|
+
:postback_url => "https://bot.example.org/coverage",
|
56
|
+
)
|
57
|
+
#ensure coverage is pushed regardless of build result
|
58
|
+
SimpleCov::S3.ensured("spec") do
|
59
|
+
cov.push_full
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
task :default => :spec_with_coverage
|
64
|
+
end
|
65
|
+
|
66
|
+
Rakefile (advanced, merge build units across worker boxes)
|
27
67
|
|
28
68
|
task :coverage do
|
29
69
|
build_units = YAML.load_file(File.expand_path("../build_units.yml",__FILE__)).size
|
@@ -46,10 +86,16 @@ Rakefile
|
|
46
86
|
:shared_secret => "XXXXXXXXXXXX", #used so build units can find each other, and for covereage postback
|
47
87
|
:postback_url => "https://bot.example.org/coverage",
|
48
88
|
)
|
89
|
+
#debug => true means publish readable HTML for each partial coverage report (as opposed to just RAW JSON)
|
49
90
|
cov.push_partial(:debug => true)
|
50
91
|
cov.pull_merge_and_push_full
|
51
92
|
end
|
52
93
|
|
94
|
+
.gitinore:
|
95
|
+
|
96
|
+
#ignore generated coverage results
|
97
|
+
coverage
|
98
|
+
|
53
99
|
Sample S3 Bucket policy to allow the "<user>" user of from the Amazon Account ID "<awsaccount>" access to read/write from the "<bucket>" bucket, while the public is allowed read-only:
|
54
100
|
|
55
101
|
{
|
data/lib/simplecov-s3.rb
CHANGED
@@ -37,7 +37,11 @@ module SimpleCov
|
|
37
37
|
@build_unit = opts[:build_unit]
|
38
38
|
@build_id = opts[:build_id]
|
39
39
|
@job_id = opts[:job_id]
|
40
|
-
@project_name = opts[:project_name]
|
40
|
+
@project_name = opts[:project_name] || "unknown"
|
41
|
+
if @project_name.empty?
|
42
|
+
@project_name = "unknown"
|
43
|
+
end
|
44
|
+
@history_limit = opts[:history_limit] || 15
|
41
45
|
end
|
42
46
|
|
43
47
|
def push_partial(opts = {})
|
@@ -81,15 +85,28 @@ module SimpleCov
|
|
81
85
|
end
|
82
86
|
result = SimpleCov::Result.new(merged)
|
83
87
|
push_coverage_to("#{@project_name}-#{Time.now.to_i}-coverageRESULT/#{SecureRandom.urlsafe_base64(33)}", gen_body(result), result.covered_percent, @postback_url)
|
88
|
+
cleanup_files
|
84
89
|
end
|
85
90
|
|
86
91
|
def push_full
|
87
92
|
result = SimpleCov::ResultMerger.merged_result
|
88
93
|
push_coverage_to("#{@project_name}-#{Time.now.to_i}-coverageRESULT/#{SecureRandom.urlsafe_base64(33)}", gen_body(result), result.covered_percent, @postback_url)
|
94
|
+
cleanup_files
|
89
95
|
end
|
90
96
|
|
91
97
|
private
|
92
98
|
|
99
|
+
def cleanup_files
|
100
|
+
json_files.each(&:destroy)
|
101
|
+
all_files = @connection.directories.get(@bucket_name, :prefix => @project_name).files
|
102
|
+
if all_files.size > @history_limit
|
103
|
+
all_files.sort_by(&:last_modified)[0,all_files.size - @history_limit].each do |f|
|
104
|
+
puts "Cleaning up #{f.key}"
|
105
|
+
f.destroy
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
93
110
|
def put_file(path, data)
|
94
111
|
puts "Putting to #{path} data size #{data.size}"
|
95
112
|
@connection.directories.get(@bucket_name).files.create(:key => path, :body => data, :content_type => "text/html")
|
data/lib/simplecov-s3/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|