Skip to content
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

Consider allowing property to add to file filters for code coverage #37416

Closed
heaths opened this issue Jul 5, 2023 · 9 comments · Fixed by #38722
Closed

Consider allowing property to add to file filters for code coverage #37416

heaths opened this issue Jul 5, 2023 · 9 comments · Fixed by #38722
Labels
EngSys This issue is impacting the engineering system. MQ This issue is part of a "milestone of quality" initiative. test-enhancement
Milestone

Comments

@heaths
Copy link
Member

heaths commented Jul 5, 2023

https://github.com/Azure/azure-sdk-for-net/blob/2cfa587f85f734fc7da3573a7349b5f642e73e44/eng/CodeCoverage.targets#L63C90-L63C90

We could modify the line above to also take filters from test projects that would ignore shared code, which a lot of libraries use. Ideally, this shared code is tested elsewhere e.g., Azure.Core.TestFramework does this, so every project that uses it doesn't have to.

@heaths heaths added EngSys This issue is impacting the engineering system. test-enhancement labels Jul 5, 2023
@heaths heaths added this to the 2023-08 milestone Jul 5, 2023
@heaths
Copy link
Member Author

heaths commented Jul 5, 2023

We might consider an item group of file patterns to exclude - easier to get right - and then use item transforms to inject the proper syntax. That said, I worry that a broad filter might explode the command line to the point it's excessive and errs. /cc @hallipr

@jsquire jsquire modified the milestones: 2023-08, Backlog Aug 16, 2023
@heaths heaths added the MQ This issue is part of a "milestone of quality" initiative. label Sep 11, 2023
@heaths
Copy link
Member Author

heaths commented Sep 11, 2023

@annelo-msft is this still necessary when all of the shared code is moved to public types in Azure.Core?

@annelo-msft
Copy link
Member

@heaths, I'm not sure I understand the question -- can you help me understand what the lines of code referenced in the issue are doing and why they're needed today? That will help me extrapolate to a later time when public types are in Azure.Core to say whether it would be needed in that world. Thanks!

@heaths
Copy link
Member Author

heaths commented Sep 11, 2023

Shared code - code we linked in .csproj files - wasn't getting covered if not tested by individual SDKs' test assemblies. But since you have been moving shared code to publicly exposed code in Azure.Core, there should be little - if any - shared code anymore, right?

@annelo-msft
Copy link
Member

annelo-msft commented Sep 11, 2023

Ah, cool, thanks for the explanation!

I expect it will take a while to move everything to public types, but you are correct that this wouldn't be needed once we get to that point. It's also true that once we have #38304, we would expect to have good test coverage of any remaining shared types in Core, so that coverage shouldn't be needed in the service library projects themselves.

An alternative to consider to get higher code coverage numbers for shared source files in service libraries might be to include the test files for the shared source files in the projects that reference them, but that could get messy from a dependency perspective, so probably not something we'd want to pursue.

@heaths
Copy link
Member Author

heaths commented Sep 11, 2023

so that coverage shouldn't be needed in the service library projects themselves.
...
An alternative to consider to get higher code coverage numbers for shared source files in service libraries

That's exactly the problem: lack of actual tests for shared files, and we don't want to put [ExcludeFromCodeCoverage] on shared files' types because we want to make sure they are tested as part of Azure.Core. Pavel and I did consider including tests, but - as you noted - gets messy very quickly.

The biggest issue is that most of code coverage configuration is through files (XML, if that gives you some idea of age), so a "one size fits all" approach for any given track 2 SDK in a monorepo doesn't really work i.e., the configuration isn't scalable.

One thing that might help is just to exclude any types with a namespace prefix of Azure.Core, except for Azure.Core itself, but even that gets hard to populate. This is why the reports are filtered as much as we can instead of code coverage numbers that AzDO sees modified to exclude sources. /cc @pallavit who was asking about this as well.

@annelo-msft
Copy link
Member

Is the top-level goal of this effort to improve code coverage numbers for all libraries, and this piece with shared source is one of the items standing in the way of that goal?

@heaths
Copy link
Member Author

heaths commented Sep 12, 2023

That's correct. A naive - or perhaps temporary (but maybe more work than it's worth) - is to [ExcludeFromCodeCoverage] all the shared source but test it in Azure.Core.Tests anyway. It wouldn't hurt CC numbers for any SDK including Azure.Core. But let's discuss it and how it relates to MQ offline. This naive approach could work but, again, may not be worth it.

heaths added a commit to heaths/azure-sdk-for-net that referenced this issue Sep 14, 2023
@heaths
Copy link
Member Author

heaths commented Sep 14, 2023

We discussed this in our team today and because shared source is most of the legitimate reason to exclude files and because those should be migrated to publicly exported types in 6-12 months as needed, do not feel additional investment is necessary at this time. We also feel code coverage metrics can be misleading, as briefly described in the associated PR to update our CONTRIBUTING.md with our "soft policy" on this.

heaths added a commit that referenced this issue Sep 18, 2023
* Add policy statement about code coverage

Resolves #37416

* Resolve PR feedback
yaotongms pushed a commit to yaotongms/azure-sdk-for-net that referenced this issue Oct 12, 2023
* Add policy statement about code coverage

Resolves Azure#37416

* Resolve PR feedback
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
EngSys This issue is impacting the engineering system. MQ This issue is part of a "milestone of quality" initiative. test-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants