Skip to content

Contributing to dampack

Caleb Easterly edited this page May 9, 2019 · 6 revisions

Contributing

Getting Set Up

Make sure the following are installed on your computer:

Within R, you'll need to install devtools:

install.packages("devtools")

After that, run the following code:

devtools::install_github("DARTH-git/dampack", dependencies = TRUE)

That should install all of the necessary packages to run dampack and its tests.

There are three important stages in R package development, each of which you should do before changing anything on GitHub:

R Package Workflow

Build

This builds the package and installs it - to the default R library, unless you specify otherwise. If you build the package locally, it will overwrite your installation from Github.

Each time you make a change in your package, you have to rebuild it for the changes to be reflected in the loaded package.

In RStudio, the easiest way to build the package is by clicking the "Install and Restart" button in the Build pane, or by pressing Ctrl + Shift + B (windows) or Cmd + Shift + B (mac).

Some changes to the Build settings can make the process simpler. Click on the "More" drop-down menu in the Build pane, then "Configure Build Tools". Check "Use devtools package functions if available" and "Generate documentation with Roxygen". Then click "Configure" next to the word Roxygen - below "Automatically roxygenize...", check all 3 options. Now, the documentation will be rebuilt every time you build the package, so you don't have to build the documentation separately.

Test

After building the package, you can run all of the unit tests in the package with Ctrl/Cmd + Shift + T. This should identify any installation or computing environment errors.

Check

Another step in CRAN deployment is package checking. CRAN requires that all submitted packages pass a series of tests. To "check" the package, click "Check" or type Ctrl/Cmd + Shift + E.

When making a change, it's important to ensure that your changes don't break anything. So, it's recommended to run each of the three steps above after each major change. If something breaks, fix it!

GitHub Flow and All Together

Also, follow the Github flow. So, all together, the package development process is something like:

  1. create a branch (I usually create a local branch first)
  2. make a code change, usually including writing new unit tests
  3. build the package (Ctrl/Cmd + Shift + B)
  4. test the package (Ctrl/Cmd + Shift + T)
  5. check the package (Ctrl/Cmd + Shift + E)
  6. repeat 2-5 until you are satisfied with the change
  7. push to GitHub - the remote branch on GitHub should have the same name as the local branch
  8. open a pull request. request comments and reviews as necessary
  9. wait for Travis CI to run the tests.
  10. if the Travis build passes, great! otherwise, go back to step 2