Carlos Ble

Carlos Ble

I am a professional software developer, I solve problems.

I also teach and mentor developers to build better software.

Developing software since 2001.

Can I help you?

  • Do you need high quality tailor-made software?
  • Need training on TDD, clean code or refactoring?
  • Do you need a technical consultant?
  • May I pair with you to write better code?

Events

Upcoming training courses:

  1. TDD - [en Español] - 6 y 7 Octubre
    Gran Canaria
  2. TDD - [in English] - October 20, 21 & 22
    London, UK
  3. TDD - [en Español] - 29, 30 y 31 de Octubre.
    Madrid, Spain

Conferences:

  1. I'll be at the Agile Testing Days 2014
  2. I'll be at the London Test Gathering Workshops.

Continuous Integration on Python

Hudson and Cruise Control are very popular among Java/.Net developers but when it comes to Python, ...
Hudson also seems to work on python!. Open source tools for Python continuous integration:

However, I just want a simple way to check out the code and run the tests. A Bash script and the Cron daemon is a good solution so far (last script update on Wed 25 Feb 2008):

  1.  
  2. cd /root/siga/src
  3. export DJANGO_SETTINGS_MODULE="settings"
  4. export PYTHONPATH=":/root/siga/src"
  5.  
  6. mailTo="developer1@sample.com, developer2@whatever.com"
  7.  
  8. analize_tests_output ()
  9. {
  10. grep "FAIL:" $1 > failResults
  11. if [[ $? == 0 ]]
  12. then
  13. echo "There are tests failing!:" > tmp
  14. cat failResults >> tmp
  15. mail -s "Continuous integration report" $mailTo < tmp
  16. fi
  17. grep "ERROR:" $1 > errorResults
  18. if [[ $? == 0 ]]
  19. then
  20. echo "There are tests with errors!:" > tmp
  21. cat failResults >> tmp
  22. mail -s "Continuous integration report" $mailTo < tmp
  23. return
  24. fi
  25.  
  26. rm -rf $1
  27. }
  28.  
  29. are_there_changes()
  30. {
  31. svn up > tmpsvnup
  32.  
  33. grep "^U" tmpsvnup 2> /dev/null > /dev/null
  34. if [[ $? == 0 ]]
  35. then
  36. return 1
  37. fi
  38.  
  39. grep "^A" tmpsvnup 2> /dev/null > /dev/null
  40. if [[ $? == 0 ]]
  41. then
  42. return 1
  43. fi
  44.  
  45. grep "^D" tmpsvnup 2> /dev/null > /dev/null
  46. if [[ $? == 0 ]]
  47. then
  48. return 1
  49. fi
  50.  
  51. grep "^G" tmpsvnup 2> /dev/null > /dev/null
  52. if [[ $? == 0 ]]
  53. then
  54. return 1
  55. fi
  56.  
  57. return 0
  58. }
  59.  
  60. are_there_changes
  61. changes=$?
  62. if [[ $changes == 1 ]] # there are svn changes
  63. then
  64. /etc/init.d/wservices stop
  65. sleep 2
  66. /etc/init.d/wservices start
  67.  
  68. # running unittests tests and mocker tests
  69. python tests/runTests.py >> tmptest1 2>> tmptest1
  70. analize_tests_output tmptest1
  71. # runnin django tests
  72. python manage.py test core 2>> tmptest2 >> tmptest2
  73. analize_tests_output tmptest2
  74. fi
  75.  

The cron file:

  1.  
  2. # m h dom mon dow command
  3. 49 * * * * root /root/siga/src/integrator.sh
  4.  
Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.
  • Dreur

    nice
    Thanks for the little script.

    Will use it for a php project.

  • http://carlosble.com Carlos Ble

    Hi Dreur, glad you find it useful. We’ve made some minor changes to the script:
    # running unittests tests and mocker tests
    python tests/runTests.py >> tmptest1 2>> tmptest1
    analize_tests_output tmptest1
    # runnin django tests
    python manage.py test core 2>> tmptest2 >> tmptest2
    analize_tests_output tmptest2

    Instead of using > we’re using >> to append because some errors were left out.
    Cheers :-)

  • http://carlosble.com Carlos Ble

    There is anocher change, “rm -rf $i” at the end of analize_tests_output.

  • http://www.belweder.velvet.beskidy.pl/ Hermiona

    hi, your site is discount. I do many thanks for get the job done

  • Kris

    Thanks for the script. I used your script as a starting point to make an automated build/test procedure for our software project. I was looking for something simpler than the continuous integration projects and this worked perfectly.