travis_bundle_cache 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/lib/travis_bundle_cache.rb +1 -1
- data/lib/travis_bundle_cache/cache.rb +13 -42
- data/lib/travis_bundle_cache/version.rb +1 -1
- data/travis_bundle_cache.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae4a071831d3e9f5a65da82641068289a54d081a
|
4
|
+
data.tar.gz: 21aa7726e58acc03270027e9f8c29d8ba0460a39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5ea24f3d147d636595ca603f99437c9e18d8db395c4221f2055c50867d64bbf7b5bae3c409508eb9c36d7473d7ae8eeef6407bda0bacaa5335010d2d76e854f
|
7
|
+
data.tar.gz: ff9639729f79513d780d215f46e78ee20ddfad46e5465a6d5c662fbb40d00eb2443dec9075ed99aa045d81e86e84493755ed34f19c525009d4a4c7ff6116ffdd
|
data/README.md
CHANGED
@@ -23,8 +23,8 @@ Usage
|
|
23
23
|
```yaml
|
24
24
|
env:
|
25
25
|
global:
|
26
|
-
- BUNDLE_ARCHIVE="your-bundle-name"
|
27
|
-
- AWS_S3_REGION="us-east-1"
|
26
|
+
- BUNDLE_ARCHIVE="your-bundle-name" # Default: "owner_name-repo_name"
|
27
|
+
- AWS_S3_REGION="us-east-1" # Default: "us-east-1" (recommended)
|
28
28
|
- AWS_S3_BUCKET="your-bucket-name"
|
29
29
|
|
30
30
|
before_install:
|
@@ -33,8 +33,11 @@ Usage
|
|
33
33
|
|
34
34
|
install: travis_bundle_install
|
35
35
|
|
36
|
+
before_script:
|
37
|
+
- "travis_bundle_cache > ~/travis_bundle_cache.log &"
|
38
|
+
|
36
39
|
after_script:
|
37
|
-
- travis_bundle_cache
|
40
|
+
- wait && cat ~/travis_bundle_cache.log
|
38
41
|
```
|
39
42
|
|
40
43
|
3. Install the travis gem (not the travis_bundle_cache gem)
|
data/lib/travis_bundle_cache.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require "digest"
|
2
|
-
require "
|
2
|
+
require "aws/s3"
|
3
3
|
|
4
4
|
module TravisBundleCache
|
5
5
|
class Cache
|
6
6
|
def initialize
|
7
|
-
@bucket_name = ENV["AWS_S3_BUCKET"]
|
8
7
|
@architecture = `uname -m`.strip
|
9
|
-
@
|
8
|
+
@bundle_archive = ENV['BUNDLE_ARCHIVE'] || ENV['TRAVIS_REPO_SLUG'].gsub(/\//, '-')
|
9
|
+
@file_name = "#{@bundle_archive}-#{@architecture}.tgz"
|
10
10
|
@file_path = File.expand_path("~/#{@file_name}")
|
11
11
|
@lock_file = File.join(File.expand_path(ENV["TRAVIS_BUILD_DIR"]), "Gemfile.lock")
|
12
12
|
@digest_filename = "#{@file_name}.sha2"
|
@@ -14,8 +14,8 @@ module TravisBundleCache
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def install
|
17
|
-
run_command %(cd ~ && wget -O "remote_#{@file_name}" "
|
18
|
-
run_command %(cd ~ && wget -O "remote_#{@file_name}.sha2" "
|
17
|
+
run_command %(cd ~ && wget -O "remote_#{@file_name}" "#{storage[@file_name].url_for(:read)}" && tar -xf "remote_#{@file_name}")
|
18
|
+
run_command %(cd ~ && wget -O "remote_#{@file_name}.sha2" "#{storage[@digest_filename].url_for(:read)}")
|
19
19
|
run_command %(bundle install --without #{ENV['BUNDLE_WITHOUT'] || "development production"} --path=~/.bundle)
|
20
20
|
end
|
21
21
|
|
@@ -48,41 +48,13 @@ module TravisBundleCache
|
|
48
48
|
end
|
49
49
|
|
50
50
|
puts "=> Preparing bundle archive"
|
51
|
-
`cd ~ && tar -cjf "#{@file_name}" .bundle
|
52
|
-
|
53
|
-
parts_pattern = File.expand_path(File.join("~", "#{@file_name}.*"))
|
54
|
-
parts = Dir.glob(parts_pattern).sort
|
51
|
+
`cd ~ && tar -cjf "#{@file_name}" .bundle`
|
55
52
|
|
56
53
|
puts "=> Uploading the bundle"
|
57
|
-
|
58
|
-
response = storage.initiate_multipart_upload(@bucket_name, @file_name, { "x-amz-acl" => "public-read" })
|
59
|
-
upload_id = response.body['UploadId']
|
60
|
-
puts " => Upload ID: #{upload_id}"
|
61
|
-
|
62
|
-
part_ids = []
|
63
|
-
|
64
|
-
puts " => Uploading #{parts.length} parts"
|
65
|
-
parts.each_with_index do |part, index|
|
66
|
-
part_number = (index + 1).to_s
|
67
|
-
puts " => Uploading #{part}"
|
68
|
-
File.open(part) do |part_file|
|
69
|
-
response = storage.upload_part(@bucket_name, @file_name, upload_id, part_number, part_file)
|
70
|
-
part_ids << response.headers['ETag']
|
71
|
-
puts " => Uploaded"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
puts " => Completing multipart upload"
|
76
|
-
storage.complete_multipart_upload(@bucket_name, @file_name, upload_id, part_ids)
|
54
|
+
storage[@file_name].write(Pathname.new(@file_path), :reduced_redundancy => true)
|
77
55
|
|
78
56
|
puts "=> Uploading the digest file"
|
79
|
-
|
80
|
-
bucket.files.create({
|
81
|
-
:body => @bundle_digest,
|
82
|
-
:key => @digest_filename,
|
83
|
-
:public => true,
|
84
|
-
:content_type => "text/plain"
|
85
|
-
})
|
57
|
+
storage[@digest_filename].write(@bundle_digest, :content_type => "text/plain", :reduced_redundancy => true)
|
86
58
|
|
87
59
|
puts "All done now."
|
88
60
|
end
|
@@ -100,12 +72,11 @@ module TravisBundleCache
|
|
100
72
|
end
|
101
73
|
|
102
74
|
def storage
|
103
|
-
@storage ||=
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
107
|
-
|
108
|
-
})
|
75
|
+
@storage ||= AWS::S3.new({
|
76
|
+
:access_key_id => ENV["AWS_S3_KEY"],
|
77
|
+
:secret_access_key => ENV["AWS_S3_SECRET"],
|
78
|
+
:region => ENV["AWS_S3_REGION"] || "us-east-1"
|
79
|
+
}).buckets[ENV["AWS_S3_BUCKET"]].objects
|
109
80
|
end
|
110
81
|
end
|
111
82
|
end
|
data/travis_bundle_cache.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis_bundle_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Genord II
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: aws-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|