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

feat(python): produce code coverage from a unit test #404

Merged
merged 6 commits into from
Jan 29, 2025
Merged

Conversation

alexeagle
Copy link
Member

@alexeagle alexeagle commented Jan 25, 2025

Ask Aspect workflows to upload the coverage data.

The codecov GitHub App is installed on this repo.


Changes are visible to end-users: no

Test plan

  • New test cases added

@alexeagle alexeagle requested a review from thesayyn January 25, 2025 02:06
Copy link
Contributor

aspect-workflows bot commented Jan 25, 2025

Test

2 test targets passed

Targets
//oci_python_image/hello_world:test [k8-fastbuild]      7s
//oci_python_image/hello_world:unit_test [k8-fastbuild] 2s

Total test execution time was 9s. 25 tests (92.6%) were fully cached saving 20s.


Format      Lint [.]

@alexeagle alexeagle requested a review from kormide January 29, 2025 21:21
@alexeagle
Copy link
Member Author

Here's what it looks like to visualize the coverage.dat file uploaded to the Buildkite artifacts by this PR
Screenshot 2025-01-29 at 1 22 40 PM

Still not perfect since the absolute path isn't desired here.

Copy link
Member

@thesayyn thesayyn left a comment

Choose a reason for hiding this comment

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

neat

@alexeagle alexeagle merged commit e5d4fa6 into main Jan 29, 2025
5 checks passed
@alexeagle alexeagle deleted the py_coverage branch January 29, 2025 23:56
alexeagle added a commit to aspect-build/rules_py that referenced this pull request Jan 30, 2025
Issue reported here:
aspect-build/bazel-examples#404 (comment)

Now looks like

```
SF:src/__init__.py
DA:1,1
DA:2,1
```

Similar to
https://github.com/bazelbuild/rules_python/blob/466da1d9710289bfb01061b9be7bb124132996e0/python/private/python_bootstrap_template.txt#L336-L346
but ours is a bit more principled since we don't break the abstraction
of what coveragepy happens to do with the paths.


### Changes are visible to end-users: no

### Test plan

- Manual testing; please provide instructions so we can reproduce:
Just `bazel coverage src:test` and inspect the .dat file
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.

2 participants