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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7439995a443d4ffd1574a246b62b34f30bd9d506
4
- data.tar.gz: ee3d3104641f3740629b15d20bf1b6a6afbc6ee0
3
+ metadata.gz: ae4a071831d3e9f5a65da82641068289a54d081a
4
+ data.tar.gz: 21aa7726e58acc03270027e9f8c29d8ba0460a39
5
5
  SHA512:
6
- metadata.gz: 5cfbcd7b6d401c8d0451aaa2d1c159b5576555c7e095582639fdfdb37927fc513961ac945f694f8e776db32af83edeada0d541ef63e4d48f028be4b9a7607a89
7
- data.tar.gz: 1654a9719ecd4967354e0bc855dab6df357796bf5bd9c3923e05d49ea3f28cf72801e3e30730b5164dc295c85022de1f63566acec7e96d04795748cb43d0891d
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)
@@ -1,4 +1,4 @@
1
- require "travis_bundle_cache/version"
1
+ require "travis_bundle_cache/cache"
2
2
 
3
3
  module TravisBundleCache
4
4
  # Your code goes here...
@@ -1,12 +1,12 @@
1
1
  require "digest"
2
- require "fog"
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
- @file_name = "#{ENV['BUNDLE_ARCHIVE']}-#{@architecture}.tgz"
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}" "https://#{@bucket_name}.s3.amazonaws.com/#{@file_name}" && tar -xf "remote_#{@file_name}")
18
- run_command %(cd ~ && wget -O "remote_#{@file_name}.sha2" "https://#{@bucket_name}.s3.amazonaws.com/#{@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 && split -b 5m -a 3 "#{@file_name}" "#{@file_name}."`
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
- puts " => Beginning multipart upload"
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
- bucket = storage.directories.new(key: @bucket_name)
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 ||= Fog::Storage.new({
104
- :provider => "AWS",
105
- :aws_access_key_id => ENV["AWS_S3_KEY"],
106
- :aws_secret_access_key => ENV["AWS_S3_SECRET"],
107
- :region => ENV["AWS_S3_REGION"] || "us-east-1"
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
@@ -1,3 +1,3 @@
1
1
  module TravisBundleCache
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -20,5 +20,5 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = ["travis_bundle_cache", "travis_bundle_install"]
21
21
 
22
22
  spec.add_dependency "bundler", "~> 1.3"
23
- spec.add_dependency "fog"
23
+ spec.add_dependency "aws-sdk"
24
24
  end
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.3
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-01 00:00:00.000000000 Z
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: fog
28
+ name: aws-sdk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '>='