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

Add code-coverage-tools package to compare code coverage on the PR build. #22452

Merged
merged 85 commits into from
Oct 4, 2024

Conversation

jatgarg
Copy link
Contributor

@jatgarg jatgarg commented Sep 9, 2024

Description

AB#14170

Add code-coverage-tools package to compare code coverage on the PR build.
1.) Before running coverage comparison, code coverage plugin identifies the baseline build for the PR.
2.) Once the baseline build is identified, we download the build artifacts corresponding to the Code Coverage Report_<Build_Number> artifact name for this build
3.) We then collect the code coverage stats for the PR build and then make the comparison with the baseline.
4.) If the code coverage diff (branch coverage) is more than a percentage point change, then we fail the build for the PR. We also fail the build in case the code coverage for the newly added package is less than 50%.
5.) We post the comment on the PR specifying the code coverage change if any for each package which is modified.

We needed this separate module as we need specifics to do the code coverage comparison like the baseline with which we need to make the comparison and then what we need to compare and then after comparison what comment and in what format we want to report it.

Sample Comment:

code coverage

@jatgarg jatgarg self-assigned this Sep 9, 2024
@jatgarg jatgarg marked this pull request as draft September 9, 2024 22:08
@github-actions github-actions bot added area: build Build related issues area: loader Loader related issues dependencies Pull requests that update a dependency file base: main PRs targeted against main branch labels Sep 9, 2024
@github-actions github-actions bot added the public api change Changes to a public API label Sep 10, 2024
@github-actions github-actions bot removed the area: loader Loader related issues label Sep 10, 2024
@github-actions github-actions bot removed the dependencies Pull requests that update a dependency file label Sep 10, 2024
@jatgarg jatgarg marked this pull request as ready for review September 10, 2024 22:50
@jatgarg jatgarg changed the title (Testing: Not for review): Test package to compare code coverage Add code-coverage-tools package to compare code coverage on the PR build. Sep 10, 2024
jatgarg and others added 9 commits September 30, 2024 11:42
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
…eStats.ts

Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
@Josmithr
Copy link
Contributor

Josmithr commented Oct 1, 2024

Nit: it would probably be good to call out in the PR description why we needed to create our own coverage infrastructure, rather than using an off-the-shelf solution.

Copy link
Member

@tylerbutler tylerbutler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor issues overall. Thanks for working through all the feedback!

build-tools/packages/build-cli/docs/codeCoverageDetails.md Outdated Show resolved Hide resolved
build-tools/packages/build-cli/docs/codeCoverageDetails.md Outdated Show resolved Hide resolved
build-tools/packages/build-cli/docs/codeCoverageDetails.md Outdated Show resolved Hide resolved
build-tools/packages/build-cli/docs/codeCoverageDetails.md Outdated Show resolved Hide resolved
logger?.verbose(`Found baseline build with id: ${baselineBuild.id}`);

return {
build: { ...baselineBuild, id: baselineBuild.id },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker, but I am still a bit confused here. if baselineBuild.id === undefined, then you throw earlier, so baselineBuild.id must be a defined value by the time you get to this line. So what is this code changing in the data? It seems like it's just setting the id property to itself, which should be a no-op.

build-tools/packages/build-cli/src/library/githubRest.ts Outdated Show resolved Hide resolved
jatgarg and others added 7 commits October 3, 2024 16:16
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
Co-authored-by: Tyler Butler <tyler@tylerbutler.com>
@jatgarg jatgarg merged commit ad35a7c into microsoft:main Oct 4, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build Build related issues base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants