Skip to content

DiDoHH/Cake.Codecov

 
 

Repository files navigation

Cake.Codecov

All Contributors AppVeyor branch NuGet Gitter Codecov SonarCloud Quality Gate

A Cake addin that extends Cake with the ability to use Codecov (.NET Edition).

Table of Contents

Usage

In order to use this addin, add to your Cake script

#tool nuget:?package=Codecov
#addin nuget:?package=Cake.Codecov

Then use one of the following snippets to upload your coverage report to Codecov.

NOTE: Starting for codecov version 1.6.0 globbing patterns are also supported for file paths.

Task("Upload-Coverage")
    .Does(() =>
{
    // Upload a coverage report.
    Codecov("coverage.xml");
});
Task("Upload-Coverage")
    .Does(() =>
{
    // Upload coverage reports.
    Codecov(new[] { "coverage1.xml", "coverage2.xml" });
});
Task("Upload-Coverage")
    .Does(() =>
{
    // Upload a coverage report by providing the Codecov upload token.
    Codecov("coverage.xml", "00000000-0000-0000-0000-000000000000");
});
Task("Upload-Coverage")
    .Does(() =>
{
    // Upload coverage reports by providing the Codecov upload token.
    Codecov(new[] { "coverage1.xml", "coverage2.xml" }, "00000000-0000-0000-0000-000000000000");
});
Task("Upload-Coverage")
    .Does(() =>
{
    // Upload a coverage report using the CodecovSettings.
    Codecov(new CodecovSettings {
        Files = new[] { "coverage.xml" },
        Token = "00000000-0000-0000-0000-000000000000",
        Flags = "ut"
    });
});

Documentation

Documentation for the addin can be found on the Cake Website.

Codecov Tips

  1. The codecov-exe uploader defined in #tool nuget:?package=Codecov currently supports Windows, OSX and Linux builds. (_Note: There also the Codecov.Tool utility)
  2. CI Services like AppVeyor and Travis CI do not require a Codecov upload token. Any other provider would need one to be specified on the command line or through an Environment variable called CODECOV_TOKEN. See all supported CI providers in the codecov-exe documentation
  3. Using Codecov with TeamCity MAY require configuration. Please refer to the codecov-exe documentation.

Questions

Feel free to open an issue or ask a question in GitHub Discussions under the Extension Q&A category, and by tagging us: @larzw and/or @AdmiringWorm.

Known Issues

  • Coverage report upload fails when using gitversion (or other tools that change the appveyor build version) Workaround: Add the following in your Upload Coverage task (only needed if gitversion is run on the same call as the uploading of coverage reports in appveyor.yml)

    Task("Upload-Coverage")
        .Does(() =>
    {
        // The logic may differ from what you actually need.
        // This way is for the use with GitVersion.
        // Basically, the buildVersion format needs to be exactly the
        // same as the build version shown on appveyor when the build is done.
        var buildVersion = string.Format("{0}.build.{1}",
            variableThatStores_GitVersion_FullSemVer,
            BuildSystem.AppVeyor.Environment.Build.Number
        );
        var settings = new CodecovSettings {
            Files = new[] { "coverage.xml" },
            EnvironmentVariables = new Dictionary<string,string> { { "APPVEYOR_BUILD_VERSION", buildVersion } }
        };
        Codecov(settings);
    });

Contributors

Thanks goes to these wonderful people (emoji key):


Larz White

🚧

Kim J. Nordmo

🚧

Gary Ewan Park

👀 🤔

Vishal Bishnoi

💻

Pascal Berger

🤔

Toni Wenzel

🤔

jericho

🤔

Sean Fausett

💻

C. Augusto Proiete

📖 🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

Packages

No packages published

Languages

  • C# 98.8%
  • Other 1.2%