Paralleling Code Coverage using Coveralls and Travis

MicrosoftTeams-image (1)

Hello Builders! So, let’s say you have multiple environments you want to have coverage on, how exactly would you accomplish that? In this entry - you’ll figure out how to do just that and more.

Paralleling Code Coverage

First let’s enable Coveralls for your repo, so if you haven’t done so yet – head over to Coveralls and Auth the Coveralls app to up your GitHub account, and then sync your repos with Coveralls.

Sample .travis.yml

So let’s set our ENV in our .travis.yml file, and include our webhooks, the config I have looks like the following:

sudo: false
language: node_js
node_js:
  - "node"
env:
  global:
    - COVERALLS_PARALLEL=true
jobs:
  include:
    - script: COVERALLS_FLAG_NAME=test-1 make test-coveralls-1
    - script: COVERALLS_FLAG_NAME=test-2 make test-coveralls-2
notifications:
  webhooks: https://coveralls.io/webhook

You’ll see we are running multiple COVERALLS_FLAG_NAME, this is using the Coveralls webhook to parallelize your coverage. If at first you don’t see Coveralls covering your code, you may want to add your env var from Coveralls to Travis CI and name it something like COVERALLS_TOKEN.

Once your checks have ran, you should see seomthing like this:

image

Conclusion

As always, if you have any questions, please email me at montana@travis-ci.com for help.

Happy building!