Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Conversation

@anirudhacharya
Copy link
Member

@anirudhacharya anirudhacharya commented Aug 29, 2018

Description

Track test coverage metrics for R-package using covr package.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Comments

@marcoabreu
Copy link
Contributor

Thank you! Could you elaborate how and when this script is getting executed? I guess we have to modify our test pipeline and add it there

@marcoabreu
Copy link
Contributor

@anirudhacharya anirudhacharya requested a review from szha as a code owner August 29, 2018 22:49
@marcoabreu
Copy link
Contributor

Thanks. Did you enable the proper error propagation?

@anirudhacharya
Copy link
Member Author

@marcoabreu the error propagation issue is due to a bug in the test framework that we are using, testthat. I am trying to find a workaround for that

@marcoabreu
Copy link
Contributor

Great, thank you.

Do you want to fix that in a separate PR?

@anirudhacharya
Copy link
Member Author

yes, I will make that another PR.


MXNET_HOME=${PWD}
cd ${MXNET_HOME}/R-package
Rscript -e 'covr::codecov()'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this script is obsolete now

@anirudhacharya anirudhacharya force-pushed the testCov branch 5 times, most recently from 828e35b to 37578be Compare August 31, 2018 05:53
@anirudhacharya
Copy link
Member Author

test coverage report - http://jenkins.mxnet-ci.amazon-ml.com/blue/rest/organizations/jenkins/pipelines/incubator-mxnet/branches/PR-12391/runs/6/nodes/133/steps/154/log/?start=0

@marcoabreu The CI run generates the report but it is not able to upload the reports to codecov due to the following error -

Please provide the repository token to upload reports via `-t :repository-token`

@marcoabreu
Copy link
Contributor

Do you see the publish_test_coverage call in our Jenkinsfile? It's important that this call submits the report to codecov. Here, it seems like the package is trying to upload the report itself. Is it possible to just output the test coverage report into the workdir? Codecov will then automatically pick it up

@anirudhacharya
Copy link
Member Author

@marcoabreu
Copy link
Contributor

Have a look at the source here: https://github.com/r-lib/covr/blob/master/R/codecov.R

They automatically try to upload to codecov. We don't want that. Instead, we want this output to be redirected to a file. Our method then automatically picks that file up and uploads it properly.

Basically what I would recommend is to take that function and replicate it to redirect the output to a file. Can you try that?

The reason we don't want this implicit upload is because of high availability. We took some measures because codecov is not really reliable in terms of availability of their default endpoints.

@anirudhacharya anirudhacharya force-pushed the testCov branch 2 times, most recently from f3b2a06 to 6985af6 Compare September 11, 2018 04:33
@anirudhacharya
Copy link
Member Author

@marcoabreu please review.

@marcoabreu
Copy link
Contributor

@anirudhacharya
Copy link
Member Author

but as you suggested, i am writing it to a json file in the local directory.

@marcoabreu
Copy link
Contributor

Can you upload the content of that file on pastebin or gist? I'd love to have a closer look to investigate

@anirudhacharya
Copy link
Member Author

Makefile Outdated
rpkgtest:
Rscript -e "require(testthat);res<-test_dir('R-package/tests/testthat');if(!testthat:::all_passed(res)){stop('Test failures', call. = FALSE)}"
Rscript -e 'require(testthat);res<-test_dir("R-package/tests/testthat");if(!testthat:::all_passed(res)){stop("Test failures", call. = FALSE)}'
Rscript -e 'res<-covr:::package_coverage("R-package");fileConn<-file("r-package_coverage.json");writeLines(RJSONIO:::toJSON(res), fileConn);close(fileConn)'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this functions output does not really match the format codecov expects. Have a look at this line:

https://github.com/r-lib/covr/blob/master/R/codecov.R#L164

Copy link
Contributor

@marcoabreu marcoabreu left a comment

Choose a reason for hiding this comment

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

@marcoabreu
Copy link
Contributor

Thanks a lot! It seems like codecov is having trouble associating the proper commit hash of a PR with the report, but that's a separate problem. This PR has successfully added test coverage for R, great job!

@marcoabreu marcoabreu merged commit f387df4 into apache:master Sep 13, 2018
@anirudhacharya anirudhacharya deleted the testCov branch September 13, 2018 17:26
@anirudhacharya
Copy link
Member Author

@marcoabreu Thanks! Though the current coverage report is not completely accurate, it shows 0% coverage for certain files which have unit tests for them. Will check why covr misses the coverage in those files.

anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request Sep 19, 2018
* get test coverage metrics for r-package

* update makefile to include test coverage, and fix test failures

* write to json file
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants