Skip to content

Example R package that includes Plumber APIs

License

Notifications You must be signed in to change notification settings

aschmidt-amplify/test-plumber

 
 

Repository files navigation

plumbpkg

Travis build status

This is a simple package illustrating how to incorporate Plumber APIs into an R package. There are two main motivations behind this example:

  1. Demonstrate how to build Plumber APIs into a package
  2. Demonstrate how to test Plumber APIs using testthat

Installation

# install.packages("remotes")
remotes::install_github("sol-eng/plumbpkg")

Architecture

The design of this package is heavily influenced by this discussion on RStudio Community.

── DESCRIPTION
├── LICENSE
├── LICENSE.md
├── NAMESPACE
├── R
│   ├── api1.R
│   └── api2.R
├── README.md
├── inst
│   └── plumber
│       ├── api1
│       │   └── plumber.R
│       └── api2
│           ├── entrypoint.R
│           └── plumber.R
├── man
├── plumbpkg.Rproj
└── tests
    ├── testthat
    │   ├── test-api1.R
    │   ├── test-api2.R
    │   └── test-plumber.R
    └── testthat.R

The R/ directory contains all of the R functions used in the Plumber APIs. This enables the functions to be tested using files in the tests/ directory. The Plumber APIs are defined in files in inst/plumber/ and are also tested using testthat and httr.

Deploy

This repository deploys both APIs to RStudio Connect using Travis. The deployment is managed by scripts/deploy-rsc.sh and uses the RStudio Connect API. Because this repository uses Travis, the APIs will only be deployed after tests have successfully completed.

There are certainly other ways this content could be deployed, either using other CI/CD solutions or using RStudio Connect's ability to publish content from a git repository.

About

Example R package that includes Plumber APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 65.5%
  • Shell 34.5%