Skip to content

Adding code coverage to tests in workflow #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 25, 2025

Conversation

aaronpowell
Copy link
Contributor

Fixes #11

Motivation and Context

This is using the pattern from the Aspire Community Toolkit which will publish coverage results to the GitHub Actions summary, as well as a comment on the PR (if the job was run by someone with permissions to write comments).

Also added the GitHubActionsTestLogger so that it writes a nicer log out to the run.

How Has This Been Tested?

Yes

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

aaronpowell and others added 2 commits March 24, 2025 10:42
This is using the pattern from the Aspire Community Toolkit which will publish coverage results to the GitHub Actions summary, as well as a comment on the PR (if the job was run by someone with permissions to write comments).

Also added the GitHubActionsTestLogger so that it writes a nicer log out to the run.

Fixes modelcontextprotocol#11
@aaronpowell
Copy link
Contributor Author

aaronpowell commented Mar 24, 2025

I'm unsure why the test failed, but it printed coverage results! https://github.com/modelcontextprotocol/csharp-sdk/actions/runs/14026518268#summary-39266074135

image

@eiriktsarpalis
Copy link
Contributor

Maybe I'm missing something, but I couldn't find a code coverage report in the test results.

@aaronpowell
Copy link
Contributor Author

Maybe I'm missing something, but I couldn't find a code coverage report in the test results.

Code coverage is generated from the new code-coverage.yml, which is called by the publish-coverage job, but since CI keeps failing on one of the matrix jobs it's not run that.

I also included the test output summaries (and incorrectly called it coverage above 🤣) as that's useful to see.

@eiriktsarpalis
Copy link
Contributor

Thanks. It would seem there is an issue with the current glob pattern:

image

@aaronpowell
Copy link
Contributor Author

Hmm, I'll have to check why those files aren't included

@aaronpowell
Copy link
Contributor Author

Turns out that I'd forgotten to include a dependency on coverlet.collector after all 🤣

I really should document the workflow/steps properly rather than trying to do this from memory each time...

@aaronpowell
Copy link
Contributor Author

aaronpowell commented Mar 25, 2025

Tada! 🎉

image

https://github.com/modelcontextprotocol/csharp-sdk/actions/runs/14058550436?pr=75#summary-39363760728

CI jobs triggered by contributors should also get a comment on the PR of coverage.

@eiriktsarpalis
Copy link
Contributor

@stephentoub is this ready to merge or are you planning to push more changes?

@eiriktsarpalis eiriktsarpalis merged commit 1f8ebee into modelcontextprotocol:main Mar 25, 2025
8 checks passed
@aaronpowell aaronpowell deleted the code-coverage branch March 25, 2025 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup code coverage
3 participants