travis_bundle_cache 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +41 -28
- data/lib/travis_bundle_cache/cache.rb +13 -6
- data/lib/travis_bundle_cache/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7439995a443d4ffd1574a246b62b34f30bd9d506
|
4
|
+
data.tar.gz: ee3d3104641f3740629b15d20bf1b6a6afbc6ee0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cfbcd7b6d401c8d0451aaa2d1c159b5576555c7e095582639fdfdb37927fc513961ac945f694f8e776db32af83edeada0d541ef63e4d48f028be4b9a7607a89
|
7
|
+
data.tar.gz: 1654a9719ecd4967354e0bc855dab6df357796bf5bd9c3923e05d49ea3f28cf72801e3e30730b5164dc295c85022de1f63566acec7e96d04795748cb43d0891d
|
data/README.md
CHANGED
@@ -1,52 +1,64 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Travis Bundle Cache
|
2
|
+
===================
|
3
3
|
[](http://badge.fury.io/rb/travis_bundle_cache)
|
4
|
+
[](https://codeclimate.com/github/collectiveidea/travis_bundle_cache)
|
5
|
+
[](https://gemnasium.com/collectiveidea/travis_bundle_cache)
|
6
|
+
|
7
|
+
The primary purpose of this gem is to make [this](http://randomerrata.com/post/45827813818/travis-s3) easier and slightly more maintainable.
|
4
8
|
|
5
|
-
|
9
|
+
This gem loads, builds, and saves a cache of your bundled gems on S3 by *ONLY* modifying your project's .travis.yml file.
|
6
10
|
|
7
|
-
|
11
|
+
What you will need:
|
12
|
+
* A project on Travis CI
|
13
|
+
* An AWS account
|
14
|
+
* A "bundle install" that takes longer than "gem install nokogiri"
|
15
|
+
|
16
|
+
Usage
|
17
|
+
=====
|
8
18
|
|
9
19
|
1. Set up a bucket on S3 in the US Standard region (us-east-1) (and possibly a new user via IAM)
|
10
|
-
|
20
|
+
|
21
|
+
2. Setup your .travis.yml to include the following (NOTE: this must be done before the next steps)
|
22
|
+
|
23
|
+
```yaml
|
24
|
+
env:
|
25
|
+
global:
|
26
|
+
- BUNDLE_ARCHIVE="your-bundle-name"
|
27
|
+
- AWS_S3_REGION="us-east-1"
|
28
|
+
- AWS_S3_BUCKET="your-bucket-name"
|
29
|
+
|
30
|
+
before_install:
|
31
|
+
- 'echo ''gem: --no-ri --no-rdoc'' > ~/.gemrc'
|
32
|
+
- gem install travis_bundle_cache
|
33
|
+
|
34
|
+
install: travis_bundle_install
|
35
|
+
|
36
|
+
after_script:
|
37
|
+
- travis_bundle_cache
|
38
|
+
```
|
39
|
+
|
40
|
+
3. Install the travis gem (not the travis_bundle_cache gem)
|
11
41
|
|
12
42
|
```bash
|
13
43
|
gem install travis
|
14
44
|
```
|
15
45
|
|
16
|
-
|
46
|
+
4. Log into Travis (from inside your project respository directory)
|
17
47
|
|
18
48
|
```bash
|
19
49
|
travis login --auto
|
20
50
|
```
|
21
51
|
|
22
|
-
|
52
|
+
5. Encrypt your S3 credentials (be sure to add your actual credentials inside the double quotes)
|
23
53
|
|
24
54
|
```bash
|
25
55
|
travis encrypt AWS_S3_KEY="" AWS_S3_SECRET="" --add
|
26
56
|
```
|
27
57
|
|
28
|
-
5. Setup your .travis.yml to include the following
|
29
|
-
|
30
|
-
```yaml
|
31
|
-
env:
|
32
|
-
global:
|
33
|
-
- BUNDLE_ARCHIVE="your-bundle-name"
|
34
|
-
- AWS_S3_REGION="us-east-1"
|
35
|
-
- AWS_S3_BUCKET="your-bucket-name"
|
36
|
-
|
37
|
-
before_install:
|
38
|
-
- "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
|
39
|
-
- "gem install travis_bundle_cache"
|
40
|
-
|
41
|
-
install: travis_bundle_install
|
42
|
-
|
43
|
-
after_script:
|
44
|
-
- "travis_bundle_cache"
|
45
|
-
```
|
46
|
-
|
47
58
|
Enjoy faster builds
|
48
59
|
|
49
|
-
|
60
|
+
Contributions
|
61
|
+
=============
|
50
62
|
|
51
63
|
TravisBundleCache is open source and contributions from the community are encouraged! No contribution is too small. Please consider:
|
52
64
|
|
@@ -63,6 +75,7 @@ For the best chance of having your changes merged, please:
|
|
63
75
|
3. Commit your changes and tests (if applicable (they're applicable)).
|
64
76
|
4. Submit a pull request with a thorough explanation and at least one animated GIF.
|
65
77
|
|
66
|
-
|
78
|
+
Thanks
|
79
|
+
======
|
67
80
|
|
68
81
|
Most of the credit for this gem goes to Random Errata and [this](http://randomerrata.com/post/45827813818/travis-s3) blog post
|
@@ -24,7 +24,11 @@ module TravisBundleCache
|
|
24
24
|
@bundle_digest = Digest::SHA2.file(@lock_file).hexdigest
|
25
25
|
@old_digest = File.exists?(@old_digest_filename) ? File.read(@old_digest_filename) : ""
|
26
26
|
|
27
|
-
if
|
27
|
+
if ENV['TRAVIS_PULL_REQUEST'].to_i > 0
|
28
|
+
puts "=> This is a pull request, doing nothing"
|
29
|
+
elsif ENV['TRAVIS_BRANCH'] != "master"
|
30
|
+
puts "=> This is not the master branch, doing nothing"
|
31
|
+
elsif @bundle_digest == @old_digest
|
28
32
|
puts "=> There were no changes, doing nothing"
|
29
33
|
else
|
30
34
|
archive_and_upload_bundle
|
@@ -38,17 +42,20 @@ module TravisBundleCache
|
|
38
42
|
puts "=> There were changes, uploading a new version of the archive"
|
39
43
|
puts " => Old checksum: #{@old_digest}"
|
40
44
|
puts " => New checksum: #{@bundle_digest}"
|
45
|
+
|
46
|
+
puts "=> Cleaning old gem versions from the bundle"
|
47
|
+
run_command "bundle clean"
|
41
48
|
end
|
42
49
|
|
43
50
|
puts "=> Preparing bundle archive"
|
44
51
|
`cd ~ && tar -cjf "#{@file_name}" .bundle && split -b 5m -a 3 "#{@file_name}" "#{@file_name}."`
|
45
52
|
|
46
53
|
parts_pattern = File.expand_path(File.join("~", "#{@file_name}.*"))
|
47
|
-
parts
|
54
|
+
parts = Dir.glob(parts_pattern).sort
|
48
55
|
|
49
56
|
puts "=> Uploading the bundle"
|
50
57
|
puts " => Beginning multipart upload"
|
51
|
-
response
|
58
|
+
response = storage.initiate_multipart_upload(@bucket_name, @file_name, { "x-amz-acl" => "public-read" })
|
52
59
|
upload_id = response.body['UploadId']
|
53
60
|
puts " => Upload ID: #{upload_id}"
|
54
61
|
|
@@ -58,15 +65,15 @@ module TravisBundleCache
|
|
58
65
|
parts.each_with_index do |part, index|
|
59
66
|
part_number = (index + 1).to_s
|
60
67
|
puts " => Uploading #{part}"
|
61
|
-
File.open
|
62
|
-
response = storage.upload_part
|
68
|
+
File.open(part) do |part_file|
|
69
|
+
response = storage.upload_part(@bucket_name, @file_name, upload_id, part_number, part_file)
|
63
70
|
part_ids << response.headers['ETag']
|
64
71
|
puts " => Uploaded"
|
65
72
|
end
|
66
73
|
end
|
67
74
|
|
68
75
|
puts " => Completing multipart upload"
|
69
|
-
storage.complete_multipart_upload
|
76
|
+
storage.complete_multipart_upload(@bucket_name, @file_name, upload_id, part_ids)
|
70
77
|
|
71
78
|
puts "=> Uploading the digest file"
|
72
79
|
bucket = storage.directories.new(key: @bucket_name)
|