Commit 24daa358 by tady

Merge pull request #30 from tadyjp/wip/140301_travis_speedup

travis cache bundlers in S3
parents 6373022d 453404e9
bundler_args: --without development --path=~/.bundle
language: ruby language: ruby
services:
- mysql
rvm: rvm:
- 2.0.0 - 2.0.0
env:
matrix:
- DB_TEST_DATABASE=rendezvous_test DB_TEST_USER=travis
global:
- secure: iCVObmVUWglzaPBvhJ/oCg/0LXFffDyGii/ws2YanPxXs9QsFhVDDj0WtKikK1ZsvZQBADRUJlQwDeTj2VD8rTGsq0Wu9Tjjz82vm+BJ6wb67QMr8HAdi096QeushLKmuVni1HEZcfStltSbmxkZpeRNf2XH9hkjb98g/2x4mzg=
- BUNDLE_ARCHIVE="rendezvous-travis-bundler"
- AWS_S3_REGION="us-east-1"
- AWS_S3_BUCKET="rendezvous-travis-bundler"
- RAILS_ENV=test
services:
- mysql
before_install:
- "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
- gem install bundler fog
- "sh ./script/travis/bundle_install.sh"
before_script: before_script:
- mysql -e 'CREATE DATABASE rendezvous_test;' - mysql -e 'CREATE DATABASE rendezvous_test;'
- cp config/database.yml.example config/database.yml - cp config/database.yml.example config/database.yml
- cp config/settings.yml.example config/settings.yml - cp config/settings.yml.example config/settings.yml
env: after_script:
- DB_TEST_DATABASE=rendezvous_test DB_TEST_USER=travis - "ruby script/travis/bundle_cache.rb"
script: "bundle exec rake db:create db:test:load spec"
...@@ -6,7 +6,7 @@ rendezvous ...@@ -6,7 +6,7 @@ rendezvous
[![Code Climate](https://codeclimate.com/github/tadyjp/rendezvous.png)](https://codeclimate.com/github/tadyjp/rendezvous) [![Code Climate](https://codeclimate.com/github/tadyjp/rendezvous.png)](https://codeclimate.com/github/tadyjp/rendezvous)
[![Dependency Status](https://gemnasium.com/tadyjp/rendezvous.png)](https://gemnasium.com/tadyjp/rendezvous) [![Dependency Status](https://gemnasium.com/tadyjp/rendezvous.png)](https://gemnasium.com/tadyjp/rendezvous)
A simple markdown-based wiki system for team. A simple markdown-based blog & wiki system for team.
# Supported versions # Supported versions
...@@ -38,28 +38,31 @@ and get ...@@ -38,28 +38,31 @@ and get
5. Get [Client ID] and [Client secret] 5. Get [Client ID] and [Client secret]
## Create your .env file. ## Create and edit config files.
``` ```
$ cp .env.example .env $ cp config/database.yml.example config/database.yml
$ vim .env $ vim config/database.yml
```
Set Google API [Client ID] and [Client secret] in `.env` $ cp config/settings.yml.example config/settings.yml
$ vim config/settings.yml
```
## Setup DB (Default: mysql). ## Setup DB
``` ```
$ (bundle exec) rake db:migrate $ (bundle exec) rake db:migrate
$ (bundle exec) rake db:seed $ (bundle exec) rake db:seed
``` ```
And have fun with your team !
## Set ENV before start server.
```
$ source .env
$ (bundle exec) rails s
```
And have fun with your team ! # Test
Rendezvous uses travis-ci for test.
To speet up `bundle install` in travis-ci, Rendezvous use AWS S3 backet for storing gems.
see also: http://randomerrata.com/post/45827813818/travis-s3
require "digest"
require "fog"
bucket_name = ENV["AWS_S3_BUCKET"]
architecture = `uname -m`.strip
file_name = "#{ENV['BUNDLE_ARCHIVE']}-#{architecture}.tgz"
file_path = File.expand_path("~/#{file_name}")
lock_file = File.join(File.expand_path(ENV["TRAVIS_BUILD_DIR"]), "Gemfile.lock")
digest_filename = "#{file_name}.sha2"
old_digest = File.expand_path("~/remote_#{digest_filename}")
puts "Checking for changes"
bundle_digest = Digest::SHA2.file(lock_file).hexdigest
old_digest = File.exists?(old_digest) ? File.read(old_digest) : ""
if bundle_digest == old_digest
puts "=> There were no changes, doing nothing"
else
if old_digest == ""
puts "=> There was no existing digest, uploading a new version of the archive"
else
puts "=> There were changes, uploading a new version of the archive"
puts " => Old checksum: #{old_digest}"
puts " => New checksum: #{bundle_digest}"
end
puts "=> Preparing bundle archive"
`cd ~ && tar -cjf #{file_name} .bundle && split -b 5m -a 3 #{file_name} #{file_name}.`
parts_pattern = File.expand_path(File.join("~", "#{file_name}.*"))
parts = Dir.glob(parts_pattern).sort
storage = Fog::Storage.new({
:provider => "AWS",
:aws_access_key_id => ENV["AWS_S3_KEY"],
:aws_secret_access_key => ENV["AWS_S3_SECRET"],
:region => ENV["AWS_S3_REGION"] || "us-east-1"
})
puts "=> Uploading the bundle"
puts " => Beginning multipart upload"
response = storage.initiate_multipart_upload bucket_name, file_name, { "x-amz-acl" => "public-read" }
upload_id = response.body['UploadId']
puts " => Upload ID: #{upload_id}"
part_ids = []
puts " => Uploading #{parts.length} parts"
parts.each_with_index do |part, index|
part_number = (index + 1).to_s
puts " => Uploading #{part}"
File.open part do |part_file|
response = storage.upload_part bucket_name, file_name, upload_id, part_number, part_file
part_ids << response.headers['ETag']
puts " => Uploaded"
end
end
puts " => Completing multipart upload"
storage.complete_multipart_upload bucket_name, file_name, upload_id, part_ids
puts "=> Uploading the digest file"
bucket = storage.directories.new(key: bucket_name)
bucket.files.create({
:body => bundle_digest,
:key => digest_filename,
:public => true,
:content_type => "text/plain"
})
end
puts "All done now."
exit 0
ARCHITECTURE=`uname -m`
FILE_NAME="$BUNDLE_ARCHIVE-$ARCHITECTURE.tgz"
cd ~
wget -O "remote_$FILE_NAME" "https://$AWS_S3_BUCKET.s3.amazonaws.com/$FILE_NAME" && tar -xf "remote_$FILE_NAME"
wget -O "remote_$FILE_NAME.sha2" "https://$AWS_S3_BUCKET.s3.amazonaws.com/$FILE_NAME.sha2"
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment