travis-artifacts 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -6
- data/README.md +8 -0
- data/lib/travis/artifacts/cli.rb +5 -0
- data/lib/travis/artifacts/uploader.rb +2 -1
- data/spec/travis/artifacts/cli_spec.rb +7 -3
- data/spec/travis/artifacts/uploader_spec.rb +70 -3
- data/travis-artifacts.gemspec +1 -1
- metadata +5 -3
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
travis-artifacts (0.0
|
4
|
+
travis-artifacts (0.1.0)
|
5
5
|
faraday
|
6
6
|
faraday_middleware
|
7
7
|
fog
|
@@ -11,12 +11,12 @@ GEM
|
|
11
11
|
specs:
|
12
12
|
builder (3.1.4)
|
13
13
|
diff-lcs (1.1.3)
|
14
|
-
excon (0.16.
|
14
|
+
excon (0.16.8)
|
15
15
|
faraday (0.8.4)
|
16
16
|
multipart-post (~> 1.1)
|
17
17
|
faraday_middleware (0.9.0)
|
18
18
|
faraday (>= 0.7.4, < 0.9)
|
19
|
-
fog (1.
|
19
|
+
fog (1.7.0)
|
20
20
|
builder
|
21
21
|
excon (~> 0.14)
|
22
22
|
formatador (~> 0.2.0)
|
@@ -28,12 +28,12 @@ GEM
|
|
28
28
|
ruby-hmac
|
29
29
|
formatador (0.2.4)
|
30
30
|
mime-types (1.19)
|
31
|
-
multi_json (1.
|
31
|
+
multi_json (1.3.7)
|
32
32
|
multipart-post (1.1.5)
|
33
33
|
net-scp (1.0.4)
|
34
34
|
net-ssh (>= 1.99.1)
|
35
|
-
net-ssh (2.6.
|
36
|
-
nokogiri (1.5.
|
35
|
+
net-ssh (2.6.1)
|
36
|
+
nokogiri (1.5.5)
|
37
37
|
rspec (2.12.0)
|
38
38
|
rspec-core (~> 2.12.0)
|
39
39
|
rspec-expectations (~> 2.12.0)
|
data/README.md
ADDED
data/lib/travis/artifacts/cli.rb
CHANGED
@@ -87,6 +87,11 @@ module Travis::Artifacts
|
|
87
87
|
options[:private] = true
|
88
88
|
end
|
89
89
|
|
90
|
+
opt.on('--cache-control CACHE_CONTROL_VALUE',
|
91
|
+
'set custom cache control metadata value') do |value|
|
92
|
+
options[:cache_control] = value
|
93
|
+
end
|
94
|
+
|
90
95
|
opt.on('-h','--help','help') do
|
91
96
|
puts @opt_parser
|
92
97
|
end
|
@@ -12,6 +12,7 @@ module Travis::Artifacts
|
|
12
12
|
@test = Test.new
|
13
13
|
@public = ! (options[:private]||false)
|
14
14
|
@target_path = options[:target_path] || "artifacts/#{@test.build_number}/#{@test.job_number}"
|
15
|
+
@cache_control = !@public ? 'private' : options[:cache_control] || 'public, max-age=315360000'
|
15
16
|
end
|
16
17
|
|
17
18
|
def upload
|
@@ -85,7 +86,7 @@ module Travis::Artifacts
|
|
85
86
|
:public => @public,
|
86
87
|
:body => file.read,
|
87
88
|
:content_type => file.content_type,
|
88
|
-
:metadata => { "Cache-Control" =>
|
89
|
+
:metadata => { "Cache-Control" => @cache_control }
|
89
90
|
})
|
90
91
|
end
|
91
92
|
|
@@ -21,11 +21,15 @@ module Travis::Artifacts
|
|
21
21
|
end
|
22
22
|
|
23
23
|
describe 'upload' do
|
24
|
-
let(:argv)
|
25
|
-
|
24
|
+
let(:argv) do
|
25
|
+
['upload', '--path', 'foo', '--target-path', 'bar', '--cache-control', 'public, max-age=3600']
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'calls Uploader with given paths, target_path, and cache_control' do
|
26
29
|
uploader = mock('uploader')
|
27
30
|
Uploader.should_receive(:new).with([Path.new('foo', nil, Dir.pwd)], \
|
28
|
-
{:paths=>["foo"], :private=>false, :target_path=>"bar"
|
31
|
+
{:paths=>["foo"], :private=>false, :target_path=>"bar",
|
32
|
+
:cache_control=>'public, max-age=3600'}\
|
29
33
|
).and_return(uploader)
|
30
34
|
uploader.should_receive(:upload)
|
31
35
|
|
@@ -45,18 +45,21 @@ module Travis::Artifacts
|
|
45
45
|
end
|
46
46
|
|
47
47
|
describe '#upload' do
|
48
|
-
|
48
|
+
let(:bucket) { mock('bucket') }
|
49
|
+
let(:bucket_files) { mock('bucket_files') }
|
50
|
+
|
51
|
+
before do
|
49
52
|
files = [
|
50
53
|
Artifact.new('source/path.png', 'destination/path.png')
|
51
54
|
]
|
52
55
|
files[0].stub(:read => 'contents')
|
53
56
|
uploader.stub(:files => files)
|
54
57
|
|
55
|
-
bucket = mock('bucker')
|
56
|
-
bucket_files = mock('bucket_files')
|
57
58
|
uploader.stub(:bucket => bucket)
|
58
59
|
bucket.stub(:files => bucket_files)
|
60
|
+
end
|
59
61
|
|
62
|
+
it 'uploads file to S3' do
|
60
63
|
bucket_files.should_receive(:create).with({
|
61
64
|
:key => 'artifacts/1/destination/path.png',
|
62
65
|
:public => true,
|
@@ -68,6 +71,70 @@ module Travis::Artifacts
|
|
68
71
|
|
69
72
|
uploader.upload
|
70
73
|
end
|
74
|
+
|
75
|
+
context 'with private set to true' do
|
76
|
+
let(:uploader) do
|
77
|
+
Uploader.new(paths, {
|
78
|
+
:target_path =>'artifacts/1',
|
79
|
+
:private => true,
|
80
|
+
:cache_control => 'public, but really ignored'
|
81
|
+
})
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'sets cache control metadata to private' do
|
85
|
+
bucket_files.should_receive(:create).with({
|
86
|
+
:key => 'artifacts/1/destination/path.png',
|
87
|
+
:public => false,
|
88
|
+
:body => 'contents',
|
89
|
+
:content_type => 'image/png',
|
90
|
+
:metadata => {'Cache-Control' => 'private'}
|
91
|
+
|
92
|
+
})
|
93
|
+
|
94
|
+
uploader.upload
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'with a custom cache control option' do
|
99
|
+
let(:custom_cache_control) do
|
100
|
+
[
|
101
|
+
'private',
|
102
|
+
'public, max-age=3600',
|
103
|
+
'public',
|
104
|
+
].send(RUBY_VERSION >= '1.9' ? :sample : :choice)
|
105
|
+
end
|
106
|
+
|
107
|
+
let(:uploader) do
|
108
|
+
Uploader.new(paths, {
|
109
|
+
:target_path =>'artifacts/1',
|
110
|
+
:cache_control => custom_cache_control
|
111
|
+
})
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'uploads file to S3 with custom cache control header metadata' do
|
115
|
+
files = [
|
116
|
+
Artifact.new('source/path.png', 'destination/path.png')
|
117
|
+
]
|
118
|
+
files[0].stub(:read => 'contents')
|
119
|
+
uploader.stub(:files => files)
|
120
|
+
|
121
|
+
bucket = mock('bucket')
|
122
|
+
bucket_files = mock('bucket_files')
|
123
|
+
uploader.stub(:bucket => bucket)
|
124
|
+
bucket.stub(:files => bucket_files)
|
125
|
+
|
126
|
+
bucket_files.should_receive(:create).with({
|
127
|
+
:key => 'artifacts/1/destination/path.png',
|
128
|
+
:public => true,
|
129
|
+
:body => 'contents',
|
130
|
+
:content_type => 'image/png',
|
131
|
+
:metadata => {'Cache-Control' => custom_cache_control}
|
132
|
+
|
133
|
+
})
|
134
|
+
|
135
|
+
uploader.upload
|
136
|
+
end
|
137
|
+
end
|
71
138
|
end
|
72
139
|
|
73
140
|
describe '#files' do
|
data/travis-artifacts.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis-artifacts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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-
|
12
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- .travis.yml
|
88
88
|
- Gemfile
|
89
89
|
- Gemfile.lock
|
90
|
+
- README.md
|
90
91
|
- bin/travis-artifacts
|
91
92
|
- lib/travis/artifacts.rb
|
92
93
|
- lib/travis/artifacts/artifact.rb
|
@@ -127,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
128
|
version: '0'
|
128
129
|
requirements: []
|
129
130
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.8.
|
131
|
+
rubygems_version: 1.8.25
|
131
132
|
signing_key:
|
132
133
|
specification_version: 3
|
133
134
|
summary: Travis build artifacts tools
|
@@ -140,3 +141,4 @@ test_files:
|
|
140
141
|
- spec/travis/artifacts/artifact_spec.rb
|
141
142
|
- spec/travis/artifacts/cli_spec.rb
|
142
143
|
- spec/travis/artifacts/uploader_spec.rb
|
144
|
+
has_rdoc:
|