Integrating Travis CI and Codacy in PSLab Repositories
Continuous Integration Testing and Automated Code Review tools are really useful for developing better software, improving code and overall quality of the project. Continuous integration can help catch bugs by running tests automatically and to merge your code with confidence. While working on my GsoC-16 project, my mentors guided and helped me to integrate Travis CI and Codacy in PSLab github repositories. This blog post is all about integrating these tools in my github repos, problems faced, errors occurred and the test results. Travis CI is a hosted continuous integration and deployment system. It is used to build and test software projects hosted on github. There are two versions of it, travis-ci.com for private repositories, and travis-ci.org for public repositories. Read : Getting started with Travis CI Travis is configured with the “.travis.yml” file in your repository to tell Travis CI what to build. Following is the code from '.travis.yml' file in our PSLab repository. This repo contains python communication library for PSLab. language: python python: - "2.6" - "2.7" - "3.2" - "3.3" - "3.4" # - "3.5" # command to install dependencies # install: "pip install -r requirements.txt" # command to run tests script: nosetests With this code everything worked out of the box (except few initial builds which errored because of missing 'requirements.txt' file) and build passed successfuly :) :) Later Mario Behling added integration to FOSSASIA Slack Channel. Slack notifications Travis CI supports notifying Slack channels about build results. On Slack, set up a new Travis CI integration. Select a channel, and you’ll find the details to paste into your '.travis.yml'. Just copy and paste the settings, which already include the proper token and you’re done. The simplest configuration requires your account name and the token. notifications: slack: '<account>:<token>' notifications: slack: fossasia:***tokenishidden**** Import errors in Travis builds of PSLab-apps Repository PSLab-apps repository contains PyQt bases apps for various experiments. The '.travis.yml' file mentioned above gave several module import errors. $ python --version Python 3.2.5 $ pip --version pip 6.0.7 from /home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages (python 3.2) Could not locate requirements.txt. Override the install: key in your .travis.yml to install dependencies. 0.33s$ nosetests E ====================================================================== ERROR: Failure: ImportError (No module named sip) The repo is installable and PSLab was working fine on popular linux distributions without any errors. I was not able to find the reason for build errors. Even after adding proper 'requirements.txt' file, travis builds errored. On exploring the documentation I could figure out the problem. Travis CI Environment uses separate virtualenv instances for each Python version. System Python is not used and should not be relied on. If you need to install Python packages, do it via pip and not apt. If you decide to use apt anyway, note that Python system packages only include Python 2.7 libraries (default python version). This means that the packages installed from the repositories are not available in other virtualenvs even if you use the –system-site-packages option. Therefore I was getting Import module errors. This…
