Skip to content

Conversation

Adityanr
Copy link
Contributor

@Adityanr Adityanr commented Oct 8, 2021

build.cake modified to generate coverage badge in README.md using opencover and reportgenerator
Closes #30

@Adityanr Adityanr marked this pull request as draft October 8, 2021 23:46
@Adityanr Adityanr marked this pull request as ready for review October 8, 2021 23:48
@Adityanr Adityanr marked this pull request as draft October 11, 2021 20:10
- Skip opencover unit test report generation for PR and local builds
- Use coveralls for coverage badge generation
@Adityanr
Copy link
Contributor Author

Adityanr commented Oct 11, 2021

Hi @Marusyk
Can you please register grok.NET repository at https://coveralls.io ?

I have done the following:

  • Registered my local fork of grok.Net at coverall.io (https://coveralls.io/github/Adityanr/grok.net) and used that to generate a sample coverage badge at README.md (Coverage Status)
  • Added environment variable, COVERALLS_REPO_TOKEN, which is used to authorize opencover test result uploads to coveralls for coverage badge generation.

The following needs to be done now:

  1. Register grok.net repository (https://github.com/Marusyk/grok.net) at coveralls.
  2. Click on details next to the newly registered repository name.
  3. Fetch the generated or supposedly generated badge URL from the bottom section as follows:
    markdown_url_coverage
  4. Send me the coverage badge markdown URL obtained above so I can update README.md with the new badge URL and set the PR ready for review.
  5. Add the Coveralls repo token obtained as an environment variable (COVERALLS_REPO_TOKEN) in the CI post merge build for main branch.
  6. Update github workflows with Upload-Coverage-Report as target instead of Run-Unit-Tests

Thank you!

@Adityanr Adityanr marked this pull request as ready for review October 12, 2021 15:34
@Marusyk
Copy link
Owner

Marusyk commented Oct 13, 2021

Hi @Adityanr
wow, thank you very much for this

I've added the token as a Repository secret.
Here is markdown

[![Coverage Status](https://coveralls.io/repos/github/Marusyk/grok.net/badge.svg?branch=main)](https://coveralls.io/github/Marusyk/grok.net?branch=main)

@Adityanr
Copy link
Contributor Author

Hi @Adityanr wow, thank you very much for this

I've added the token as a Repository secret. Here is markdown

[![Coverage Status](https://coveralls.io/repos/github/Marusyk/grok.net/badge.svg?branch=main)](https://coveralls.io/github/Marusyk/grok.net?branch=main)

Hi @Marusyk
I have update README.md with the new badge for main branch! It will display new coverage after main branch CI pipeline build is run. All it needs now is github workflow update. I don't seem to have a push access for that. Can you please make that change if this PR gets merged?

@Marusyk Marusyk merged commit 789a779 into Marusyk:main Oct 13, 2021
@Marusyk
Copy link
Owner

Marusyk commented Oct 13, 2021

@Adityanr Could you please check
Windows.yml
image

@Adityanr
Copy link
Contributor Author

sure, lemme check @Marusyk

@Adityanr
Copy link
Contributor Author

Adityanr commented Oct 13, 2021

Hi, @Marusyk
The build steps are working fine locally. Is the windows build server running as a container? If so maybe the user does not have appropriate permissions to register the opencover profiler. The following modification to Run-Unit-Tests target can be made for this to work:

Task("Run-Unit-Tests")
    .IsDependentOn("Build")
    .Does(() =>
{
    var projectFile = Directory("./src/Grok.Net.Tests") + File("Grok.Net.Tests.csproj");

    if(!BuildSystem.IsLocalBuild)
    {
        DotNetCoreTest(System.IO.Path.GetFullPath(projectFile), new DotNetCoreTestSettings()
        {
            Configuration = configuration
        });
    }
    else
    {
        OpenCover(tool => {
                tool.DotNetCoreTest(
                System.IO.Path.GetFullPath(projectFile),
                new DotNetCoreTestSettings()
                {
                    Configuration = configuration
                }
                );
            },
            testResultFile, new OpenCoverSettings() {
                Filters = { "-[*xunit*]*", "-[GrokNetTests.UnitTests]*", "+[*]*" },
                Register = "User"
            }
        );
    }
});

Added the Register = "User" for OpenCoverSettings.
Should i raise another PR for the same?
local_execution

@Marusyk
Copy link
Owner

Marusyk commented Oct 13, 2021

Should i raise another PR for the same?
Yes please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate code coverage badge
2 participants