Continuous Integration - TeraLogics/TotalBriecall GitHub Wiki
Test Tools
The NodeJS community has several tools for unit testing, performance testing, and integration testing.
Unit/Integration Tests
We chose Mocha for our unit and integration testing. Mocha is open source, regularly updated, and designed to work well for asynchronous testing which is great for JavaScript applications.
Continuous Integration
Since this is a public repository, the results are also public and available at: https://travis-ci.org/TeraLogics/TotalBriecall
Travis CI is an externally hosted CI system that integrates very well with open and private GitHub projects as well with our code coverage utilities and with Heroku. We chose Travis CI for its integration points, easy to use interface and reporting mechanisms. Since Travis CI is open source it can be hosted internally with the appropriate resources.
Set Up
Setting up Travis CI was really easy. All we needed to do was to sign in with our GitHub account, Sync our repositories, and turn on integration for our repository. We also added a .travis.yml
file to our code repository and added a few instructions to it to tell Travis CI what to do.
Configuration
Our custom .travis.yml
file is configured to tell Travis CI:
- What version(s) of NodeJS we wanted to test against
- What our additional testing dependencies are
- Our Heroku configuration
- Slack configuration
We provided our Heroku information so that once our build passed, test results could be passed on so an automated deployment decision could be made by Heroku based on the passing score of our tests. As long as all of our unit tests pass, Heroku will go ahead and deploy our code to the live running instances.
Additionally, we included JSHint in the CI process such that failure to conform to the standards defined in our JSHint configuration would also cause a build to fail.
We also decided to integrate Slack, which our team uses for communication, so that the team gets notified when a build passes or fails.
Lastly, our build process also includes generation of a code coverage report and submission of that report to Coveralls. See below for more details.
Results
Travis CI keeps track of our build history and provides views into the build process and the test results so we know exactly what tests or build processes failed, so we can take corrective action.
It also generates a badge image that shows whether or not the build is passing or errored. This is tagged directly at the top of the README.md
Code Coverage
Istanbul
Istanbul is an open-source code coverage utility that works hand-in-hand with Mocha to generate code coverage based on unit tests.
It generates a file (.lcov
) that is a global format for coverage results and can be imported into many different tools for analysis. Istanbul can also generate an HTML report, but we use the .lcov
file and submit it to Coveralls because their interface is public, is easier to use, and provides additional functionality.
Coveralls
Since this is a public repository, the results are also public and available at: https://coveralls.io/r/TeraLogics/TotalBriecall
Much like Travis CI, Coveralls is an externally hosted code coverage tool that also integrates very well with open and private GitHub projects. It is not open source, but is open for public use. We use this tool not because it is necessary, but because it provides additional functionality to the coverage reports that Istanbul provides.
Coveralls provides a better web visualization of our coverage statistics, coverage history, and the ability to look at multiple repository branches for coverage (if reported). It provides overall coverage statistics for the entire project and generates a badge image that shows our final code coverage for the project. This is tagged directly at the top of the README.md
This is the second to last part of our CI build process. As long as all of our tests pass, and Istanbul completes successfully, the results are posted to Coveralls.
Code Climate
Since this is a public repository, the results are also public and available at: https://codeclimate.com/github/TeraLogics/TotalBriecall
Code Climate is another add-on utility (which is not open source but is available for public use) that we use to generate a score of the overall health of the code. It takes into consideration the code coverage, language style, security issues, and overall quality of the code. It identifies known pitfalls in languages and security, and provides visibility into the places in the code base that contain potential issues. It also points out places where code is duplicated, could be simplified, is syntactically incorrect, or is just plain wrong. It tracks these items over time and creates a quality score for them on a file by file basis. This is tagged directly at the top of the README.md
Dependency Management
David
Since this is a public repository, the results are also public and available at: https://david-dm.org/TeraLogics/TotalBriecall
David is a dependency manager. It allows our team to visually identify when NodeJS package dependencies are out of date. We use this as an informational point in order to keep up to date with the latest feature/security releases for the dependencies we use. This is tagged directly at the top of the README.md