Github, Travis-CI and Perl

8,451 views

Published on

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

Published in: Software
3 Comments
8 Likes
Statistics
Notes
  • re coveralls: required is only
    script:
    perl Makefile.PL && make && cover -test -report coveralls
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Also for slide 69: since you are overwriting the install action you have to add the default behavior, that is if your project has dependencies apart from Devel::Cover::Report::Coveralls:

    install:
    cpanm –quiet –installdeps –notest . && cpanm –quiet –notest \
    Devel::Cover::Report::Coveralls
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Slide 69: To avoid prove being listed in the report I had to change the options to exclude prove like so:

    PERL5OPT=-MDevel::Cover=”-coverage,statement,branch,condition,path,subroutine+ignore=prove” prove -lrsv t
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
8,451
On SlideShare
0
From Embeds
0
Number of Embeds
5,178
Actions
Shares
0
Downloads
30
Comments
3
Likes
8
Embeds 0
No embeds

No notes for slide

Github, Travis-CI and Perl

  1. 1. Github, Travis­CI & Perl Dave Cross dave@perlhacks.com @davorg
  2. 2. Github is Awesome
  3. 3. Github is Awesome Because
  4. 4. Github is Awesome Because ● Git
  5. 5. Github is Awesome Because ● Git ● Social coding
  6. 6. Github is Awesome Because ● Git ● Social coding ● Free
  7. 7. Github is Awesome Because ● Git ● Social coding ● Free ● Octocat
  8. 8. Github is Awesome Because API
  9. 9. APIs are Awesome APIs allow you to  add cool features to  Github
  10. 10. APIs are Awesome APIs allow other  people to add cool  features to Github
  11. 11. APIs are Awesome APIs allow other  people to add cool  features to Github
  12. 12. APIs are Awesome APIs allow whole  ecosystem of cool  new toys
  13. 13. Continuous Integration
  14. 14. Continuous Integration ● Source code control is awesome
  15. 15. Continuous Integration ● Source code control is awesome ● Units tests are awesome
  16. 16. Continuous Integration ● Source code control is awesome ● Units tests are awesome ● Continuous integration is running  unit tests whenever you commit code
  17. 17. Continuous Integration ● Source code control is awesome ● Units tests are awesome ● Continuous integration is running  unit tests whenever you commit code ● Which is awesome
  18. 18. Travis­CI is Awesome
  19. 19. Travis­CI is Awesome ● Travis­CI monitors your Github projects
  20. 20. Travis­CI is Awesome ● Travis­CI monitors your Github projects ● Watches for commits
  21. 21. Travis­CI is Awesome ● Travis­CI monitors your Github projects ● Watches for commits ● Runs unit tests
  22. 22. Travis­CI is Awesome ● Travis­CI monitors your Github projects ● Watches for commits ● Runs unit tests ● Reports success or failure
  23. 23. Travis­CI is Awesome ● Travis­CI monitors your Github projects ● Watches for commits ● Runs unit tests ● Reports success or failure ● Which is awesome
  24. 24. Travis­CI & Perl ● Easy to enable Travis­CI for Perl projects
  25. 25. Travis­CI & Perl ● Easy to enable Travis­CI for Perl projects ● Just add a file to your repos
  26. 26. Travis­CI & Perl ● Easy to enable Travis­CI for Perl projects ● Just add a file to your repos ● .travis.yml
  27. 27. Travis­CI & Perl ● Easy to enable Travis­CI for Perl projects ● Just add a file to your repos ● .travis.yml ● Sign up with Travis
  28. 28. 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
  29. 29. .travis.yml language: perl perl:   ­ "5.18"   ­ "5.16"   ­ "5.14"
  30. 30. (Sidebar) ● No Perl 5.20 support yet ● Planned but not implemented ● There is a workaround ● See http://mgnm.at/travis520
  31. 31. Sign Up With Travis­CI
  32. 32. Sign Up With Travis­CI ● http://travis­ci.org/
  33. 33. Sign Up With Travis­CI ● http://travis­ci.org/ ● Sign in with your Github account
  34. 34. Sign Up With Travis­CI
  35. 35. Sign Up With Travis­CI
  36. 36. Integrating Continuously ● Now you're set up
  37. 37. Integrating Continuously ● Now you're set up ● Commit a change to your repository
  38. 38. Integrating Continuously ● Now you're set up ● Commit a change to your repository ● And wait
  39. 39. Integrating Continuously ● Now you're set up ● Commit a change to your repository ● And wait ● ...
  40. 40. Build Results
  41. 41. Build Results
  42. 42. Build Results
  43. 43. Build Results
  44. 44. Build Results
  45. 45. Build Results
  46. 46. Badges
  47. 47. Badges
  48. 48. Badges
  49. 49. Badges
  50. 50. More Complex Stuff ● That's all very easy
  51. 51. More Complex Stuff ● That's all very easy ● Not all code is that simple
  52. 52. More Complex Stuff ● That's all very easy ● Not all code is that simple ● Can we do more?
  53. 53. More Complex Stuff ● That's all very easy ● Not all code is that simple ● Can we do more? ● Rhetorical question
  54. 54. Example: Adding Database ● A database is a common requirement
  55. 55. Example: Adding Database ● A database is a common requirement ● Include schema in repo
  56. 56. Example: Adding Database ● A database is a common requirement ● Include schema in repo ● Include data in repo
  57. 57. Example: Adding Database ● A database is a common requirement ● Include schema in repo ● Include data in repo ● Load database before testing
  58. 58. 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)
  59. 59. Example: Adding Database before_script: - mysql -e 'create database my_db;' - mysql -D my_db < db/load_db.sql
  60. 60. Example: Connecting to Database ● Travis­CI sets up a database user
  61. 61. Example: Connecting to Database ● Travis­CI sets up a database user ● Called “travis”
  62. 62. Example: Connecting to Database ● Travis­CI sets up a database user ● Called “travis” ● No password
  63. 63. Example: Connecting to Database ● Travis­CI sets up a database user ● Called “travis” ● No password ● Use env variables
  64. 64. Example: Connecting to Database ● Travis­CI sets up a database user ● Called “travis” ● No password ● Use env variables ● “env” (in .travis.yml)
  65. 65. Example: Connecting to Database env: MYAPP_DB_SERVER=localhost MYAPP_DB_NAME=my_db MYAPP_DB_USER=travis MYAPP_DB_PASS=''
  66. 66. Example: Test Coverage ● Automatically run test coverage
  67. 67. Example: Test Coverage ● Automatically run test coverage ● http://coveralls.io/
  68. 68. Example: Test Coverage ● Automatically run test coverage ● http://coveralls.io/ ● Add to .travis.yml
  69. 69. .travis.yml install:   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
  70. 70. See also ● http://mgnm.at/travis520
  71. 71. Example: Test Coverage
  72. 72. Example: Test Coverage
  73. 73. Example: Test Coverage
  74. 74. More and More ● Many more things are possible
  75. 75. More and More ● Many more things are possible ● Barely scratching the surface
  76. 76. More and More ● Many more things are possible ● Barely scratching the surface ● See http://docs.travis­ci.com/
  77. 77. 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
  78. 78. Summary
  79. 79. Summary ● Github is awesome
  80. 80. Summary ● Github is awesome ● Unit tests are awesome
  81. 81. Summary ● Github is awesome ● Unit tests are awesome ● Continuous integration is awesome
  82. 82. Summary ● Github is awesome ● Unit tests are awesome ● Continuous integration is awesome ● Travis­CI is awesome
  83. 83. Summarised Summary
  84. 84. Summarised Summary ● APIs are awesome
  85. 85. Summarised Summary ● APIs are awesome ● Other people are awesome
  86. 86. Questions?
  87. 87. Thank You Dave Cross dave@perlhacks.com @davorg

×