Migrating Coveralls Report from Travis-CI to GitHub Actions

Migrating Coveralls Report from Travis-CI to GitHub Actions

Disclaimer: This is a very specific problem. It is relevant only if you had a travis ci pipeline setup for your GitHub repository and using nyc and coveralls, and thinking of migrating to GitHub actions.

The Past

I followed this setup guide: Integrating with coveralls.io

The Problem

I thought of migrating the build pipeline to GitHub Actions, but was hindered by this error:

> js-big-decimal@1.3.3 coverage /home/runner/work/js-big-decimal/js-big-decimal
> nyc report --reporter=text-lcov | coveralls


/home/runner/work/js-big-decimal/js-big-decimal/node_modules/coveralls/bin/coveralls.js:19
      throw err;
      ^
Bad response: 422 {"message":"Couldn't find a repository matching this job.","error":true}
(Use `node --trace-uncaught ...` to show where the exception was thrown)
npm ERR! code ELIFECYCLE

Now time to reveal the solution:

The Solution:

  • Edit the coverage script in package.json to use the default reporter of lcov
    "coverage": nyc report --reporter=lcov
    
  • Modify the pipeline to use the official Coveralls stage

        - name: Test
          run: |
            npm run ci-test
            npm run coverage
    
        - name: Publish to coveralls.io
          uses: coverallsapp/github-action@v1.1.2
          with:
            github-token: ${{ github.token }}
    

If you need a working example, check JS Big Decimal

Did you find this article valuable?

Support Niladri Roy by becoming a sponsor. Any amount is appreciated!