Skip to content

Steps to Update a package

Suzanne Childress edited this page Feb 1, 2024 · 10 revisions

Suppose you want to fix a bug or add a new feature to your package.

  1. Prepare for making the change.
  • Clone the current code from Github.
  • Install the current commit from Github.
    • devtools::install_github('url')
  • Review the recent Commits to understand recent work.
  • Communicate with the team about changes you will be making.
  • Branch the code from main commit to ensure that the main branch always works.
  1. Test the changes locally before you commit.

Generally, you will be wanting to make a small change to existing code and you want to isolate it to that change before you check anything in.

To do so:

  • Make a test project to build and test the changes as you make them.
  • Make a new R file or new R markdown file. Read in your library.
  • Next copy the parts of the code related to your updates. Begin making changes.
  • Test the change against examples to ensure that the results are as expected.
  • If you add any libraries, remember to add them to the DESCRIPTION FILE.
  • Add any necessary examples or tests in the test frame work.The examples are added in the @examples roxygen at the top of the function definitions.
  • Test are added by adding them to the tests directory using testthat or other similar libraries.
  • Iterate on your documentation and code changes until everything is working as expected.
  • Close your example project. Restart R.
  1. Build the package locally, document, check and test:
  • devtools::build()
  • devtools::document()
  • devtools::check()
  • devtools::test()

Install the package locally. install.packages(path_to_file, repos= NULL, type="source") Restart R.

4.Do local checks and tests.Return to your test project. Rerun only the examples.

Work through any problems that arise when you document and check the package.

If you have a github pages site associated with your package,

  • run pkgdown::build_site_github_pages()
  1. Push your code to Github. Ensure that any associated documentation website updates correctly.

  2. Have a co-worker test the package which is now on a branch before merging the branch to main. Give the co-worker a pull request from the branch to the main branch. devtools::install_github("url/with_Branch_name") The co-worker should run a test of an affected area of the code using the updated library. Ideally they'd make up their own test but that's kind of heavyweight, so you could just have them run your test on their machine. If problems are found, trouble shoot them. If everything is okay, the co-worker should merge the pull request into the main branch.

  3. Alert necessarily people to re-install the package with the new feature or fix.

Clone this wiki locally