How it works...

When you enable the Travis CI on a repository, Travis registers a hook on GitHub. By default, the hook will trigger a Travis CI build for each push to a branch of the repository and for each pull request. Pull requests are built on a temporary merge to ensure that the merged branches pass the tests.

The Travis CI configuration file proposed here is fairly advanced and very close to the one found in the sample_files subdirectory of the maintainer-quality-tools project, which you can find at https://github.com/OCA/maintainer-quality-tools (we removed the transifex configuration that's used to manage module translations). Here's an explanation of the customized sections in the file:

  • addons: This has nothing to do with Odoo add-on modules. It's used to ask Travis to install some Ubuntu packages using distribution packages in the testing environment. This saves us from installing Python packages, such as python-lxml, from source, which takes a lot of time.
  • env: This section defines environment variables and the build matrix. The maintainer quality tools use these environment variables to know what to test, and will run each env line in a separate test run:
    • VERSION: This is the Odoo version to test against.
    • LINT_CHECK: Use 0 for a build with no flake8 or Pylint tests, and 1 otherwise. In the matrix, we set the first build to perform the lint check, as this is fast and we want rapid feedback if the coding standards are not met or if the linter finds errors.
    • TESTS: Use 0 for a build in which the module tests are not run, otherwise use 1.
    • ODOO_REPO: This is the GitHub repository for Odoo to test against when TESTS is 1. In the recipe, we set up a build against both the official https://github.com/odoo/odoo repository and the community backports repository, https://github.com/OCA/OCB. If unset, only the official repository is used.
  • install: This section downloads maintainer-quality-tools in the build environment and calls the travis_install_nightly utility, which will set up Odoo in Travis.
  • script: This section calls travis_run_tests from maintainer-quality-tools. This script is in charge of checking the environment variables from the build matrix and performing the appropriate actions.
  • after_success: After the tests in the script section have run successfully, the travis_after_test_success script is run. In the context of this recipe, this script will check the test coverage of the modules using https://coveralls.io and produce a report in the build.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset