Site icon R-bloggers

pkgcheck now available as a GitHub action!

[This article was first published on rOpenSci - open tools for open science, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

What is pkgcheck?

The pkgcheck package has been developed by rOpenSci to automate the process of checking all packages on submission. The ropensci-review-bot automatically runs pkgcheck on all submissions, and checks can also be called at any time by editors using the command:

@ropensci-review-bot check package

The bot will return a list of checks which should ideally look like this:

To be ready for peer review, pkgcheck should return a series of ✔, indicating successful checks, and there shouldn’t be any ✘ symbols, which indicate failed checks. Anybody preparing a package to submit is recommended to “use pkgcheck” to confirm that a package is indeed ready to submit. Until now, this has only been possible through locally installing the package and running the pkgcheck() command. Local checks suffer two important disadvantages:

  1. Results may only be reproducible on a local system, rather than be generally reproducible; and
  2. The checks run by pkgcheck include all checks run by the rcmdcheck package which may take quite some time to run.

Just like the GitHub rcmdcheck action which can be easily installed with one of the use_github_action_check_... functions from the usethis package, pkgcheck now also has a GitHub action which overcomes both of these disadvantages through running remotely (on GitHub), and generating reproducible results.

The GitHub pkgcheck-action

This post is the “official” release announcement of pkgcheck-action, a GitHub action which enables checks to be run every time code is pushed to GitHub. The action was developed by one of us (Jacob), and can be found on GitHub at ropensci-review-tools/pkgcheck-action. The easiest way to use this action in your own repository is to install the pkgcheck package, and run the use_github_action_pkgcheck() function. That will place a new file in the .github/workflows directory of your package called “pkgcheck.yaml”, an example of which is shown on the main README of the pkgcheck-action repository. The action consists of the single job expressed in the final lines:

jobs:
 check:
 runs-on: ubuntu-latest
 steps:
 - uses: ropensci-review-tools/pkgcheck-action@main

There are several parameters also described in that main README, which can either be passed as parameters to the use_github_action_pkgcheck() function, or added to the YAML workflow file as also described in the README. Once the action has been created in your repository, it can be activated by adding it in a git commit and pushing to GitHub.

Posting pkgcheck results to a GitHub issue

In addition to the workflow printing the full details returned by the main pkgcheck function, the output of pkgcheck can also be posted to a GitHub issue, where it will appear precisely like the example shown above. Once the workflow has finished, you’ll receive a notification, and be able to view the check results (with a summary-only parameter determining whether only a summary of results like shown above will be posted to the issue, or whether full results will be posted which include the summary followed by quite a bit more detail). The workflow will only succeed when all pkgcheck checks have been passed.

Using pkgcheck-action to prepare for submission

This action makes preparing packages for submission to peer review with rOpenSci much easier, by automatically confirming whether a package the general requirements for rOpenSci submissions. You can use pkgcheck-action to confirm that a package is ready for submission by following these three easy steps:

  1. Insert the action into your repository with pkgcheck::use_github_action_pkgcheck().
  2. Add and commit the action script to your git index, and push to GitHub to activate it.
  3. Examine results in the automatically-created issue of your GitHub repository, modify the repository to address any failing checks, and iterate.
  4. Once the action passes, you’ll see “✔ This package may be submitted.”

You can also put a pkgcheck} badge in your README by inserting a modified version of these lines:

[![pkgcheck](https://github.com/<org>/<repo>/workflows/pkgcheck/badge.svg)](https://github.com/<org>/<repo>/actions?query=workflow%3Apkgcheck)

Once your package passes all tests, the badge will turn green and look like this:

< svg xmlns="http://www.w3.org/2000/svg" width="128" height="20"> < defs>
  • < stop stop-color="#444D56" offset="0%"> < stop stop-color="#24292E" offset="100%">
  • < stop stop-color="#34D058" offset="0%"> < stop stop-color="#28A745" offset="100%"> < g fill="none" fill-rule="evenodd"> < g -family="'DejaVu Sans',Verdana,Geneva,sans-serif" -size="11"> < path id="workflow-bg" d="M0,3 C0,1.3431 1.3552,0 3.02702703,0 L102,0 L102,20 L3.02702703,20 C1.3552,20 0,18.6569 0,17 L0,3 Z" fill="url(#workflow-fill)" fill-rule="nonzero"> < text fill="#010101" fill-opacity=".3"> < tspan x="22.1981982" y="15">pkgcheck < text fill="#FFFFFF"> < tspan x="22.1981982" y="14">pkgcheck < g transform="translate(79)" -family="'DejaVu Sans',Verdana,Geneva,sans-serif" -size="11"> < path d="M0 0h46.939C48.629 0 50 1.343 50 3v14c0 1.657-1.37 3-3.061 3H0V0z" id="state-bg" fill="url(#state-fill)" fill-rule="nonzero"> < text fill="#010101" fill-opacity=".3"> < tspan x="4" y="15">passing < text fill="#FFFFFF"> < tspan x="4" y="14">passing < path fill="#959DA5" d="M11 3c-3.868 0-7 3.132-7 7a6.996 6.996 0 0 0 4.786 6.641c.35.062.482-.148.482-.332 0-.166-.01-.718-.01-1.304-1.758.324-2.213-.429-2.353-.822-.079-.202-.42-.823-.717-.99-.245-.13-.595-.454-.01-.463.552-.009.946.508 1.077.718.63 1.058 1.636.76 2.039.577.061-.455.245-.761.446-.936-1.557-.175-3.185-.779-3.185-3.456 0-.762.271-1.392.718-1.882-.07-.175-.315-.892.07-1.855 0 0 .586-.183 1.925.718a6.5 6.5 0 0 1 1.75-.236 6.5 6.5 0 0 1 1.75.236c1.338-.91 1.925-.718 1.925-.718.385.963.14 1.68.07 1.855.446.49.717 1.112.717 1.882 0 2.686-1.636 3.28-3.194 3.456.254.219.473.639.473 1.295 0 .936-.009 1.689-.009 1.925 0 .184.131.402.481.332A7.011 7.011 0 0 0 18 10c0-3.867-3.133-7-7-7z">

    You’ll then know that your package is good to submit!

    And finally, feel free to ask any questions about using pkgcheck-action, or report any bugs, at https://github.com/ropensci-review-tools/pkgcheck-action/issues.

    To leave a comment for the author, please follow the link and comment on their blog: rOpenSci - open tools for open science.

    R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
    Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.