eSaude Continuous Integration
Note: We are currently only using the described continuous integration process for our POC product.

In order to promote good code quality, every time code is merged into master, we run through the continuous integration pipeline pictured above.

We use Codacy for code quality analysis and a dashboard showing a summary of the current quality of our code can be found at https://www.codacy.com/app/esaude/esaude-esaude-emr-poc/dashboard.

We use Travis CI as our continuous integration tool and the latest build result can always be found at https://travis-ci.org/esaude/esaude-emr-poc.

The build will fail if any of the steps in the CI pipeline fails.

Quality Phase

Codacy code quality analysis is invoked when a PR is created or when a commit is made directly to master. Right now we are checking our code against the default Codacy code patterns, but when the community establishes its own coding style guidelines, we should configure Codacy to check against these guidelines.

Prepare Phase

Once Travis detects that new code has been merged into the master branch, it begins the build and deploy pipeline execution by spinning up a Docker container, installing the specified version of node, and running:

npm install -g bower grunt-cli codacy-coverage coveralls
npm install
bower install --force-latest

This sets up the required eSaude EMR POC development environment.

Test Phase

Once the development environment has been prepared, the tests are run by executing:

grunt test

Package Phase

This phase builds a deployable packaged archive from the latest code in master:

grunt build:package

The result is a zip file called esaude-emr-poc-master.zip.

Deploy Phase

The deploy phase has two steps and will only be invoked when code is merged into master and not when a PR is created. 

First, the distributable archive is uploaded to Bintray, our binary hosting service using Travis’ Bintray deployment provider. This is necessary in order to make the latest build from master publicly available so that we can use it to build the Docker containers in our dev test environment.

Next we do a clean deploy of the latest build using the dev server deploy script. This script first destroys any existing containers and images on the dev test server, then creates the POC Docker image from scratch using the Docker and docker-compose scripts. As part of this process, the latest platform docker images are pulled from Bintray.

Finally, we initialise the database container with a clean database, then start up all the containers. The system running with the latest code will be available at http://dev.esaude.org after two or three minutes once the containers start up.

Report Phase

This phase reports the code coverage metrics to Codacy and Coveralls by running:

cat coverage/**/lcov.info | codacy-coverage
cat coverage/**/lcov.info | coveralls