simplecov-s3 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/lib/simplecov-s3.rb +41 -5
- data/lib/simplecov-s3/version.rb +1 -1
- data/spec/a_spec.rb +9 -0
- metadata +14 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1be02985d6dccbe11b92af4e97c018a3a2d40f8b
|
4
|
+
data.tar.gz: 4fda1155fdf6891ca9012d3cc8004e83489f4e1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f76ff1bda128f0522921f2fda81d811c593d71af79f281832a366922b8717ab0855698f32adaa5759ea070f605dc2b11d67c1f35e683f81a5d4f7a479807b727
|
7
|
+
data.tar.gz: 4cacc8f463f1a0ac29dbcd756d963e0b9e1ef636defb66401e9e8256dc728b7749b689c0dd9833999fde52921ddf09ce8b9207b998e0dbc6de1e7c50a5ca7807
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/simplecov-s3.rb
CHANGED
@@ -32,7 +32,10 @@ module SimpleCov
|
|
32
32
|
@shared_secret = opts[:shared_secret]
|
33
33
|
@assets_url = opts[:assets_url]
|
34
34
|
@bucket_name = opts[:bucket_name]
|
35
|
-
@build_units = opts[:build_units]
|
35
|
+
@build_units = opts[:build_units].to_i
|
36
|
+
if @build_units <= 1
|
37
|
+
raise "Missing build_units in config (need a value greater than 0)"
|
38
|
+
end
|
36
39
|
@postback_url = opts[:postback_url]
|
37
40
|
@build_unit = opts[:build_unit]
|
38
41
|
@build_id = opts[:build_id]
|
@@ -41,7 +44,8 @@ module SimpleCov
|
|
41
44
|
if @project_name.empty?
|
42
45
|
@project_name = "unknown"
|
43
46
|
end
|
44
|
-
@history_limit = opts[:history_limit] ||
|
47
|
+
@history_limit = opts[:history_limit] || (@build_units.to_i * 3)
|
48
|
+
@additional_artifacts_to_merge = opts[:additional_artifacts_to_merge] || []
|
45
49
|
end
|
46
50
|
|
47
51
|
def push_partial(opts = {})
|
@@ -49,6 +53,13 @@ module SimpleCov
|
|
49
53
|
result = SimpleCov::ResultMerger.merged_result
|
50
54
|
data_to_push = result.original_result.merge("BUILD_UNIT" => @build_unit).to_json
|
51
55
|
put_file("#{@project_name}-#{commit_time}-coverageJSON/#{hashed_build_id}/#{@job_id}", data_to_push)
|
56
|
+
@additional_artifacts_to_merge.each do |artifact|
|
57
|
+
key = artifact[:key]
|
58
|
+
file = artifact[:file]
|
59
|
+
filedata = File.read(file)
|
60
|
+
puts "pushing additional artifact #{key} #{file} #{filedata[0,100]}"
|
61
|
+
put_file("#{@project_name}-#{commit_time}-#{key}/#{hashed_build_id}/#{@job_id}", filedata)
|
62
|
+
end
|
52
63
|
rescue => e
|
53
64
|
puts e.inspect
|
54
65
|
puts e.backtrace
|
@@ -84,7 +95,28 @@ module SimpleCov
|
|
84
95
|
merged = result.original_result.merge_resultset(merged)
|
85
96
|
end
|
86
97
|
result = SimpleCov::Result.new(merged)
|
87
|
-
|
98
|
+
uniq_id = SecureRandom.urlsafe_base64(33)
|
99
|
+
push_coverage_to("#{@project_name}-#{Time.now.to_i}-coverageRESULT/#{uniq_id}", gen_body(result), result.covered_percent, @postback_url)
|
100
|
+
@additional_artifacts_to_merge.each do |artifact|
|
101
|
+
key = artifact[:key]
|
102
|
+
file = artifact[:file]
|
103
|
+
merge_with = artifact[:merge_with]
|
104
|
+
files = files_for_key(key).map do |f|
|
105
|
+
data = f.body
|
106
|
+
puts "merging additional artifact #{f.key} #{data[0,100]}"
|
107
|
+
data
|
108
|
+
end
|
109
|
+
while files.size > 1
|
110
|
+
a, b, *files = files
|
111
|
+
files << merge_with.call(a, b)
|
112
|
+
end
|
113
|
+
File.open(file, "w+"){|f| f.write(files.first)}
|
114
|
+
puts "Merged artifact #{key} contents:"
|
115
|
+
puts files.first
|
116
|
+
save_merged_artifact_in_s3_at = "#{@project_name}-#{Time.now.to_i}-#{key}/#{uniq_id}"
|
117
|
+
puts "Also saving in S3 at path: #{save_merged_artifact_in_s3_at}"
|
118
|
+
put_file(save_merged_artifact_in_s3_at, files.first)
|
119
|
+
end
|
88
120
|
cleanup_files
|
89
121
|
end
|
90
122
|
|
@@ -112,11 +144,15 @@ module SimpleCov
|
|
112
144
|
@connection.directories.get(@bucket_name).files.create(:key => path, :body => data, :content_type => "text/html")
|
113
145
|
end
|
114
146
|
|
115
|
-
def
|
116
|
-
expected_dir = "#{@project_name}-#{commit_time}
|
147
|
+
def files_for_key(key)
|
148
|
+
expected_dir = "#{@project_name}-#{commit_time}-#{key}/#{hashed_build_id}/"
|
117
149
|
@connection.directories.get(@bucket_name, :prefix => expected_dir).files
|
118
150
|
end
|
119
151
|
|
152
|
+
def json_files
|
153
|
+
files_for_key("coverageJSON")
|
154
|
+
end
|
155
|
+
|
120
156
|
def gen_body(result)
|
121
157
|
Formatter.new.format(result).gsub("./assets",@assets_url)
|
122
158
|
end
|
data/lib/simplecov-s3/version.rb
CHANGED
data/spec/a_spec.rb
CHANGED
@@ -18,6 +18,7 @@ describe SimpleCov::S3 do
|
|
18
18
|
}
|
19
19
|
s3conn = Fog::Storage.new(fog_opts)
|
20
20
|
s3conn.directories.create(:key => "somebucket")
|
21
|
+
knapsack_rspec_report_path = File.expand_path("knapsack_rspec_report.json")
|
21
22
|
cov_opts = {
|
22
23
|
:fog => fog_opts,
|
23
24
|
:project_name => "ey/simplecov-s3", #ENV["TRAVIS_REPO_SLUG"],
|
@@ -30,14 +31,22 @@ describe SimpleCov::S3 do
|
|
30
31
|
:assets_url => "http://somebucket.s3-website-us-east-1.amazonaws.com/assets",
|
31
32
|
:shared_secret => "XXXXXXXXXXXX", #used so build units can find each other, and for covereage postback
|
32
33
|
:postback_url => "https://bot.example.org/coverage",
|
34
|
+
:additional_artifacts_to_merge => [{
|
35
|
+
key: "knapsack",
|
36
|
+
file: knapsack_rspec_report_path,
|
37
|
+
merge_with: Proc.new{|a,b| JSON.pretty_generate(JSON.parse(a).merge(JSON.parse(b))) }
|
38
|
+
}]
|
33
39
|
}
|
40
|
+
File.open(knapsack_rspec_report_path, "w"){|fp| fp.write({foo: "bar"}.to_json)}
|
34
41
|
cov = SimpleCov::S3.new(cov_opts)
|
35
42
|
cov.push_partial(:debug => true)
|
36
43
|
cov.pull_merge_and_push_full
|
44
|
+
File.open(knapsack_rspec_report_path, "w"){|fp| fp.write({bar: "baz"}.to_json)}
|
37
45
|
cov2 = SimpleCov::S3.new(cov_opts.merge(:job_id => "457", :build_unit => "6"))
|
38
46
|
cov2.push_partial(:debug => true)
|
39
47
|
cov2.pull_merge_and_push_full
|
40
48
|
cov2.push_full
|
49
|
+
expect(JSON.parse(File.read(knapsack_rspec_report_path))).to eq('foo' => 'bar', 'bar' => 'baz')
|
41
50
|
#TODO: assert on the resulting contents of S3?
|
42
51
|
end
|
43
52
|
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fog
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: simplecov
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Merge simplecov outputs using S3 as shared storage (and publish the results
|
@@ -60,9 +60,9 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
64
|
-
- .rspec
|
65
|
-
- .travis.yml
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
66
|
- Gemfile
|
67
67
|
- LICENSE
|
68
68
|
- README.md
|
@@ -80,21 +80,20 @@ require_paths:
|
|
80
80
|
- lib
|
81
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.4.5.1
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Merge simplecov outputs using S3 as shared storage (and publish the results
|
97
97
|
as html to S3)
|
98
98
|
test_files:
|
99
99
|
- spec/a_spec.rb
|
100
|
-
has_rdoc:
|