Skip to content

Implementing code coverage #208

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 53 commits into from
Jul 10, 2025
Merged

Implementing code coverage #208

merged 53 commits into from
Jul 10, 2025

Conversation

suhaani-agarwal
Copy link
Contributor

@suhaani-agarwal suhaani-agarwal commented Jun 19, 2025

Implementing code coverage for animint2 using codecov. (using covr for R side and Chrome devtools coverage + v8-to-istanbul for JS side)

Closes #122

@suhaani-agarwal
Copy link
Contributor Author

suhaani-agarwal commented Jun 25, 2025

This PR adds R and JavaScript code coverage tracking:

  • For compiler tests we use the covr package to track which R code lines are executed during testing. The coverage data is automatically uploaded to Codecov after successful test runs via covr::codecov().
  • For renderer tests, we leverage Chrome DevTools Protocol through Chromote to capture precise JS coverage data as the animint.js code executes in the browser. The raw coverage data is converted to Istanbul/lcov format using puppeteer-to-istanbul and uploaded to Codecov

Once request for installation of Codecov is approved for animint, and the CODECOV_TOKEN is added to GitHub Secrets, the coverage tracking will be uploaded to Codecov . we can further refine the coverage reporting and verify if this works once codecov token is uploaded.

Copy link

codecov bot commented Jul 1, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@suhaani-agarwal
Copy link
Contributor Author

Update : the R side code coverage is correctly being uploaded to codecov for every commit. see here : https://app.codecov.io/gh/animint/animint2/tree/coverage/R
Here we can also look at the R code being covered by the tests and the parts of R code not being covered by tests. for example : https://app.codecov.io/gh/animint/animint2/blob/coverage/R%2Ffacet-.r

About the JS code coverage, I have managed to collect the JS code coverage from chrome devtools while the renderer tests run. This coverage is currently being stored in a raw json format. to upload it to codecov, we require it to be in a different (istanbul) format. For this, I am currently facing difficulty downloading the node package pupeteer-to-istanbul (responsible for converting raw json js coverage data to codecov accepted format) correctly in Github Actions workflow. As soon as I am able to convert it correctly, The js coverage will also be uploaded to codecov along with the R coverage.

@suhaani-agarwal suhaani-agarwal marked this pull request as ready for review July 8, 2025 19:25
@suhaani-agarwal
Copy link
Contributor Author

code coverage is now being uploaded for both JS and R codes to codecov . see here : https://app.codecov.io/github/animint/animint2/commit/1747fde5868452bd9651a8637022bb3b75b84836/tree?dropdown=coverage

@tdhock
Copy link
Collaborator

tdhock commented Jul 8, 2025

this is really excellent work, thanks!
I see files under vendor are used to compute code coverage for this report https://app.codecov.io/github/animint/animint2/commit/1747fde5868452bd9651a8637022bb3b75b84836/tree/inst/htmljs?dropdown=coverage

Can you please tell codecov to ignore the files under vendor/ ?

@tdhock
Copy link
Collaborator

tdhock commented Jul 8, 2025

there is an issue with the CRAN test suite, which currently has a WARNING but is not failing (green build).
Can you please fix the github action so that the current code results in a failed CRAN test suite? (red build because of warning below)

* checking DESCRIPTION meta-information ... NOTE
Package listed in more than one of Depends, Imports, Suggests, Enhances:
  ‘covr’
A package should be listed in only one of these fields.
* checking top-level files ... NOTE
Non-standard files/directories found at top level:
  ‘package-lock.json’ ‘package.json’ ‘v8-to-istanbul.js’
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking code files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking loading without being on the library search path ... OK
* checking whether startup messages can be suppressed ... OK
* checking use of S3 registration ... OK
* checking dependencies in R code ... NOTE
Namespace in Imports field not imported from: ‘covr’
  All declared Imports should be used.
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... [19s/15s] OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd line widths ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking contents of ‘data’ directory ... OK
* checking data for non-ASCII characters ... OK
* checking LazyData ... OK
* checking data for ASCII and uncompressed saves ... OK
* checking examples ... [48s/44s] OK
* checking examples with --run-donttest ... [93s/83s] OK
* checking for unstated dependencies in ‘tests’ ... WARNING
Warning: 'library' or 'require' call not declared from: ‘jsonlite’
* checking tests ...
  Running ‘namespace.R’
  Running ‘testthat.R’ [36s/30s]
 [38s/32s] OK

@suhaani-agarwal
Copy link
Contributor Author

there is an issue with the CRAN test suite, which currently has a WARNING but is not failing (green build). Can you please fix the github action so that the current code results in a failed CRAN test suite? (red build because of warning below)

That warning was appearing earlier because of a file I had created for a previous implementation, which is no longer needed. I've removed that file now, and the warning no longer appears.

@tdhock
Copy link
Collaborator

tdhock commented Jul 8, 2025

In CRAN test suite I still see

* checking top-level files ... NOTE
Non-standard file/directory found at top level:
  ‘v8-to-istanbul.js’

the fix is to add this file to Rbuildignore. But before doing that, can you please modify the CI so that the CRAN test suite will fail when there is a WARNING or NOTE?
so then we should get a red/failed build next.
and then you can push the fix after that?

@suhaani-agarwal
Copy link
Contributor Author

In CRAN test suite I still see

* checking top-level files ... NOTE
Non-standard file/directory found at top level:
  ‘v8-to-istanbul.js’

the fix is to add this file to Rbuildignore. But before doing that, can you please modify the CI so that the CRAN test suite will fail when there is a WARNING or NOTE? so then we should get a red/failed build next. and then you can push the fix after that?

thanks for the clarification! I have now modified the CI so that the CRAN test suite will fail when there is a WARNING or NOTE: https://github.com/animint/animint2/actions/runs/16154589438/job/45594000311
and after that I fixed the error by adding the file v8-to-istanbul.js to Rbuildignore.

@suhaani-agarwal
Copy link
Contributor Author

update : currently, one of the test files, test-renderer2-PredictedPeaks is causing chromote timeout issue which isnt getting resolved even after increasing the chromote timeout. So I am trying to figure out why that is happening.

@suhaani-agarwal
Copy link
Contributor Author

suhaani-agarwal commented Jul 10, 2025

The original test-renderer2-PredictedPeaks was a little heavy and was slowing down the browser, especially after we added JavaScript coverage collection through Chrome DevTools. I’ve now refactored the test to make it lighter by:

  • Subsetting the dataset to a minimal size,
  • Removing unnecessary visualization components not relevant to the test logic.

With this update, both JavaScript and R code coverage are now correctly collected and uploaded to Codecov:
https://app.codecov.io/github/animint/animint2/commit/9952830992b8e8f216647c4e174665234cd46bee/tree?dropdown=coverage

Comment on lines 162 to 173
showSelected=c("dotID", "chrom"),
clickSelects="peak.name",
size=11,
data=PredictedPeaks$chromCounts)+
scale_y_discrete("cell type", drop=FALSE),
chroms=ggplot()+
theme_bw()+
theme_animint(width=1500, height=330)+
scale_y_discrete("chromosome", drop=FALSE)+
scale_x_continuous("position on chromosome (mega bases)")+
geom_text(aes(0, chrom, label=paste0(peaks, "_")),
clickSelects="chrom",
showSelected="dotID",
hjust=1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

it is unusual that these were not used at all in the test.
Instead of deleting them, I would think it should be preferable to include them in the test somehow.

It seems that there are several significant changes to this test, and it is not clear which one is responsible for the fix, can you please clarify?

  • deleting two plots
  • making smaller data set
  • modifying timeout

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Timeout has not been modified ( I have again set it to 120 as it was before)
  • making smaller data set is the change responsible for the fix.
  • I have now restored the 2 deleted plots and also included them in a small test case. Is that okay?

@suhaani-agarwal
Copy link
Contributor Author

Apologies for any confusion caused. While updating NEWS.md, I accidentally ran git rebase instead of merging master into coverage, which resulted in some duplicate commits and a rewritten history due to a force push.

I've verified that all intended changes ,including test improvements and coverage additions are intact. The branch is now clean, up-to-date with master, and ready for review.
Please let me know if any further changes are needed

@tdhock
Copy link
Collaborator

tdhock commented Jul 10, 2025

Can you please provide a link to a more recent coverage report which shows R/JS code coverage? (but not vendor files)

Like this: https://app.codecov.io/github/animint/animint2/commit/1747fde5868452bd9651a8637022bb3b75b84836/tree/inst/htmljs?dropdown=coverage

For some reason I can't find a newer report on codecov. What do I need to click on?

@suhaani-agarwal
Copy link
Contributor Author

suhaani-agarwal commented Jul 10, 2025

Can you please provide a link to a more recent coverage report which shows R/JS code coverage? (but not vendor files)

Like this: https://app.codecov.io/github/animint/animint2/commit/1747fde5868452bd9651a8637022bb3b75b84836/tree/inst/htmljs?dropdown=coverage

coverage report for the most recent commit : https://app.codecov.io/github/animint/animint2/commit/1065d7f9c082536e4db9e0e90dc7abd0717883ba/tree

For some reason I can't find a newer report on codecov. What do I need to click on?

So the link to the homepage for the coverage reports for animint2 is : https://app.codecov.io/github/animint/animint2
here, after selecting the branch "coverage" , you will be able to access the most recent coverage report for different files (after scrolling down) : https://app.codecov.io/github/animint/animint2/tree/coverage

In order to view the coverage reports for different commits, you can click on "commits" in the navbar and then click on the commit you want to view the coverage report for.

Shall I make a video demonstrating the usage of this dashboard?

@tdhock
Copy link
Collaborator

tdhock commented Jul 10, 2025

ok, I had to click File Explorer.
Thanks!
Video would be nice for your blog.
Great work!!

@tdhock tdhock merged commit 33f5a80 into master Jul 10, 2025
5 checks passed
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.

code coverage on github actions
2 participants