Integrate .NET Core, AppVeyor, OpenCover and Codecov

As a developer, I need to take a good rest at night. In my line of work the only way to achieve it is using an integrated workflow pipeline, aka Source Code Management (SCM), Continuous Integration (CI) and Continuous Deployment (CD) with some tools in the middle.

For my new pet project (I will write about it once reach a good maturity level) I use this set of tools/technologies:

OpenCover is the most used framework to generate code coverage reports for .NET framework. It’s open source and well maintain (updated to work with .NET Core).

Codecov is a commercial project from Steve Peak, free for open source projects, and has powerful visualisations from the code coverage report. Can be used with a tonne of frameworks/languages, using OpenCover report format for the .NET framework. Is my preferred platform, since Steve has a great customer service support.

My integrated workflow pipeline is:

  1. Commit to GitHub project
  2. AppVeyor is configured to be triggered when a new commit is done
  3. AppVeyor builds the solution, run the tests and generate the code coverage report
  4. AppVeyor publish the code coverage report to CodeCov

To manage the AppVeyor actions during the build and tests phases I just develop a PowerShell script to run the generate the code coverage report using OpenCover for the projects/classes under test:

The script instructions do the following:

  1. Set as parameters the general configurations, such as locations of the code coverage report, OpenCover and .NET, using the AppVeyor environment variables to set the correct path
  2. Set the parameters to test the WebAPplicationAssemblyStorage project, excluding a dummy class, running the OpenCover console using the parameters
  3. Set the parameters to test the WebApp project, excluding all the bootstrapping code generated by the .NET framework when a web app is created, running the OpenCover console using the parameters
  4. Copy the code coverage report to the AppVeyor artifacts
  5. Set the Python version in the PATH environment variable, installing Python Package Manager and Codecov script, and uploading the code coverage report to Codecov

The Powershell is integrated into appveyor.yml file, integrated into the project solution. The script runs in the ‘test_script’ step.

NOTE: at the time that you are reading this post the script can be different. If that is the case please leave a comment and I will update the Gist. 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s