← Back to team overview

openerp-community team mailing list archive

OCA 8.0 Suggestion: use travis-ci.org for testing addons

 

Hello Community.

I have a proposal for submit before we start porting our projects to
8.0.

I suggest we add travis.yml to the root of each addon repository.
That way, we can use the free service of travis-ci.org to do initial
testing of each MP and each commit.

This will greatly reduce the amount of redundant manual testing reviews
have to do (e.g. Fix pep8, the MP fails tests) and gives an output of
these MPs being run on a machine which doesn't actually cost us any
ressource. Looking at the output, we could easily see the warnings in a
log without having to clone and run the tests myself -- a process which
is quite time consuming.

I have included my proposal travis config file template. This is a rough
first draft, it is very possible that it needs tweaking.
It tests on python2.6, python2.7 (possibility to add 3.4 and pypy when
they become supported) with odoo and with ocb. 
 - It will first test pep8 compliance.
   - Use a max line length of 120
   - Ignore error F401 ("imported but unused") in __init__.py files. 
 - It then runs odoo in test mode for each of the modules in the
repository. 
   - There is also a coverage report being run which shows what portion
of the code is covered by tests (a .coveragerc  file is also provided).

This would require pypi versions of both odoo and ocb. An alternative
would be to install these with --allow-external, but I suspect this
would require a lot more initial setup.

------------------
# Config file .travis.yml

language: python

python:
  - "2.7"
  - "2.6"

env:
  - ODOO="odoo"
  - ODOO="ocb"

# command to install dependencies
install: pip install ${ODOO} coveralls flake8

before_script: createdb test

# command to run tests, e.g. python setup.py test
script:
    - git diff -W HEAD^ HEAD | flake8 --diff --max-line-length=120
--filename=__init__.py --ignore=F401
    - git diff -W HEAD^ HEAD | flake8 --diff --max-line-length=120
--exclude=__init__.py 
    - python -m coverage run odoo-server -d test --test-enable
--log-level=test --stop-after-init --init=$(python -c "import os;
print(','.join(filter(lambda x: os.path.isdir(x) and not
x.startswith('.'), os.listdir('.'))))")


after_success:
  coveralls

--------
# Config file .coveragerc

[report]
omit =
    *__init__.py
    odoo/*
    /usr/*

# Regexes for lines to exclude from consideration
exclude_lines =
    # Have to re-enable the standard pragma
    pragma: no cover

    # Don't complain about null context checking
    if context is None:

Attachment: signature.asc
Description: This is a digitally signed message part


Follow ups