bitbucketのプライベートリポジトリを無料でCIしてくれるみんなの味方werckerですが、
とあるrailsのプロジェクトで試しに使ってみたところ若干ハマったところがあったのでメモ。
werckerはwercker.yml
にbuildやdeployのために必要なモノやステップを記述しておくと、
pushした時に自動でテストが走ります。
# sample via http://devcenter.wercker.com/articles/werckeryml/
box: wercker/ruby
services:
- mies/rethinkdb
build:
steps:
# Execute the bundle install step, a step provided by wercker
- bundle-install
# Execute a custom script step.
- script:
name: middleman build
code: bundle exec middleman build --verbose
deploy:
steps:
# Execute the heroku-deploy, heroku details can be edited
# online at http://app.wercker.com/
#- heroku-deploy
# Execute the s3sync deploy step, a step provided by wercker
- s3sync:
key_id: $AWS_ACCESS_KEY_ID
key_secret: $AWS_SECRET_ACCESS_KEY
bucket_url: $AWS_BUCKET_URL
source_dir: build/
after-steps:
- hipchat-notify:
token: $HIPCHAT_TOKEN
room-id: id
from-name: name
で、サンプルにもあるように
build:
steps:
- bundle-install
と書いておけばbuild時にbundle install
が走るのですが、
ここで
cd $WERCKER_SOURCE_DIR
$ export WERCKER_STEP_ROOT="/wercker/steps/wercker/bundle-install/1.1.1"
$ export WERCKER_STEP_ID="be022acd-9e27-435d-8071-9932df7a776a"
$ export WERCKER_STEP_NAME="bundle-install"
$ export WERCKER_REPORT_NUMBERS_FILE="$WERCKER_REPORT_DIR/$WERCKER_STEP_ID/numbers.ini"
$ export WERCKER_REPORT_MESSAGE_FILE="$WERCKER_REPORT_DIR/$WERCKER_STEP_ID/message.txt"
$ export WERCKER_REPORT_ARTIFACTS_DIR="$WERCKER_REPORT_DIR/$WERCKER_STEP_ID/artifacts"
$ mkdir -p $WERCKER_REPORT_ARTIFACTS_DIR
$ export WERCKER_STEP_TEMP="/tmp/$WERCKER_STEP_ID"
$ source '/wercker/wercker-build-essentials/init.sh'
$ mkdir -p $WERCKER_STEP_TEMP
$ source "$WERCKER_STEP_ROOT/run.sh"
Gemfile found. Start bundle install.
bundler gem is available, and will not be installed by this step
type bundle: bundle is /home/ubuntu/.rvm/gems/ruby-2.2.0@global/bin/bundle
bundle version: Bundler version 1.7.9
bundle install --path /cache/bundle-install/
Fetching source index from https://rubygems.org/
Using rake 10.4.2
Using abstract_type 0.0.7
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
・・・(中略)・・・
Using better_errors 2.1.1
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using bootstrap-sass 3.3.3
Using rainbow 2.0.0
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/home/ubuntu/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150128-1056-n23jjh.rb extconf.rb
checking for cmake... no
ERROR: CMake is required to build Rugged.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/ubuntu/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
extconf failed, exit code 1
Gem files will remain installed in /cache/bundle-install/ruby/2.2.0/gems/rugged-0.21.4 for inspection.
Results logged to /cache/bundle-install/ruby/2.2.0/extensions/x86_64-linux/2.2.0/rugged-0.21.4/gem_make.out
An error occurred while installing rugged (0.21.4), and Bundler cannot continue.
Make sure that `gem install rugged -v '0.21.4'` succeeds before bundling.
こんなかんじでcmakeがないと怒られにっちもさっちもいかない状態に...
やむを得ず問い合わせてみると
You can install any package you need using the install-package step:
https://app.wercker.com/#applications/51c829ea3179be4478002168/tab/details
If you install a lot of packages that take up a long time in your build process, it can become > > worthwhile to create your own box that has the packages pre-installed:
とのこと。
どうやらパッケージの依存関係が足りないなら足したらいいじゃないということのようなので、
steps:
- wercker/install-packages@0.0.4
- install-packages:
packages: cmake
- bundle-install
こんなかんじでcmakeを足してあげたところ無事通りましたとさ。
めでたしめでたし。