-
Notifications
You must be signed in to change notification settings - Fork 9
Contributing to dampack
Make sure the following are installed on your computer:
- R (version >= 3.4) - https://www.r-project.org/
- RStudio: https://www.rstudio.com/products/rstudio/download/
- Git: https://git-scm.com/downloads
- Optional: a graphical user interface for working with Git. I wouldn't recommend the built-in Git tools in RStudio: they are slow and clunky. It's easier to use the terminal within RStudio, if you don't need/want a GUI.
- Sourcetree: https://www.sourcetreeapp.com/
- GitHub Desktop: https://desktop.github.com/
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:
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.
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.
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!
Also, follow the Github flow. So, all together, the package development process is something like:
- create a branch (I usually create a local branch first)
- make a code change, usually including writing new unit tests
- build the package (Ctrl/Cmd + Shift + B)
- test the package (Ctrl/Cmd + Shift + T)
- check the package (Ctrl/Cmd + Shift + E)
- repeat 2-5 until you are satisfied with the change
- push to GitHub - the remote branch on GitHub should have the same name as the local branch
- open a pull request. request comments and reviews as necessary
- wait for Travis CI to run the tests.
- if the Travis build passes, great! otherwise, go back to step 2