Github, Travis-CI and Perl

Post on 27-Aug-2014

2.791 views 9 download

Tags:

description

A quick introduction to using Github and Travis-CI to test Perl projects

Transcript of Github, Travis-CI and Perl

Github,Travis­CI

& PerlDave Cross

dave@perlhacks.com@davorg

Github is Awesome

Github is Awesome Because

Github is Awesome Because

● Git

Github is Awesome Because

● Git● Social coding

Github is Awesome Because

● Git● Social coding● Free

Github is Awesome Because

● Git● Social coding● Free● Octocat

Github is Awesome Because

API

APIs are Awesome

APIs allow you to add cool features to 

Github

APIs are Awesome

APIs allow other people to add cool features to Github

APIs are Awesome

APIs allow other people to add cool features to Github

APIs are Awesome

APIs allow whole ecosystem of cool 

new toys

Continuous Integration

Continuous Integration

● Source code control is awesome

Continuous Integration

● Source code control is awesome● Units tests are awesome

Continuous Integration

● Source code control is awesome● Units tests are awesome● Continuous integration is running 

unit tests whenever you commit code

Continuous Integration

● Source code control is awesome● Units tests are awesome● Continuous integration is running 

unit tests whenever you commit code● Which is awesome

Travis­CI is Awesome

Travis­CI is Awesome

● Travis­CI monitors your Github projects

Travis­CI is Awesome

● Travis­CI monitors your Github projects● Watches for commits

Travis­CI is Awesome

● Travis­CI monitors your Github projects● Watches for commits● Runs unit tests

Travis­CI is Awesome

● Travis­CI monitors your Github projects● Watches for commits● Runs unit tests● Reports success or failure

Travis­CI is Awesome

● Travis­CI monitors your Github projects● Watches for commits● Runs unit tests● Reports success or failure● Which is awesome

Travis­CI & Perl

● Easy to enable Travis­CI for Perl projects

Travis­CI & Perl

● Easy to enable Travis­CI for Perl projects● Just add a file to your repos

Travis­CI & Perl

● Easy to enable Travis­CI for Perl projects● Just add a file to your repos● .travis.yml

Travis­CI & Perl

● Easy to enable Travis­CI for Perl projects● Just add a file to your repos● .travis.yml● Sign up with Travis

Travis­CI & Perl

● Easy to enable Travis­CI for Perl projects● Just add a file to your repos● .travis.yml● Sign up with Travis● Activate project

.travis.yml

language: perlperl:  ­ "5.18"  ­ "5.16"  ­ "5.14"

(Sidebar)

● No Perl 5.20 support yet● Planned but not implemented● There is a workaround● See http://mgnm.at/travis520

Sign Up With Travis­CI

Sign Up With Travis­CI

● http://travis­ci.org/

Sign Up With Travis­CI

● http://travis­ci.org/● Sign in with your Github account

Sign Up With Travis­CI

Sign Up With Travis­CI

Integrating Continuously

● Now you're set up

Integrating Continuously

● Now you're set up● Commit a change to your repository

Integrating Continuously

● Now you're set up● Commit a change to your repository● And wait

Integrating Continuously

● Now you're set up● Commit a change to your repository● And wait● ...

Build Results

Build Results

Build Results

Build Results

Build Results

Build Results

Badges

Badges

Badges

Badges

More Complex Stuff

● That's all very easy

More Complex Stuff

● That's all very easy● Not all code is that simple

More Complex Stuff

● That's all very easy● Not all code is that simple● Can we do more?

More Complex Stuff

● That's all very easy● Not all code is that simple● Can we do more?● Rhetorical question

Example: Adding Database

● A database is a common requirement

Example: Adding Database

● A database is a common requirement● Include schema in repo

Example: Adding Database

● A database is a common requirement● Include schema in repo● Include data in repo

Example: Adding Database

● A database is a common requirement● Include schema in repo● Include data in repo● Load database before testing

Example: Adding Database

● A database is a common requirement● Include schema in repo● Include data in repo● Load database before testing● “before_script” (in .travis.yml)

Example: Adding Database

before_script: - mysql -e 'create database my_db;' - mysql -D my_db < db/load_db.sql

Example: Connecting to Database

● Travis­CI sets up a database user

Example: Connecting to Database

● Travis­CI sets up a database user● Called “travis”

Example: Connecting to Database

● Travis­CI sets up a database user● Called “travis”● No password

Example: Connecting to Database

● Travis­CI sets up a database user● Called “travis”● No password● Use env variables

Example: Connecting to Database

● Travis­CI sets up a database user● Called “travis”● No password● Use env variables● “env” (in .travis.yml)

Example: Connecting to Database

env: MYAPP_DB_SERVER=localhost MYAPP_DB_NAME=my_db MYAPP_DB_USER=travis MYAPP_DB_PASS=''

Example: Test Coverage

● Automatically run test coverage

Example: Test Coverage

● Automatically run test coverage● http://coveralls.io/

Example: Test Coverage

● Automatically run test coverage● http://coveralls.io/● Add to .travis.yml

.travis.ymlinstall:  cpanm ­­quiet –notest \           Devel::Cover::Report::Coveralls

script:  ­ PERL5OPT=­Mdevel::Cover=­coverage,statement, \    branch,condition,path,subroutine prove ­lrsv t  ­ cover

after_success:  ­ cover ­report coveralls

See also

● http://mgnm.at/travis520

Example: Test Coverage

Example: Test Coverage

Example: Test Coverage

More and More

● Many more things are possible

More and More

● Many more things are possible● Barely scratching the surface

More and More

● Many more things are possible● Barely scratching the surface● See http://docs.travis­ci.com/

More and More

● Many more things are possible● Barely scratching the surface● See http://docs.travis­ci.com/● If you do something cool, please blog it

Summary

Summary

● Github is awesome

Summary

● Github is awesome● Unit tests are awesome

Summary

● Github is awesome● Unit tests are awesome● Continuous integration is awesome

Summary

● Github is awesome● Unit tests are awesome● Continuous integration is awesome● Travis­CI is awesome

Summarised Summary

Summarised Summary

● APIs are awesome

Summarised Summary

● APIs are awesome● Other people are awesome

Questions?

Thank You

Dave Crossdave@perlhacks.com

@davorg