One of the powerful features of Odoo is the third party add-ons available in Odoo app store. These Add-ons provides many enterprise edition features and lot of other customized features to Odoo users. But ensuring the quality of each Add-on is necessary to secure the Odoo from external threats like a data breach or system failures. Quality tools help us to ensure the quality of the add-ons. Odoo Community Association (OCA) has a Maintainer Quality Tools (MQT) project that helps the user to ensure the quality of Odoo Add-ons.
This Project uses Coveralls code coverage reporting service and Travis CI continuous integration service. The services are free for open-source projects and paid for proprietary projects. We need a GitHub repository to use this service, an easily integrate the OCA maintainer-quality-tools with the repository
To develop Add-ons that meet the quality measures, the following basic guideline can be followed.
1. Avoid Messy Code and focus on clean code so that it will helpful for future bug fixing or adding new functionality
2. Always ensure a good coding standard or style guides.
Now let us check, how to use Travis CI and perform the quality checks.
Steps 1: Link Travis CI and GitHub
Go to Travis official page https://www.travis-ci.org/ and then sign using Github account.
Then click on sync repository button to sync repositories with Travis
Step 2: Build Configuration
Next, create a file called “.travis.yml” in the root of your project repository:
- The ‘language’ section is used for specifying the language of the software.
- The ‘python’ section is used for specifying the version or versions of Python to use for testing.
- The ‘install’ section is used for specifying commands to run before testing, such as the installation of dependencies or the compilation of required packages.
- The ‘script’ section is used for specifying the command to test the software. Typically, this command will find all tests in the project and run them. The specified command must exit status code ‘0’ if the test is successful; otherwise, the test will be considered a failure.
Alternatively, we can specify multiple versions of Python and Travis CI, which will test each project version
For advanced build configuration, see the Travis CI documentation on Configuring your build( https://www.docs.travis-ci.com/user/customizing-the-build/ ).
Step 3: Trigger builds
To trigger builds, push the commit that adds “.travis.yml” to the project. The quality test will start automatically on Travis.