A Cake addin that extends Cake with the ability to use the official Codecov CLI that have been repackaged as a NuGet package named CodecovUploader.
In order to use this addin, add to your Cake script
#tool nuget:?package=CodecovUploader
#addin nuget:?package=Cake.Codecov // Any versions before 1.1.0 is not guaranteed to work anymore.
Then use one of the following snippets to upload your coverage report to Codecov.
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 for the addin can be found on the Cake Website.
- While CI Service like GitHub Action, these workflows are likely to hit a rate limit on Codecov. As such it is recommended to always pass in a repository or global token when one is available.
- Do not set NonZero to
true
when running without a Codecov token.
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.
-
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); });
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 π π€ |
Nils Andresen π» |
This project follows the all-contributors specification. Contributions of any kind welcome!