Contributing
Source:CONTRIBUTING.md
This document outlines a rough approach for local setup and contributing to this project.
Local setup
To work with this project locally you will need Git and R installed locally. It is also recommended that you install Docker and VSCode to enable you to utilise the devcontainer setup or edit the code directly via GitHub Codespaces.
Alternatively, you can use conda to manage your R packages; see instructions below.
If you’re unfamiliar with using git
why not check out the fantastic Carpentries introductory course.
To get working on this project you will need the devtools
package which you can install with the following R command:
# Install devtools from CRAN
install.packages("devtools")
Using conda
You can install R and manage your packages and dependencies using conda (see the open source Miniforge installer here). The file conda-dev-env.yml
contains a minimal list of packages (including devtools
), allowing you to create an environment with conda:
Once you’ve agreed to the installation, you can activate your environment called np-r-env
:
You will now be able to launch an interactive R session from the terminal, or run .R
files with the Rscript
command.
Development workflow
When working locally you should use the following workflow to help develop the code:
- Create a fork of the GitHub repository to create your own personal copy of this repository to which you can push changes to
- Locally clone your fork so that you can start working on it
- Open an R session
- Load
devtools
with:R library(devtools)
- Make a change to the package files
- Test this in your R session by running
load_all()
to load the package (check here for any errors) - Check your changes pass tests by running
test()
- If your package passes the tests and you’ve updated the appropriate documentation you should now run
check()
locally to make sure all appropriate roxygen2 files are created/update and any functions you’ve now tagged with @export are exported to NAMESPACE - Commit all the changes from the
check()
run and push these to GitHub - Open a pull request against the
main
branch from your development branch. This will trigger a GitHub action that also runs the equivalent ofcheck()
to make sure you didn’t miss anything and ensure the package still works against different versions of R. - Once the checks pass on the pull request your changes can be accepted by the maintainer.