Skip to content

Commit

Permalink
docs: amended R CMD CHECK and added coverage CI checks
Browse files Browse the repository at this point in the history
  • Loading branch information
simpar1471 committed Oct 16, 2024
1 parent e906946 commit a7a981d
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 8 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,35 @@ permissions: read-all

jobs:
R-CMD-check:
runs-on: ubuntu-latest
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
OPENFDA_KEY: ${{ secrets.OPENFDA_KEY }}
OPENFDA_TOKEN: ${{ secrets.OPENFDA_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
OPENFDA_KEY: ${{ secrets.OPENFDA_KEY }}
OPENFDA_TOKEN: ${{ secrets.OPENFDA_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
3 changes: 2 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ knitr::opts_chunk$set(
<!-- badges: start -->
[![R-CMD-check](https://github.com/simpar1471/openFDA/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/simpar1471/openFDA/actions/workflows/R-CMD-check.yaml)
[![Project Status: WIP -- Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![Codecov test coverage](https://codecov.io/gh/simpar1471/openFDA/graph/badge.svg)](https://app.codecov.io/gh/simpar1471/openFDA)
<!-- badges: end -->

openFDA makes querying the [openFDA API](https://open.fda.gov/apis/) from R a breeze.
Expand Down Expand Up @@ -83,4 +84,4 @@ The [openfda](https://github.com/rOpenHealth/openfda) package from `rOpenHealth`
It's got a pretty neat structure whereby you build up a query using individual functions for each parameter - though it's my personal preference to keep these as parameters to a single function.
It also makes results available in data frames, which is nice, but I think working with the response object and parsing the underlying JSON yourself permits more powerful interactions with the API.

There is also [FDAopenR](https://github.com/ck2136/FDAopenR/), which I couldn't quite wrap my head around. The package appears to be in working order, though!
There is also [FDAopenR](https://github.com/ck2136/FDAopenR/), which I couldn't quite wrap my head around. The package appears to be in working order, though!
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
[![Project Status: WIP – Initial development is in progress, but there
has not yet been a stable, usable release suitable for the
public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![Codecov test
coverage](https://codecov.io/gh/simpar1471/openFDA/graph/badge.svg)](https://app.codecov.io/gh/simpar1471/openFDA)
<!-- badges: end -->

openFDA makes querying the [openFDA API](https://open.fda.gov/apis/)
Expand Down Expand Up @@ -59,7 +61,7 @@ search
#> https://api.fda.gov/drug/drugsfda.json?api_key=[API_KEY]&search=openfda.generic_name:furosemide&limit=5
#> Status: 200 OK
#> Content-Type: application/json
#> Body: In memory (22363 bytes)
#> Body: In memory (17286 bytes)
```

The underlying response is JSON data - you can use
Expand All @@ -85,11 +87,9 @@ purrr::map_chr(
.x = json$results,
.f = \(result) purrr::pluck(result, "openfda", "manufacturer_name", 1)
)
#> [1] "Meitheal Pharmaceuticals Inc."
#> [2] "Hospira, Inc."
#> [3] "Heritage Pharmaceuticals Inc. d/b/a Avet Pharmaceuticals Inc."
#> [4] "scPharmaceuticals Inc."
#> [5] "Graviti Pharmaceuticals Private Limited"
#> [1] "Amneal Pharmaceuticals LLC" "Gland Pharma Limited"
#> [3] "Solco Healthcare LLC" "Lifestar Pharma LLC"
#> [5] "Ipca Laboratories Limited"
```

## Other R packages for openFDA
Expand Down

0 comments on commit a7a981d

Please sign in to comment.