Skip to content

Session 4 guide

Selin Jessa edited this page May 14, 2020 · 12 revisions

Code working group - Session 4

Agenda

Task

  • In this task, we'll run through the whole contribution workflow again, but this time, we'll be each adding a function that has an external dependency. The idea is to practice the whole branch-change-commit-rebase workflow.
  • Again, we'll then open a PR from our issue branch to develop-private, and ensure our code passes status checks & reviews before integrating it.
  • In terms of choosing what to add, I suggest to start with a very small package where you need just a single function, so for now please avoid: dplyr, tidyverse, tidyr, purrr, ggplot2, magrittr. Instead, some suggestions: something from prcomp, stats, glue, hclust, utils, etc...
  • The package now contains a new dataset, called fibonacci_mat, which is a matrix that you could use to perform some computation

Steps

At this point, we'll generally assume everyone has created a function with tests, and that it is now merged into the codebase (master-private), and the issue closed. If not, you can easily start this task independently from the previous issue!

  1. Open a new issue specifying what you'll be adding -- make sure the package name is in the issue title, so other people can see
  2. Create a new branch
    • First, ensure your local repository is up to date: while on develop-private, pull any changes from GitHub
    • While still on the develop-private branch, create a new branch, corresponding to your new issue
  3. Add your contribution for today's task, by creating a new function which uses a function from an external package available on CRAN. You will need to:
    • Add the package as a dependency in DESCRIPTION
    • Import the desired function with an @importFrom pkg function statement in your function's documentation
    • Document the function
    • Create some unit tests for the function
    • Optional: this time, you may want to explore using the two functions usethis::use_r("myfunction") and usethis::use_test("myfunction") to create the file templates for you!
  4. When you've finished, commit & push your changes, and once Travis status checks pass, open a pull request from your issue branch onto the develop-private branch. In the PR message, add "This closes #XXX" to reference your issue
  5. If anybody has made changes to the develop-private branch in between your commits to your branch, don't forget to rebase regularly onto develop private:
    • Get the latest changes on the develop-private branch: git checkout develop-private then git pull
    • Go back to your issue branch, git checkout issue/XXX
    • Rebase: git rebase develop-private

✨ Keep in mind our workflow from previous sessions - you'll need to...

  • ...follow the steps from Session 1 to create and document a function
  • ...follow the steps from Session 2 to create a test for it
  • ...follow the steps from Session 3 to push your changes, and run through the debugging cycle until the Travis status checks pass

Resources

Clone this wiki locally