diff --git a/.travis.yml b/.travis.yml index c86aa045..c01a062d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,14 @@ +sudo: false language: ruby env: matrix: - APP_SECRET_TOKEN=b2724973fd81c2f4ac0f92ac48eb3f0152c4a11824c122bcf783419a4c51d8b9bba81c8ba6a66c7de599677c7f486242cf819775c433908e77c739c5c8ae118d - global: - - AMAZON_S3_BUCKET=huginn-bundle-cache - - AMAZON_ACCESS_KEY_ID=AKIAITMDBT3BL3ZWVFGA - - secure: JbDX6yVP+Q32FOl7UmB7bBxaEGDNYd3IlfDACmdRHkf23yRa4RvQD1U1Gu8kh8c5Els2VvzUWEkv7VjJWNgxVJFnbGbqbnIrbdEhGMTwXnJjpuzAx2+TWuXUEGFeZVqtNqtxSW1r/CCAFYtWpnX0jW27wLQvRitY1r/BqiXXDgc= rvm: - 2.0.0 -- 2.1.4 +- 2.1.5 - 1.9.3 -before_install: -- travis_retry gem install bundler -install: travis_retry script/cached-bundle install --without development production --deployment +cache: bundler +bundler_args: --without development production before_script: - mysql -e 'create database huginn_test;' - bundle exec rake db:migrate db:test:prepare diff --git a/script/cached-bundle b/script/cached-bundle deleted file mode 100755 index 45ef8f16..00000000 --- a/script/cached-bundle +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -# Usage: cached-bundle install --deployment -# -# After running `bundle`, caches the `vendor/bundle` directory to S3. -# On the next run, restores the cached directory before running `bundle`. -# When `Gemfile.lock` changes, the cache gets rebuilt. -# -# Requirements: -# - Gemfile.lock -# - TRAVIS_REPO_SLUG -# - TRAVIS_RUBY_VERSION -# - AMAZON_S3_BUCKET -# - script/s3-put -# - bundle -# - curl -# -# Author: Mislav Marohnić - -set -e - -compute_md5() { - local output="$(openssl md5)" - echo "${output##* }" -} - -download() { - curl --tcp-nodelay -qsfL "$1" -o "$2" -} - -bundle_path="vendor/bundle" -gemfile_hash="$(compute_md5 <"${BUNDLE_GEMFILE:-Gemfile}.lock")" -#cache_name="${TRAVIS_RUBY_VERSION}-${gemfile_hash}.tgz" -cache_name="${TRAVIS_RUBY_VERSION}.tgz" -fetch_url="http://${AMAZON_S3_BUCKET}.s3.amazonaws.com/${cache_name}" - -if download "$fetch_url" "$cache_name"; then - echo "Reusing cached bundle ${cache_name}" - tar xzf "$cache_name" -fi - -bundle "$@" - -if [ ! -f "$cache_name" ]; then - echo "Caching \`${bundle_path}' to S3" - tar czf "$cache_name" "$bundle_path" - script/s3-put "$cache_name" "${AMAZON_S3_BUCKET}:${cache_name}" -fi diff --git a/script/s3-put b/script/s3-put deleted file mode 100755 index 036e845d..00000000 --- a/script/s3-put +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env bash -# Usage: s3-put [:] [] -# -# Uploads a file to the Amazon S3 service. -# Outputs the URL for the newly uploaded file. -# -# Requirements: -# - AMAZON_ACCESS_KEY_ID -# - AMAZON_SECRET_ACCESS_KEY -# - openssl -# - curl -# -# Author: Mislav Marohnić - -set -e - -authorization() { - local signature="$(string_to_sign | hmac_sha1 | base64)" - echo "AWS ${AMAZON_ACCESS_KEY_ID?}:${signature}" -} - -hmac_sha1() { - openssl dgst -binary -sha1 -hmac "${AMAZON_SECRET_ACCESS_KEY?}" -} - -base64() { - openssl enc -base64 -} - -bin_md5() { - openssl dgst -binary -md5 -} - -string_to_sign() { - echo "$http_method" - echo "$content_md5" - echo "$content_type" - echo "$date" - echo "x-amz-acl:$acl" - printf "/$bucket/$remote_path" -} - -date_string() { - LC_TIME=C date "+%a, %d %h %Y %T %z" -} - -file="$1" -bucket="${2%%:*}" -remote_path="${2#*:}" -content_type="$3" - -if [ -z "$remote_path" ] || [ "$remote_path" = "$bucket" ]; then - remote_path="${file##*/}" -fi - -http_method=PUT -acl="public-read" -content_md5="$(bin_md5 < "$file" | base64)" -date="$(date_string)" - -url="https://$bucket.s3.amazonaws.com/$remote_path" - -curl -qsSf -T "$file" \ - -H "Authorization: $(authorization)" \ - -H "x-amz-acl: $acl" \ - -H "Date: $date" \ - -H "Content-MD5: $content_md5" \ - -H "Content-Type: $content_type" \ - "$url" - -echo "$url"