Continuous Integration for Open Source Projects with Travis-CI

#NDCOslo

@GeekGoneNomad

Kyle Tyacke

@GeekGoneNomad

Kyle Tyacke

@GeekGoneNomad

Kyle Tyacke

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

Continuous Integration

...a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

–https://www.thoughtworks.com/continuous-integration

#NDCOslo

@geekgonenomad

Continuous Integration

...a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

#NDCOslo

@geekgonenomad

Continuous Integration

...a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

#NDCOslo

@geekgonenomad

Continuous Integration

...a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

#NDCOslo

@geekgonenomad

Continuous Integration

...a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

#NDCOslo

@geekgonenomad

Continuous Integration

...a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

Travis CI

...a hosted continuous integration service

that's free for open source projects.

#NDCOslo

@GeekGoneNomad

Travis CI

...a hosted continuous integration service that's free for open source projects.

#NDCOslo

@GeekGoneNomad

Travis CI

...a hosted continuous integration service

that's free for open source projects.

#NDCOslo

@GeekGoneNomad

Open Source

Multi-Language

Pull Requests

Simplified Deployments

Easy

Travis CI

#NDCOslo

@GeekGoneNomad

Language Support

Adding Travis

to Your Project

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

Success

#NDCOslo

@GeekGoneNomad

Failure

Pull Requests

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

Pull Request Workflow

#NDCOslo

@GeekGoneNomad

Pull Request Success

#NDCOslo

@GeekGoneNomad

Pull Request Failure

.travis.yml

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

INSTALL

before_install

install

BUILD

before_script

script

after_success 

after_failure

after_script

DEPLOY 

before_deploy

deploy

after_deploy

Travis Build Lifecycle

#NDCOslo

@GeekGoneNomad

INSTALL

before_install

install

BUILD

before_script

script

after_success 

after_failure

after_script

DEPLOY 

before_deploy

deploy

after_deploy

Travis Build Lifecycle

#NDCOslo

@GeekGoneNomad

INSTALL

before_install

install

BUILD

before_script

script

after_success

after_failure

after_script

DEPLOY 

before_deploy

deploy

after_deploy

Travis Build Lifecycle

#NDCOslo

@GeekGoneNomad

INSTALL

before_install

install

BUILD

before_script

script

after_success 

after_failure

after_script

DEPLOY

before_deploy

deploy

after_deploy

Travis Build Lifecycle

#NDCOslo

@GeekGoneNomad

Linting

#NDCOslo

@GeekGoneNomad

Linting

language: node_js

node_js:
  - stable

before_script:
  - npm install -g jscs

script: 
  - jscs src
  - mocha

#ConfHandle

@geekgonenomad

Linting Failure

#NDCOslo

@GeekGoneNomad

Linting Failure

#NDCOslo

@GeekGoneNomad

Database Support

  • MySQL

  • PosgreSQL

  • SQLite3

  • MongoDB

  • CouchDB

  • Redis

#NDCOslo

@GeekGoneNomad

Databases

services:
  - couchdb

before_script:
  - curl -X PUT http://127.0.0.1:5984/travis-node-demo
  - curl -X GET http://127.0.0.1:5984/_all_dbs

#NDCOslo

@GeekGoneNomad

Databases

#NDCOslo

@GeekGoneNomad

Databases

$ sudo service couchdb start
couchdb start/running, process 2303

$ curl -X PUT http://127.0.0.1:5984/travis-node-demo
{"ok":true}

$ curl -X GET http://127.0.0.1:5984/_all_dbs
["_replicator","_users","travis-node-demo"]

#NDCOslo

@GeekGoneNomad

The Travis Client

#NDCOslo

@GeekGoneNomad

Deployment

  • Heroku

  • NPM

  • PyPi

  • Amazon S3

  • RubyGems

  • Github 

#NDCOslo

@GeekGoneNomad

Deployment

before_deploy:
  - npm version patch

deploy:
  provider: npm
  email: ktyacke@gmail.com
  api_key:
    secure: XXXXXXXXXXXXX
  on:
    tags: true
    repo: ktyacke/travis-node-example
    all_branches: true

#NDCOslo

@GeekGoneNomad

Deployment

# ENCRYPT AND ADD KEY TO CONFIG
travis encrypt YOUR_API_KEY --add deploy.api_key

# USE CLI TO ADD DEPLOYMENT PROVIDER
travis setup npm

#NDCOslo

@GeekGoneNomad

Deployment

#NDCOslo

@GeekGoneNomad

Installing deploy dependencies
Preparing deploy
NPM version: 3.8.3
Authenticated with email ktyacke@gmail.com

Cleaning up git repository with `git stash --all`. If you need build artifacts for deployment, set `deploy.skip_cleanup: true`. 
See https://docs.travis-ci.com/user/deployment/#Uploading-Files.

Deploying application
NPM API key format changed recently. If your deployment fails, check your API key in ~/.npmrc.
http://docs.travis-ci.com/user/deployment/npm/
~/.npmrc size: 48
+ travis-node-example@1.0.4

Deployment

#NDCOslo

@GeekGoneNomad

Notifications

  • Email

  • IRC

  • HipChat

  • Slack

  • Webhooks

#NDCOslo

@GeekGoneNomad

Notifications

notifications:
  email:
    recipients:
      - foo@bar.com
    on_success: always
    on_failure: always

  slack:
    rooms:
      - secure: XXXXXXXXXXXXX
    on_success: always
    on_failure: always
    on_start: always

#NDCOslo

@GeekGoneNomad

Notifications

# ENCRYPT AND ADD TOKEN TO CONFIG
travis encrypt "<account>:<token>" --add notifications.slack.rooms

#NDCOslo

@GeekGoneNomad

Notifications

#NDCOslo

@GeekGoneNomad

Notifications

#NDCOslo

@GeekGoneNomad

Build Status Badges

#MakeOSFunAgain

#NDCOslo

@GeekGoneNomad

#NDCOslo

@GeekGoneNomad

kyle@geekgonenomad.com

Kyle Tyacke

Examples and Source

@GeekGoneNomad

Continuous Integration with Travis-CI (NDC Oslo)

By Kyle Tyacke

Continuous Integration with Travis-CI (NDC Oslo)

  • 1,462