Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #29 from dreispt/better-travis
Browse files Browse the repository at this point in the history
Add self tests; use Odoo official repos
  • Loading branch information
bwrsandman committed Jul 18, 2014
2 parents 8a93a20 + 19ebaef commit 0e1ae06
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 48 deletions.
31 changes: 31 additions & 0 deletions .travis.yml
@@ -0,0 +1,31 @@
# WARNING:
# Do not use this file as a template for you repository TravisCI configuration
# Instead use the files under the "/sample_files" directory for that purpose.

language: python

python:
- "2.7"

virtualenv:
system_site_packages: true

env:
- VERSION="master"
- VERSION="8.0"
- VERSION="7.0"
- VERSION="6.1"
# - VERSION="6.0" # Test script not ready for v6.0

install:
#- git clone https://github.com/OCA/maintainer-quality-tools.git $HOME/maintainer-quality-tools
- cp -r ../maintainer-quality-tools/ $HOME # for maintainer-quality-tools self tests only
- export PATH=$HOME/maintainer-quality-tools/travis:$PATH
- travis_install_nightly $VERSION

script:
- travis_run_flake8
- travis_run_tests ${VERSION}

after_success:
coveralls
23 changes: 2 additions & 21 deletions README.md
Expand Up @@ -6,27 +6,8 @@ The goal is to provide helpers to ensure the quality of Odoo addons.
Sample travis configuration file (for version 7.0)
--------------------------------------------------

Put this in your project's `.travis.yml`:

language: python
python:
- "2.7"

virtualenv:
system_site_packages: true

install:
- git clone https://github.com/OCA/maintainer-quality-tools.git $HOME/maintainer-quality-tools
- export PATH=$HOME/maintainer-quality-tools/travis:$PATH
- travis_install_nightly 7.0
- pip install coveralls flake8

script:
- travis_run_flake8
- travis_run_tests 7.0

after_success:
coveralls
To setup the TravisCI continuous integration for your project, just copy the
content of the `/sample_files` to your project’s root directory.

If your project depends on other OCA/Github repositories simply add the following under `before_install` section:

Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions travis/travis.yml.sample → sample_files/.travis.yml
Expand Up @@ -5,15 +5,18 @@ python:
virtualenv:
system_site_packages: true

env:
- VERSION="8.0"

install:
- git clone https://github.com/OCA/maintainer-quality-tools.git $HOME/maintainer-quality-tools
- export PATH=$HOME/maintainer-quality-tools/travis:$PATH
- travis_install_nightly 7.0
- pip install coveralls flake8
- travis_install_nightly $VERSION
- $HOME/maintainer-quality-tools/travis/travis_install_nightly ${VERSION}

script:
- travis_run_flake8
- travis_run_tests 7.0
- travis_run_tests ${VERSION}

after_success:
coveralls
2 changes: 2 additions & 0 deletions test_module/__init__.py
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
# none
6 changes: 6 additions & 0 deletions test_module/__openerp__.py
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
{
'name': 'Empty module for tests',
'version': '1.0',
'depends': ['base'],
}
4 changes: 2 additions & 2 deletions travis/check_installable
Expand Up @@ -4,14 +4,14 @@ import sys
import os
module_path = sys.argv[1]

if module_path.endswith('_unported'):
if '__unported__' in module_path or not os.path.isdir(module_path):
sys.exit(1)
for name in ['__openerp__.py', '__odoo__.py', '__terp__.py']:
file_name = os.path.join(module_path, name)
if os.path.isfile(file_name):
with open(file_name) as fobj:
metadata = eval(fobj.read())
if metadata.get('installable'):
if metadata.get('installable', True):
sys.exit(0)
else:
sys.exit(1)
Expand Down
35 changes: 35 additions & 0 deletions travis/requirements.txt
@@ -0,0 +1,35 @@
http://download.gna.org/pychart/PyChart-1.39.tar.gz
babel >= 1.0
decorator
docutils
feedparser
gdata
gevent
psycogreen
Jinja2
#lxml - installed using apt-get
mako
mock
passlib
pillow
psutil
psycopg2 >= 2.2
pydot
pyparsing < 2
pyPdf
pyserial
python-dateutil < 2
# python-ldap
python-openid
pytz
pyusb >= 1.0.0b1
pyyaml
qrcode
reportlab
requests
simplejson
unittest2
vatnumber
vobject
werkzeug
xlwt
14 changes: 8 additions & 6 deletions travis/travis_install_nightly
@@ -1,9 +1,11 @@
#!/bin/sh

VERSION=$1
# Install the nightly version of OpenERP
sudo apt-get install -qq graphviz # needed?
sudo pip install QUnitSuite # web unit tests fail without this
wget http://nightly.openerp.com/${VERSION}/nightly/deb/openerp_${VERSION}-latest-1_all.deb
sudo dpkg -i openerp_${VERSION}-latest-1_all.deb || sudo apt-get -f install
ODOO_URL="https://github.com/odoo/odoo/archive/$1.tar.gz"
echo "Installing Odoo ${ODOO_URL}"
wget -O odoo.tar.gz ${ODOO_URL}
tar -xf odoo.tar.gz -C ../

sudo apt-get install python-lxml # because pip installation is slooow

pip install QUnitSuite flake8 coveralls
pip install -r $HOME/maintainer-quality-tools/travis/requirements.txt
37 changes: 21 additions & 16 deletions travis/travis_run_tests
Expand Up @@ -10,21 +10,18 @@ version=$1
shift 1

case ${version} in
7.0)
options="--test-enable"
install_options=""
;;
6.1)
options=""
install_options="--test-disable"
;;
*)
options=""
options="--test-enable"
install_options=""
;;
esac

addons_path=/usr/share/pyshared/openerp/addons
server_path="../odoo-$version"
addons_path="$server_path/addons"

for repo in "$@" $TRAVIS_BUILD_DIR;
do
Expand Down Expand Up @@ -58,25 +55,33 @@ then
exit 0
fi

psql -c "create database ${database} with owner openerp;" -U postgres
createdb ${database}
# setup the base module without running the tests
echo
echo setting up the database
/usr/bin/openerp-server --db_user=openerp --db_password=admin -d ${database} --addons-path=${addons_path} ${install_options} --stop-after-init -i ${tested_addons}
$server_path/openerp-server -d ${database} --addons-path=${addons_path} ${install_options} --stop-after-init -i ${tested_addons}

command="/usr/bin/openerp-server --db_user=openerp --db_password=admin -d ${database} ${options} \
command="$server_path/openerp-server -d ${database} ${options} \
--stop-after-init --log-level test \
--addons-path=${addons_path} \
-i ${tested_addons}"

echo
echo ${command}
coverage run $command | tee stdout.log

if $(grep -v mail stdout.log | egrep -q "(At least one test failed when loading the modules.|ERROR ${database})")
then
exit 1
else
exit 0
fi
case ${version} in
5.0|6.0|6.1|7.0)
coverage run $command | tee stdout.log

if $(grep -v mail stdout.log | egrep -q "(At least one test failed when loading the modules.|ERROR ${database})")
then
exit 1
else
exit 0
fi
;;
*)
coverage run $command
exit $?
;;
esac

0 comments on commit 0e1ae06

Please sign in to comment.