How to test package-pull requests/commits locally, before sending to Github?

I have:

  • a bug
  • a fix
  • a fork
  • a local clone of the fork
    So how can I test my modifications locally, before commit it and make a pull request on Github?
    Do I have to compile a new package-version, and 'say' for example:

Your strategy for testing a pull request (PR) can follow the same strategy used to check the original package. The most common would be to:

  1. Reload the package with devtools::install()
    a. You may need to load the package after this step using devtools::load_all(".")
  2. Check the package with devtools::check()
  3. If the package uses a testing suite via {testthat}, step 2 will run the tests for you. Otherwise, you may experiment locally with your bug fix to check the modifications.

Actually I want to test my modifications in a real world application.
So If I understand it right, I don't have to recompile the package (the library).
I should include the library (the package) as normal, after install with devtools?
Do they compile on Github automatically?

Correct. After re-installing the package you just call library(pkg_name) and then test your modifications.

I am not sure what you mean exactly by compile. If you are referring to a new package version (ex: the latest version of devtools) this is not done on Github automatically. If a package is hosted only on Github, you typically download the latest commits when installing a package. If a package is also on CRAN, then the authors submit the new package version to CRAN.

Take a look at this section of R packages for some more information on different package states.

Ah ok, thank you for the info.

So far so good. Test was successful. But then I get this on Github...

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

That message seems to suggest that the connection between your local code and the package is broken. Unfortunately, it is hard for me to point you in the right direction without seeing the error (perhaps you can link to the Github repo?)

I would suggest going through this vignette from the {usethis} package. It outlines a procedure for contributing to packages using PRs. The R package book also has a section on PRs which may help.

It's here:

My guess is, I click on the wrong place.

I try to PR on Github.

Needed a branch... finished.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.