R Development Collaboration Guide
Rules
The following set of rules should be followed by all contributors and checked by all reviewers of the OSPS R projects.
Each change made to the codebase should have a clear purpose and exist in an isolated context. 1.1 Each change should be related to an issue created on the project's repository. 1.2 Each change should be made in a separate branch. 1.3 Each change should be proposed through a pull request.
Each change or addition to the code should be documented and controlled. 2.1 Each change that affects user experience or outputs be reflected in the documentation. If documentation is not present, then it should be created. 2.2 Each change should be tested. If new cases emerge, then they should be tested, even if some tests are already present. If no tests are present, then they should be created.
Each change should be easily reviewable, understandable and traceable. 3.1 Each change that affects user experience or outputs should have a corresponding entry in the
NEWS
file. 3.2 Each change should be associated with a pull request which scope is limited to the change itself.Each change must respect the coding style of the project. 4.1 Each change must respect the coding style of the project as defined in the R Coding Standards. 4.2 Each change must be processed by the
{styler}
package before being proposed.Each change should be reviewed before being merged. 5.1 Each change should be reviewed by at least one other contributor through its associated pull request. 5.2 Each change should be functional and comply with these rules before its associated pull request is set as "ready for review". If not ready or reviewer inputs are needed, the pull request should be marked as "draft".
Recommended Workflows
Changing Code
The recommended workflow for contributing to the OSPS R projects heavily relies on the {usethis}
package and it family of function pr_*()
.
Prerequisites
This workflow implies that:
R and R Studio are installed,
A GitHub account is available and setup to work within RStudio,
The
{usethis}
package is installed,A local clone (from original repository or from a fork) has been created.
Workflow
Initialize
usethis::pr_init("my-branch-name")
.Apply changes in codebase and save with commits
Once changes are implemented, make a pull request with
usethis::pr_push()
.Review of the pull request may ask for additional changes, proceed with commits then use the
pr_push()
command again.Finally, the reviewer merge the pull request, the local branch can be cleaned away using
usethis::pr_finish()
Useful tips
At any moment you can get back to main branch using
usethis::pr_pause()
If you need to make some changes on a branch that already has a pull request open, you can retrieve it locally with
usethis::pr_fetch(XX)
withXX
being the pull request's numerical identifier.
Releasing Versions
This section is only applicable for the following repositories:
{ospsuite}
{ospsuite.parameteridentification}
Prerequisites
This workflow implies that:
R and R Studio are installed,
A GitHub account is available and setup to work within RStudio,
The
{usethis}
package is installed,A local clone (from original repository or from a fork) has been created.
The current branch is the default branch (usually
main
).
Workflow
The recommended workflow for contributing to the OSPS R projects heavily relies on the {usethis}
package.
Pick the new version number using the following command (refer to this to make the right choice).
Create a dedicated branch
Automatically update version number and DESCRIPTION file and accept to commit all the changes
Push the local branch and create the pull request by running:
Once the pull request is approved and merged, the local branch can be cleaned away using
usethis::pr_finish()
.Make sure the current branch is the default branch (usually
main
) and create the release on github using:usethis::use_github_release()
.Download the built packages from the GitHub action run from the PR merge and attach them to the release.
Now, the package must be put back to development mode. For this, we will create another Pull Request in which we will repeat the previous steps but with a different version number. The development version number ends with a
.9000
so that both dev and users can easily distinguish between the two. Pick "dev" after executing the following code:
Repeat steps 2 to 5.
Last updated