To get started with Travis CI, sign in through GitHub OAuth. Go to Travis CI and follow the Sign In link at the top.
GitHub will ask you to grant read and write access. Travis CI needs write access for setting up service hooks20.1 for your repositories when you request it, but it won't touch anything else.
Once you're signed in go to your profile page. You'll see a list of your repositories.
Flip the on/off switch for each repository that you want to hook up on Travis CI.
In order for Travis to build your project, you need to tell the system a little bit about it.
To do so, add .travis.yml
to the root
of your repository.
.travis.yml
is not in the repository, is misspelled or is not
valid YAML, travis-ci.org will ignore it, assume Ruby as the language
and use default values for everything.
[~/srcLPP/coro/frac(master)]$ cat .travis.yml language: ruby rvm: - 1.9.3 - jruby-18mode # JRuby in 1.8 mode - jruby-19mode # JRuby in 1.9 mode - rbx-18mode - rbx-19mode - 1.8.7
Inside a repository with .travis.yml
[~/sinatra/sinatra-number_cruncher(master)]$ travis lint Hooray, .travis.yml looks valid :)
travis-lint
will check things like
.travis.yml
file is valid YAML
Once GitHub hook is set up, push your commit that adds
.travis.yml
to your repository.
That should add a build into one of the queues on Travis CI and your build will start as soon as one worker for your language is available.
To start a build commit and push something to your repository
Travis will use Bundler
to install your project's dependencies and
run rake
by default to execute your tests.
Please note that you
need to add rake
to your Gemfile
(adding it to just :test
group
should be sufficient).
group :development, :test do gem "rake" endGroups can be ignored by
bundle
at install-time (using --without=GROUP1[ GROUP2...]
).
[~/srcLPP/coro/frac(master)]$ cat Gemfile source 'https://rubygems.org' gem 'rake' gem 'rspec'
Exclude non-essential gems like ruby-debug
from your Gemfile
.
./gemfiles
is a commonly used name)
.travis.yml
gemfile: - Gemfile - gemfiles/eventmachine-pre
gemfile: gemfiles/Gemfile.ciUnless specified, the worker will look for a file named
Gemfile
in the root of your project.
You can also set extra arguments to be passed to bundle install:
bundler_args: --without=development
john@exthost:~/291012/frac$ rake -T rake spec # Run RSpec code examples rake specman # Run rspec with --format documentation rake thtml # Run rspec with format: html
john@exthost:~/291012/frac$ cat Rakefile $:.unshift File.dirname(__FILE__) + 'lib' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new task :default => :spec desc "Run rspec with --format documentation" task :specman do sh "rspec -Ilib spec/frac_spec.rb --format documentation" end desc "Run rspec with format: html" task :thtml do sh "rspec -Ilib spec/frac_.rb --format html > index.html" endVéase la documentación de la clase RSpec::Core::RakeTask.
john@exthost:~/291012/frac$ rake /usr/local/ruby/bin/ruby -S rspec ./spec/frac_spec.rb .................... Finished in 0.00451 seconds 20 examples, 0 failures john@exthost:~/291012/frac$
[~/srcLPP/coro/frac(master)]$ tree -A . |-- Gemfile |-- README |-- Rakefile |-- lib | `-- fraction.rb `-- spec `-- frac_spec.rb 2 directories, 5 files