Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Django & Continuous integration

Django & Continuous integration

Как быстро и просто внедрить проект на Django непрерывную интеграцию.

Avatar for Moscow Python Meetup

Moscow Python Meetup

July 09, 2012
Tweet

More Decks by Moscow Python Meetup

Other Decks in Technology

Transcript

  1. What is CI? A software development practice where members of

    a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Martin Fowler
  2. Зачем нужен CI • сокращается время интеграции • защита от

    регрессий • всегда работающая копия проекта • качественная оценка кода (lint)
  3. • Free, MIT Licence • java  -­‐jar  jenkins.war • WebGUI

    • Богатый функционал out of the box • Более 400 плагинов
  4. django-jenkins • простая установка и настройка • тестируем только свои

    приложения • поддержка анализаторов кода: • coverage • pylint, pep8, pyflakes • csslint, jslint и др.
  5. Тестовый проект https://github.com/coagulant/jenkins_demo pip  install  django==1.4 django-­‐admin.py  \    

       startproject  jenkins_demo  . django-­‐admin.py  \        startapp  meetup jenkins_demo/        __init__.py        settings.py        urls.py        wsgi.py meetup/        __init__.py        models.py        tests.py        views.py manage.py
  6. Тесты django $  python  manage.py  test Creating  test  database  for

     alias  'default'... .................................................................... .................................................................... .................................................................... .................................................................... .................................................................... ...s................................................................ ........ -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐ -­‐-­‐ Ran  416  tests  in  16.872s OK  (skipped=1) Destroying  test  database  for  alias  'default'...
  7. Настраиваем django-jenkins pip  install  django-­‐jenkins  coverage  pylint INSTALLED_APPS  =  (

           ...        'meetup',        'django_jenkins',        ... ) PROJECT_APPS  =  (        'meetup', )
  8. Тесты django-jenkins $  python  manage.py  jenkins Creating  test  database  for

     alias  'default'... . -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐ Ran  1  test  in  0.004s OK Destroying  test  database  for  alias  'default'...
  9. Ставим Jenkins и плагины Устанавливаем плагины Violations и Cobertura для

    Jenkins $  wget  http://mirrors.jenkins-­‐ci.org/war/latest/ jenkins.war $  java  -­‐jar  jenkins.war
  10. Shining Panda • Jenkins SaaS • Python, Java • Linux,

    Windows • MySQL, PostgreSQL, MongoDB • 12$ в месяц (48c в час) • https://www.shiningpanda.com/
  11. Travis CI • CI SaaS • Free for opensource •

    Python, Javascript, Ruby, etc (11 языков) • Интеграция с гитхабом • Тестирование pull-реквестов (beta) • http://travis-ci.org/
  12. language:  python python:    -­‐  2.6    -­‐  2.7 env:

       -­‐  DJANGO_VERSION=1.3.1    -­‐  DJANGO_VERSION=1.4 install:    -­‐  pip  install  -­‐q  Django==$DJANGO_VERSION      -­‐  pip  install  reqs.txt  -­‐-­‐use-­‐mirrors    -­‐  python  setup.py  -­‐q  install script:  python  runtests.py branches:    only:        -­‐  dev Пример .travis.yml