Continuous Integration with TravisCI
Justin James
Continuous Integration
Frequently integrating code into a shared repository with an automated build for each check-in
Detect problems early and locate them more easily.
"Continuous Integration doesn’t get rid of bugs, but it does make them dramatically easier to find and remove.”
Martin Fowler, Chief Scientist, ThoughtWorks
CI More than a process
backed by several practices and principles
-
Maintain a Single Respository
-
Automate the build
-
Keep the build fast
-
Every commit should build on an integration machine
-
Test in a clone of the production environment
Practices
-
Developers check out code
-
Developer commit the change
-
CI server monitors the repo for changes
-
CI server builds the system and runs tests
-
CI server informs the team of build status
-
If build or test fails, team fixes at the earliest opportunity
How to do it
-
Check in frequently
-
Don't check in broken code
-
Don't check in untested code
-
Don't check in when the build is broken
-
Don't go home after checking in until the system builds
Team Responsibilities
Automate Tests are Key
CI without tests is like never changing the oil in your car. It is just a matter of time before it blows up.
said by me, just now
TravisCI
Hosted continuous integration service for open-source and private projects.
Android C/C++ Clojure Erlang Go Groovy
Haskell Java Javascript NodeJS Objective-C
Perl Php Phython Ruby Scala
MySQL PostgreSQL MongoDB CouchDB
Redis Riak RabbitMQ Memcached
Cassandra Neo4j Elasticsearch
Krestel SQLLite3 ZeroMQ
Services
Email IRC Campfire Flowdock
HipChat Pushover Sqwiggle
Slack Webhook
Notifications
Heroku Azure Web Apps Github Releases
Google App Engine Google Cloud Storage
AWS Opsworks AWS Code Deploy
Deploy
Docs
How does it work?
login
service hook
git push
git add .travis.yml
git commit .travis.yml
git push
git add .travis.yml
git commit .travis.yml
service hook
run tests / builds
fresh environments
Build Lifecycle
- before_install
- install
- before_script
- script
- after_success
- after_failure
- before_deploy
- deploy
- after_deploy
- after_script
.travis.yml
language: ruby
cache: bundler
sudo: true
rvm:
- 2.0.0
before_install:
- sudo apt-get -qq update
- sudo apt-get install ncftp
- gem install bundler
- gem install html-proofer
script:
- chmod +x scripts/build
- ./scripts/build
after_success:
- chmod +x scripts/deploy
- ./scripts/deploy
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
.travis.yml
# blacklist
branches:
except:
- master
# whitelist
branches:
only:
- scheduled
build script
bundle exec jekyll build
--config _config.yml,_configdev.yml,_configazure.yml
--drafts
deploy script
ncftp -u "$USERNAME" -p "$PASSWORD" $HOST<<EOF
rm -rf site/wwwroot
mkdir site/wwwroot
quit
EOF
cd _site
rm robots.txt
touch robots.txt
echo -e "# robots.txt" >> robots.txt
echo -e "User-agent: *" >> robots.txt
echo -e "Disallow: /" >> robots.txt
echo -e "Disallow: /cgi-bin/" >> robots.txt
ncftpput -R -v -u "$USERNAME" -p "$PASSWORD" $HOST /site/wwwroot .
htmlproofer ./_site --only-4xx
Secret Info
Pricing
Demo Time
Alternatives
Hosted:
-
Visual Studio Team Services
Self-Hosted:
-
Jenkins
-
Cruise Control .NET
-
Team City
Cost to Create CI
-
It is not free
-
It is code that has to be maintained
-
More complicated the app, more complicated CI can be
-
Not every tech stack plays well with command line tools
-
Benefits far out weight the cost
thank you
@digitaldrummerj - digitaldrummerj@gmail.com
http://digitaldrummerj.me
TravisCI Intro
By Justin James
TravisCI Intro
- 3,857