How it works...

When you enable 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 of the PR 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 you can find at https://github.com/OCA/maintainer-quality-tools (we removed the transifex configuration used to manage module translations). Here's an explanation of the customized sections in the file:

  • addons: This has nothing to do with Odoo addon 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: It 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 the maintainer-quality-tools in the build environment and call the travis_install_nightly utility, which will set up Odoo in Travis.
  • script: This section calls the travis_run_tests from the maintainer-quality-tools. This is the script in charge of checking the environment variables form 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 the 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
18.222.196.175