Share
Embed
Django & Continuous integration
Как быстро и просто внедрить проект на Django непрерывную интеграцию.
Moscow Python Meetup PRO
July 09, 2012
Transcript
25 slides
-
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 -
Зачем нужен CI • сокращается время интеграции • защита от
регрессий • всегда работающая копия проекта • качественная оценка кода (lint) -
• Free, MIT Licence • java -‐jar jenkins.war • WebGUI
• Богатый функционал out of the box • Более 400 плагинов -
django-jenkins • простая установка и настройка • тестируем только свои
приложения • поддержка анализаторов кода: • coverage • pylint, pep8, pyflakes • csslint, jslint и др. -
Тестовый проект 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 -
Тесты 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'... -
Настраиваем django-jenkins pip install django-‐jenkins coverage pylint INSTALLED_APPS = (
... 'meetup', 'django_jenkins', ... ) PROJECT_APPS = ( 'meetup', ) -
Тесты 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'... -
Ставим Jenkins и плагины Устанавливаем плагины Violations и Cobertura для
Jenkins $ wget http://mirrors.jenkins-‐ci.org/war/latest/ jenkins.war $ java -‐jar jenkins.war -
Shining Panda plug-in • поддержка python, virtualenv, buildout, tox при
настройке заданий -
Shining Panda • Jenkins SaaS • Python, Java • Linux,
Windows • MySQL, PostgreSQL, MongoDB • 12$ в месяц (48c в час) • https://www.shiningpanda.com/ -
Travis CI • CI SaaS • Free for opensource •
Python, Javascript, Ruby, etc (11 языков) • Интеграция с гитхабом • Тестирование pull-реквестов (beta) • http://travis-ci.org/ -
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 -
Полезные ссылочки • http://martinfowler.com/articles/continuousIntegration.html • http://jenkins-ci.org/ • https://github.com/kmmbvnr/django-jenkins • https://github.com/coagulant/jenkins_demo
• https://www.shiningpanda.com/ • http://travis-ci.org/