LoginSignup
21

More than 5 years have passed since last update.

【TravisCI高速化】bundle installを毎回走らせないようにキャッシュする

Last updated at Posted at 2014-07-23

はじめに

  • TravisCIのbundle installに非常に時間を食ってるのでなんとかしたい
  • と思ったらこんな記事があったので、試してみました
  • 公式文書はこちら

効果

  • 早くなりました!!!!
    • 16〜21分かかっていたビルドが12〜14分程度になりました

やること

  • 基本的には上にある記事のとおり、.travis.ymlに以下を追加するだけ
  • ただ、bundle installをオーバーライドしているときは以下のように指定する必要がある
    • 公式サイトにも書いてあるがいくつか書き方がある
    • 必要ならばbundler_argsで--wihtoutオプションなども書いてよい
.travis.yml(Exsample1)
...
language: ruby
cache: bundler
bundler_args: --without production --deployment
...
.travis.yml(Exsample2)
...
language: ruby
install: bundle install --without production --deployment
cache:
  directories:
  - vendor/bundle
...

bundle installをオーバーライドしているにもかかわらず、 cache: bundlerしか書いていない場合

  • Travisのコンソールログの一部
...
setup build cache
attempting to download cache archive
could not download cache
...

directoryをvender/bundleに指定した場合

  • Travisのコンソールログの一部
...
setup build cache
attempting to download cache archive
found cache
adding /home/travis/build/[UserName]/[RepositoryName]/vendor/bundle to cache
...

travisコマンドで確認

  • travisコマンド入れてなければインストールしてください
    • $(sudo) gem install travis
$ travis login
$ travis cache
On branch [BranchName]:
cache--rvm-1.9.3--gemfile-Gemfile  last modified: 2014-07-22 11:28:09  size: 156 B

Overall size of above caches: 156 B

最後に、、、一人ではまっていたところ

  • キャッシュは見つかったしvendor/bundleにも配置も出来ているとコンソールには出ているのにキャッシュが効いてくれなかった
  • 以下のような書き方をしていた
.travis.yml
...
language: ruby
install: bundle install --without production --path vendor/bundle
cache:
  directories:
  - vendor/bundle
...

~ただの宣伝~

  • 全国のSeleniumer必読
  • Seleniumerといっていますが、Selenium, SauceLabs, Travis, Jenkinsに関するノウハウ書いているのでよかったら参考にしてみてください

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21