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

Collect test coverage for both unit & NixOS integration tests #117

Merged
merged 2 commits into from
Feb 18, 2024

Conversation

elpdt852
Copy link
Collaborator

@elpdt852 elpdt852 commented Feb 17, 2024

Fix #43

As of go 1.20, we can compile go binaries with cover instrumentation to collect coverage for integration tests: https://go.dev/doc/build-cover

Combined with machine.copy_from_vm capability via a shared mount in the NixOS test framework, we can essentially collect Golang test coverage data even when nix-snapshotter is embedded in a systemd service, very cool!

We likely want to use codecov, which is free for open source (cc @gbpdt need approval for pdtpartners/nix-snapshotter). For now, I've added the coverage data to $GITHUB_STEP_SUMMARY.

@elpdt852 elpdt852 added the ok-to-test Runs NixOS tests label Feb 17, 2024
RobbieBuxton
RobbieBuxton previously approved these changes Feb 17, 2024
Copy link
Collaborator

@RobbieBuxton RobbieBuxton left a comment

Choose a reason for hiding this comment

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

Huh, that's really cool. Looks like a great way of doing it!

@elpdt852 elpdt852 force-pushed the feature/test-coverage branch 2 times, most recently from 37966da to fb56221 Compare February 17, 2024 14:42
@elpdt852 elpdt852 force-pushed the feature/test-coverage branch from fb56221 to 47256c8 Compare February 17, 2024 15:02
@elpdt852
Copy link
Collaborator Author

Previously it was generating a coverage report per integration test. Using actions/upload-artifact and actions/download-artifact I was able to copy each integration test coverage report into a single step to merge & produce the final coverage report.

@elpdt852
Copy link
Collaborator Author

Thanks, looks like our current statement-level test coverage is 63.9%.

@elpdt852 elpdt852 merged commit f4ae2be into main Feb 18, 2024
11 checks passed
@elpdt852 elpdt852 deleted the feature/test-coverage branch February 18, 2024 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Runs NixOS tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate and improve code coverage
2 participants