travis_bundle_cache-rentify 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/.travis.yml +9 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +92 -0
- data/Rakefile +1 -0
- data/bin/travis_bundle_cache +8 -0
- data/bin/travis_bundle_install +8 -0
- data/gem-public_cert.pem +21 -0
- data/lib/travis_bundle_cache.rb +5 -0
- data/lib/travis_bundle_cache/cache.rb +87 -0
- data/lib/travis_bundle_cache/version.rb +3 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/travis_bundle_cache_spec.rb +128 -0
- data/travis_bundle_cache.gemspec +24 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Y2YzMjhhNTg5MWJjYzg1NTRhN2Q4NzkwYTQzNjU1MmFkOWE1ZmE0NQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTRjYWU5MmU5NmUxYTkzYzI1ZTgxZTIzZWZmNzI0YmU0M2Y4YWRhOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDFhYzdjYWExMDFlOTI0NTEwODNmMjM2Y2ExMGFjMGU0Y2U1M2Y1Y2I4OTUz
|
10
|
+
MmRlMzE5OGY0OTA3MzUxMjA4NDVhZWU3Yjk3YjYwM2I5NjAwNWJkYmJlNjVl
|
11
|
+
NmMzZWQ3YjUzMjc0YTk3ZGY1YmU5YzZiZGFmMTdkNGYwMzI3ZjY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjQzOWY5OTgyOWQxZGRiNmE1ZDNjMjdjYjIyOTIwOTFiYzIxMTQ1YjM0NzE0
|
14
|
+
ZTI0MGI1NWEzMTgwYjA1YTkzMDg0ZDY4YjU0MTk0YjEzZGM4Njc3MzgwMDA5
|
15
|
+
ODdjNTc3NWU2MjAyZTk5MGZmYmUzNDllMWE2YWIxMjkwZjk2MzI=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in travis_bundle_cache.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'rake'
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem "coveralls", "~> 0.6.7", require: false
|
10
|
+
gem "rspec", "~> 2.14"
|
11
|
+
gem "fakefs", require: "fakefs/safe"
|
12
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 David Genord II
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
Travis Bundle Cache
|
2
|
+
===================
|
3
|
+
[](http://badge.fury.io/rb/travis_bundle_cache)
|
4
|
+
[](https://travis-ci.org/collectiveidea/travis_bundle_cache)
|
5
|
+
[](https://codeclimate.com/github/collectiveidea/travis_bundle_cache)
|
6
|
+
[](https://coveralls.io/r/collectiveidea/travis_bundle_cache?branch=master)
|
7
|
+
[](https://gemnasium.com/collectiveidea/travis_bundle_cache)
|
8
|
+
|
9
|
+
The primary purpose of this gem is to make [this](http://randomerrata.com/post/45827813818/travis-s3) easier and slightly more maintainable.
|
10
|
+
|
11
|
+
This gem loads, builds, and saves a cache of your bundled gems on S3 by *ONLY* modifying your project's .travis.yml file.
|
12
|
+
|
13
|
+
What you will need:
|
14
|
+
* A project on Travis CI
|
15
|
+
* An AWS account
|
16
|
+
* A "bundle install" that takes longer than "gem install nokogiri"
|
17
|
+
|
18
|
+
Usage
|
19
|
+
=====
|
20
|
+
|
21
|
+
1. Set up a bucket on S3 in the US Standard region (us-east-1) (and possibly a new user via IAM)
|
22
|
+
|
23
|
+
2. Setup your .travis.yml to include the following (NOTE: this must be done before the next steps)
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
env:
|
27
|
+
global:
|
28
|
+
- BUNDLE_ARCHIVE="your-bundle-name" # Default: "owner_name-repo_name"
|
29
|
+
- AWS_S3_REGION="us-east-1" # Default: "us-east-1" (recommended)
|
30
|
+
- AWS_S3_BUCKET="your-bucket-name"
|
31
|
+
|
32
|
+
before_install:
|
33
|
+
- 'echo ''gem: --no-ri --no-rdoc'' > ~/.gemrc'
|
34
|
+
# Better security (If only we could get Amazon to sign their gem)
|
35
|
+
- wget https://raw.github.com/collectiveidea/travis_bundle_cache/4753620b8f2bcfd0c5af85ccd68888c1f593a023/gem-public_cert.pem
|
36
|
+
- gem cert --add gem-public_cert.pem
|
37
|
+
- gem install aws-sdk
|
38
|
+
- gem install travis_bundle_cache -P HighSecurity
|
39
|
+
# Low security option
|
40
|
+
# - gem install travis_bundle_cache
|
41
|
+
|
42
|
+
install: travis_bundle_install
|
43
|
+
|
44
|
+
before_script:
|
45
|
+
- "travis_bundle_cache > ~/travis_bundle_cache.log &"
|
46
|
+
|
47
|
+
after_script:
|
48
|
+
- wait && cat ~/travis_bundle_cache.log
|
49
|
+
```
|
50
|
+
|
51
|
+
3. Install the travis gem (not the travis_bundle_cache gem)
|
52
|
+
|
53
|
+
```bash
|
54
|
+
gem install travis
|
55
|
+
```
|
56
|
+
|
57
|
+
4. Log into Travis (from inside your project respository directory)
|
58
|
+
|
59
|
+
```bash
|
60
|
+
travis login --auto
|
61
|
+
```
|
62
|
+
|
63
|
+
5. Encrypt your S3 credentials (be sure to add your actual credentials inside the double quotes)
|
64
|
+
|
65
|
+
```bash
|
66
|
+
travis encrypt AWS_S3_KEY="" AWS_S3_SECRET="" --add
|
67
|
+
```
|
68
|
+
|
69
|
+
Enjoy faster builds
|
70
|
+
|
71
|
+
Contributions
|
72
|
+
=============
|
73
|
+
|
74
|
+
TravisBundleCache is open source and contributions from the community are encouraged! No contribution is too small. Please consider:
|
75
|
+
|
76
|
+
* adding an awesome feature
|
77
|
+
* fixing a terrible bug
|
78
|
+
* updating documentation
|
79
|
+
* fixing a not-so-bad bug
|
80
|
+
* fixing typos
|
81
|
+
|
82
|
+
For the best chance of having your changes merged, please:
|
83
|
+
|
84
|
+
1. Ask us! We'd love to hear what you're up to.
|
85
|
+
2. Fork the project.
|
86
|
+
3. Commit your changes and tests (if applicable (they're applicable)).
|
87
|
+
4. Submit a pull request with a thorough explanation and at least one animated GIF.
|
88
|
+
|
89
|
+
Thanks
|
90
|
+
======
|
91
|
+
|
92
|
+
Most of the credit for this gem goes to Random Errata and [this](http://randomerrata.com/post/45827813818/travis-s3) blog post
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/gem-public_cert.pem
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDijCCAnKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQ4wDAYDVQQDDAVkYXZp
|
3
|
+
ZDEeMBwGCgmSJomT8ixkARkWDmNvbGxlY3RpdmVpZGVhMRMwEQYKCZImiZPyLGQB
|
4
|
+
GRYDY29tMB4XDTEzMDgwMjE0MjAwN1oXDTE0MDgwMjE0MjAwN1owRTEOMAwGA1UE
|
5
|
+
AwwFZGF2aWQxHjAcBgoJkiaJk/IsZAEZFg5jb2xsZWN0aXZlaWRlYTETMBEGCgmS
|
6
|
+
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAO+X
|
7
|
+
lpzbJojxB0O/2nTxK2NdfgOd2EsnOZaezBZsGDZq0Vbnjec/tNrnsHdUM12LvP1h
|
8
|
+
ZuIx/IrAZj4wlsyZgUsKAQs9GXQCDzmKuwo3kmYtUDv55TQJKwDhtdwliTD82FOT
|
9
|
+
IkTUEcRZNhtb7ymzpK17p5iHaHL+4BgNs1fbciTxqI1xhh9TGyDOht++9dCjJVDV
|
10
|
+
I5nU8VMV8gkAkxA8AlTXNf3hWQNN3tBuvY5EMaG3beN52v+YYDW8Ko4GL16M+aOA
|
11
|
+
PShN16CdA5Jjc/hwe6gK175Ma9UTHwIoWDX2WBztM+cU0E27vxFxbe+il9mHk9wG
|
12
|
+
BzedoP1o5yNUovdOhIsCAwEAAaOBhDCBgTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
|
13
|
+
sDAdBgNVHQ4EFgQUozKz5aO8wO2w0VHWEbPR7x0nBlQwIwYDVR0RBBwwGoEYZGF2
|
14
|
+
aWRAY29sbGVjdGl2ZWlkZWEuY29tMCMGA1UdEgQcMBqBGGRhdmlkQGNvbGxlY3Rp
|
15
|
+
dmVpZGVhLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEANGHG41mjDpWNsdtjMq7lp5Dw
|
16
|
+
xgnf3D3Bz1/t2e4QimdTqniwudSE/P/HD/8HkEn9JMI39xQFyXpfWCFwS5kwsGle
|
17
|
+
qr/LzRfLXV3B11TciP10uMYmHQ+46AJ4mL2iyvmRsIKFU45gBpU1/2zJ44GGzYU1
|
18
|
+
cSKuuZ0obmZRTI0Vn54e2ofKnWZtylW0SYa9uQplEJK/Ttu88DL99WgwOyNdMlqg
|
19
|
+
FJkL4MD3SK4X13qDUlr6YzTkvc8MMfaECuzUIM6KqSGQnyZ16D2zLdZTtr0GPzJZ
|
20
|
+
SdQ0gsTaFvafp6C7hh//UHFI92FnVtzpV01oGPDikn3a2qc8eUPvULa2NlJRFQ==
|
21
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "digest"
|
2
|
+
require "aws/s3"
|
3
|
+
|
4
|
+
module TravisBundleCache
|
5
|
+
class Cache
|
6
|
+
def initialize
|
7
|
+
@architecture = `uname -m`.strip
|
8
|
+
@bundle_archive = ENV['BUNDLE_ARCHIVE'] || ENV['TRAVIS_REPO_SLUG'].gsub(/\//, '-')
|
9
|
+
@file_name = "#{@bundle_archive}-#{@architecture}-#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}.tgz"
|
10
|
+
@file_path = File.expand_path("~/#{@file_name}")
|
11
|
+
@lock_file = File.join(File.expand_path(ENV["TRAVIS_BUILD_DIR"]), "Gemfile.lock")
|
12
|
+
@digest_filename = "#{@file_name}.sha2"
|
13
|
+
@old_digest_filename = File.expand_path("~/remote_#{@digest_filename}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def install
|
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
|
+
run_command %(bundle install --without #{ENV['BUNDLE_WITHOUT'] || "development production"} --path=~/.bundle), retry: true
|
20
|
+
end
|
21
|
+
|
22
|
+
def cache_bundle
|
23
|
+
@bundle_digest = Digest::SHA2.file(@lock_file).hexdigest
|
24
|
+
@old_digest = File.exists?(@old_digest_filename) ? File.read(@old_digest_filename) : ""
|
25
|
+
|
26
|
+
archive_and_upload_bundle
|
27
|
+
end
|
28
|
+
|
29
|
+
def archive_and_upload_bundle
|
30
|
+
if @old_digest == ""
|
31
|
+
puts "=> There was no existing digest, uploading a new version of the archive"
|
32
|
+
else
|
33
|
+
puts "=> There were changes, uploading a new version of the archive"
|
34
|
+
puts " => Old checksum: #{@old_digest}"
|
35
|
+
puts " => New checksum: #{@bundle_digest}"
|
36
|
+
|
37
|
+
puts "=> Cleaning old gem versions from the bundle"
|
38
|
+
run_command "bundle clean"
|
39
|
+
end
|
40
|
+
|
41
|
+
puts "=> Preparing bundle archive"
|
42
|
+
run_command %(cd ~ && tar -cjf "#{@file_name}" .bundle), exit_on_error: true
|
43
|
+
|
44
|
+
puts "=> Uploading the bundle"
|
45
|
+
storage[@file_name].write(Pathname.new(@file_path), :reduced_redundancy => true)
|
46
|
+
|
47
|
+
puts "=> Uploading the digest file"
|
48
|
+
storage[@digest_filename].write(@bundle_digest, :content_type => "text/plain", :reduced_redundancy => true)
|
49
|
+
|
50
|
+
puts "All done now."
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def run_command(cmd, opts = {})
|
56
|
+
tries = 1
|
57
|
+
puts "Running: #{cmd}"
|
58
|
+
while true
|
59
|
+
IO.popen(cmd) do |f|
|
60
|
+
begin
|
61
|
+
print f.readchar while true
|
62
|
+
rescue EOFError
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if $?.exitstatus == 0
|
67
|
+
break
|
68
|
+
elsif opts[:retry] && tries < 3
|
69
|
+
tries += 1
|
70
|
+
puts "Retrying attempt #{tries} of 3"
|
71
|
+
elsif opts[:exit_on_error] || opts[:retry]
|
72
|
+
exit($?.exitstatus)
|
73
|
+
else
|
74
|
+
break
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def storage
|
80
|
+
@storage ||= AWS::S3.new({
|
81
|
+
:access_key_id => ENV["AWS_S3_KEY"],
|
82
|
+
:secret_access_key => ENV["AWS_S3_SECRET"],
|
83
|
+
:region => ENV["AWS_S3_REGION"] || "us-east-1"
|
84
|
+
}).buckets[ENV["AWS_S3_BUCKET"]].objects
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "coveralls"
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require "travis_bundle_cache"
|
5
|
+
|
6
|
+
require "fakefs/spec_helpers"
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.order = "random"
|
10
|
+
config.expect_with(:rspec) {|c| c.syntax = :expect }
|
11
|
+
config.include FakeFS::SpecHelpers
|
12
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe TravisBundleCache::Cache do
|
4
|
+
before(:each) do
|
5
|
+
ENV["TRAVIS_REPO_SLUG"] = "owner/repo"
|
6
|
+
ENV["TRAVIS_BUILD_DIR"] = "/home/travis/owner/repo"
|
7
|
+
ENV["AWS_S3_KEY"] = "AN_ACCESS_KEY_ID"
|
8
|
+
ENV["AWS_S3_SECRET"] = "AN_SECRET_ACCESS_KEY"
|
9
|
+
ENV["AWS_S3_BUCKET"] = "a-bucket-name"
|
10
|
+
|
11
|
+
@uname = `uname -m`.strip
|
12
|
+
@ruby_version = "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}"
|
13
|
+
@cache = TravisBundleCache::Cache.new
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'install' do
|
17
|
+
before(:each) do
|
18
|
+
@cache.stub(:run_command)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'tries to download an available bundle archive' do
|
22
|
+
expect(@cache).to receive(:run_command).once.with(/\Acd ~ && wget -O "remote_owner-repo-#{@uname}-#{@ruby_version}\.tgz" "https:\/\/a-bucket-name\.s3\.amazonaws\.com\/owner-repo-#{@uname}-#{@ruby_version}.tgz\?AWSAccessKeyId=AN_ACCESS_KEY_ID&Expires=[0-9]+&Signature=[^"]+" && tar -xf "remote_owner-repo-#{@uname}-#{@ruby_version}\.tgz"\Z/)
|
23
|
+
|
24
|
+
@cache.install
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'tries to download an available bundle archive signature' do
|
28
|
+
expect(@cache).to receive(:run_command).once.with(/\Acd ~ && wget -O "remote_owner-repo-#{@uname}-#{@ruby_version}\.tgz.sha2" "https:\/\/a-bucket-name\.s3\.amazonaws\.com\/owner-repo-#{@uname}-#{@ruby_version}.tgz.sha2\?AWSAccessKeyId=AN_ACCESS_KEY_ID&Expires=[0-9]+&Signature=[^"]+"\Z/)
|
29
|
+
|
30
|
+
@cache.install
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'installs the bundle' do
|
34
|
+
expect(@cache).to receive(:run_command).once.with("bundle install --without development production --path=~\/.bundle", retry: true)
|
35
|
+
|
36
|
+
@cache.install
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'cache_bundle' do
|
41
|
+
before(:each) do
|
42
|
+
ENV['TRAVIS_PULL_REQUEST'] = 'false'
|
43
|
+
ENV['TRAVIS_BRANCH'] = 'master'
|
44
|
+
|
45
|
+
@cache.stub(:puts)
|
46
|
+
@cache.stub(:run_command)
|
47
|
+
AWS::S3::S3Object.any_instance.stub(:write)
|
48
|
+
|
49
|
+
FileUtils.mkdir_p(ENV["TRAVIS_BUILD_DIR"])
|
50
|
+
File.open(File.join(ENV["TRAVIS_BUILD_DIR"], 'Gemfile.lock'), 'w') {|f| f.puts "Some lock contents" }
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'builds a new archive if one does not already exist' do
|
54
|
+
expect(@cache).to receive(:archive_and_upload_bundle).once.with(no_args)
|
55
|
+
|
56
|
+
@cache.cache_bundle
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'builds a new archive if the sha has changed' do
|
60
|
+
FileUtils.mkdir_p("~/")
|
61
|
+
File.open(File.expand_path("~/remote_owner-repo-#{@uname}-#{@ruby_version}.tgz.sha2"), 'w') {|f| f.print "old sha hash" }
|
62
|
+
expect(@cache).to receive(:archive_and_upload_bundle).once.with(no_args)
|
63
|
+
|
64
|
+
@cache.cache_bundle
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'does not build a new archive if the sha matches' do
|
68
|
+
FileUtils.mkdir_p("~/")
|
69
|
+
File.open(File.expand_path("~/remote_owner-repo-#{@uname}-#{@ruby_version}.tgz.sha2"), 'w') {|f| f.print "be7b966bd555fffd27c11f2557484501ad2ed482f1b6164457433800e163ae29" }
|
70
|
+
expect(@cache).to receive(:archive_and_upload_bundle).never
|
71
|
+
expect(@cache).to receive(:puts).with("=> There were no changes, doing nothing")
|
72
|
+
|
73
|
+
@cache.cache_bundle
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'does not build a new archive for pull requests' do
|
77
|
+
ENV['TRAVIS_PULL_REQUEST'] = '1'
|
78
|
+
expect(@cache).to receive(:archive_and_upload_bundle).never
|
79
|
+
expect(@cache).to receive(:puts).with("=> This is a pull request, doing nothing")
|
80
|
+
|
81
|
+
@cache.cache_bundle
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'does not build a new archive for a non master brnach' do
|
85
|
+
ENV['TRAVIS_BRANCH'] = 'not-master'
|
86
|
+
expect(@cache).to receive(:archive_and_upload_bundle).never
|
87
|
+
expect(@cache).to receive(:puts).with("=> This is not the master branch, doing nothing")
|
88
|
+
|
89
|
+
@cache.cache_bundle
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'archive_and_upload_bundle' do
|
94
|
+
before(:each) do
|
95
|
+
@cache.stub(:puts)
|
96
|
+
@cache.stub(:run_command)
|
97
|
+
AWS::S3::S3Object.any_instance.stub(:write)
|
98
|
+
|
99
|
+
@cache.instance_variable_set(:@bundle_digest, 'be7b966bd555fffd27c11f2557484501ad2ed482f1b6164457433800e163ae29')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'runs bundle clean if there was an old archive' do
|
103
|
+
@cache.instance_variable_set(:@old_digest, 'non-empty-string')
|
104
|
+
expect(@cache).to receive(:run_command).with("bundle clean")
|
105
|
+
|
106
|
+
@cache.archive_and_upload_bundle
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'archives the current bundle directory' do
|
110
|
+
expect(@cache).to receive(:run_command).with(%{cd ~ && tar -cjf "owner-repo-#{@uname}-#{@ruby_version}.tgz" .bundle}, exit_on_error: true)
|
111
|
+
|
112
|
+
@cache.archive_and_upload_bundle
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'sends the correct files to S3' do
|
116
|
+
storage = {
|
117
|
+
"owner-repo-#{@uname}-#{@ruby_version}.tgz" => double(AWS::S3::S3Object),
|
118
|
+
"owner-repo-#{@uname}-#{@ruby_version}.tgz.sha2" => double(AWS::S3::S3Object)
|
119
|
+
}
|
120
|
+
@cache.stub(:storage).and_return(storage)
|
121
|
+
|
122
|
+
expect(storage["owner-repo-#{@uname}-#{@ruby_version}.tgz"]).to receive(:write).with(Pathname.new(File.expand_path("~/owner-repo-#{@uname}-#{@ruby_version}.tgz")), reduced_redundancy: true)
|
123
|
+
expect(storage["owner-repo-#{@uname}-#{@ruby_version}.tgz.sha2"]).to receive(:write).with("be7b966bd555fffd27c11f2557484501ad2ed482f1b6164457433800e163ae29", content_type: 'text/plain', reduced_redundancy: true)
|
124
|
+
|
125
|
+
@cache.archive_and_upload_bundle
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'travis_bundle_cache/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "travis_bundle_cache-rentify"
|
8
|
+
spec.version = TravisBundleCache::VERSION
|
9
|
+
spec.authors = ["David Genord II"]
|
10
|
+
spec.email = ["david@collectiveidea.com"]
|
11
|
+
spec.description = %q{Cache the gem bundle for speedy travis builds}
|
12
|
+
spec.summary = %q{Cache the gem bundle for speedy travis builds}
|
13
|
+
spec.homepage = "https://github.com/rentify/travis_bundle_cache"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.executables = ["travis_bundle_cache", "travis_bundle_install"]
|
21
|
+
|
22
|
+
spec.add_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_dependency "aws-sdk"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: travis_bundle_cache-rentify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Genord II
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Cache the gem bundle for speedy travis builds
|
42
|
+
email:
|
43
|
+
- david@collectiveidea.com
|
44
|
+
executables:
|
45
|
+
- travis_bundle_cache
|
46
|
+
- travis_bundle_install
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- .gitignore
|
51
|
+
- .travis.yml
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/travis_bundle_cache
|
57
|
+
- bin/travis_bundle_install
|
58
|
+
- gem-public_cert.pem
|
59
|
+
- lib/travis_bundle_cache.rb
|
60
|
+
- lib/travis_bundle_cache/cache.rb
|
61
|
+
- lib/travis_bundle_cache/version.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
- spec/travis_bundle_cache_spec.rb
|
64
|
+
- travis_bundle_cache.gemspec
|
65
|
+
homepage: https://github.com/rentify/travis_bundle_cache
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.1.10
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Cache the gem bundle for speedy travis builds
|
89
|
+
test_files:
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
- spec/travis_bundle_cache_spec.rb
|