Updated: 2023-05-24

A simple guide to use CI/CD and Code coverage. For CI tasks will be done using GitHub Actions. Some examples of yaml files for CI tasks can be found here eg. check-standard.yaml file.

CI/CD

This is a simple process to implement CI/CD using GitHub Actions with usethis package. Basically the steps here is a summary from Dean Attali with slight changes:

  1. If you already use Travis and want to change to Github Actions, you have to delete all Travis related files and references. Easier to search with project SPC s p if you use Doom Emacs. Among those will be:
    • .travis.yml
    • link in README.md file
    • in .Rbuildignore file
  2. I have multiple git accounts as explained here and usethis will not able to find the correct repo URL. I have to change the origin to Git repo url from git@work:helseprofil/myrepo.git using either terminal or usethis::use_git_remote() functions. You can check your remote origin with git remote -v in the terminal just to check where the repos origin is.
# with R usethis package
usethis::use_git_remote("origin", url = "https://github.com/username/reponame.git", overwrite = TRUE)

# from terminal
git remote add origin https://github.com/username/reponame
  1. Get the CI url with:
usethis::use_github_action_check_standard()
  1. Paste the URL to your README file. The URL is allready copy to your clipboard when running step 3.
  2. You can edit R-CMD-check.yml file in folder .github/workflow to suit your need.

Covr

For Code coverage we will use both covr and usethis packages. So don’t forget to install them first! You can also read general guide from this blog. This short guide below is especially relevant if you are using Github Action:

CI  Cov 
comments powered by Disqus