Skip to content

Commit

Permalink
Satisfy devtools::check() and add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Oct 17, 2020
1 parent 5a69d0c commit f792c14
Show file tree
Hide file tree
Showing 32 changed files with 561 additions and 69 deletions.
7 changes: 7 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
^\.github$
^.*\.html$
^.*\.Rmd$
^.*\.Rproj$
^\.Rproj\.user$
^.*\.yml$
^CODE_OF_CONDUCT\.md$
^CONTRIBUTING\.md$
^LICENSE\.md$
76 changes: 76 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
on: [push, pull_request]

name: check

jobs:
check:
runs-on: macOS-latest

env:
GITHUB_PAT: ${{ secrets.GITHUBPAT }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
TORCH_INSTALL: 1
R_REMOTES_NO_ERRORS_FROM_WARNINGS: false

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup R
uses: r-lib/actions/setup-r@master

- name: Install system requirements
run: |
brew install pandoc
brew install pandoc-citeproc
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install dependencies
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("covr")
shell: Rscript {0}

- name: Cache bookdown results
uses: actions/cache@v1
with:
path: _bookdown_files
key: bookdown-${{ hashFiles('**/*Rmd') }}
restore-keys: bookdown-

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_FORCE_SUGGESTS_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Bookdown
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
_R_CHECK_FORCE_SUGGESTS_: false
run: bookdown::render_book(input = "index.Rmd", output_format = "bookdown::gitbook")
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
61 changes: 61 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
on:
push:
branches: main

name: publish

jobs:
publish:
runs-on: macOS-latest

env:
GITHUB_PAT: ${{ secrets.GITHUBPAT }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
TORCH_INSTALL: 1
R_REMOTES_NO_ERRORS_FROM_WARNINGS: false

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup R
uses: r-lib/actions/setup-r@master

- name: Install system requirements
run: |
brew install pandoc
brew install pandoc-citeproc
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install dependencies
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("covr")
shell: Rscript {0}

- name: Cache bookdown results
uses: actions/cache@v1
with:
path: _bookdown_files
key: bookdown-${{ hashFiles('**/*Rmd') }}
restore-keys: bookdown-

- name: Publish manual
run: |
./inst/publish.sh
41 changes: 0 additions & 41 deletions .github/workflows/render.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ _book
_bookdown_files
_targets.R
_targets/
targets-manual.Rmd
46 changes: 46 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Package: targets.manual
Title: Targets R Package User Manual
Description: This repository is the 'bookdown' project of the targets R
package user manual. It contains in-depth discussion and walkthroughs
of the main features of 'targets' and advice about best practices.
Version: 0.0.0.9000
License: MIT + file LICENSE
URL: https://wlandau.github.io/targets-manual,
https://github.com/wlandau/targets-manual
BugReports: https://github.com/wlandau/targets-manual/issues
Authors@R: c(
person(
given = c("William", "Michael"),
family = "Landau",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-1878-3253")
),
person(
family = "Eli Lilly and Company",
role = "cph"
))
Depends:
R (>= 3.5.0)
Imports:
biglm (>= 0.9.2),
bookdown (>= 0.19),
fs (>= 1.4.1),
purrr (>= 0.3.4),
tarchetypes,
targets,
tidyverse (>= 1.3.0),
visNetwork (>= 2.0.9),
withr (>= 2.2.0)
Suggests:
knitr (>= 1.30),
rmarkdown (>= 2.4),
testthat (>= 2.3.2)
Remotes:
wlandau/tarchetypes,
wlandau/targets
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1.9000
VignetteBuilder: knitr
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2020
COPYRIGHT HOLDER: Eli Lilly and Company
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Generated by roxygen2: do not edit by hand

export(targets_manual_empty)
10 changes: 10 additions & 0 deletions R/empty.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#' @title Empty function
#' @export
#' @description This is a bookdown manual. It only
#' borrows R package infrastructure for devops purposes.
#' @return Nothing.
#' @examples
#' targets_manual_empty()
targets_manual_empty <- function() {
invisible()
}
8 changes: 0 additions & 8 deletions build.R

This file was deleted.

6 changes: 3 additions & 3 deletions files.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ save_plot_and_return_path <- function() {

R Markdown reports are a little more challenging because they often depend on upstream targets. To integrate an R Markdown report with a `targets` pipeline, you must use `tar_read()` and `tar_load()` in active code chunks to explicitly name the targets that the report depends on. (Do not use `tar_read_raw()` or `tar_load_raw()` for this.) The report from the [minimal example](https://github.com/wlandau/targets-minimal) looks like this.

![](./images/knitr-source.png)
![](./man/figures/knitr-source.png)

Above, the report depends on targets `fit` and `hist`. The use of `tar_read()` and `tar_load()` allows us to run the report outside the pipeline. (Again, do not use `tar_read_raw()` or `tar_load_raw()` for this.) As long as `_targets/` folder has data on the required targets from a previous `tar_make()`, you can open the RStudio IDE, edit the report, and click the Knit button like you would for any other R Markdown report.

![](./images/knitr-ide.png)
![](./man/figures/knitr-ide.png)

To connect the target with the pipeline, we define a special kind of target using `tar_render()` from the [`tarchetypes`](https://github.com/wlandau/tarchetypes) package instead of the usual `tar_target()`, which

Expand Down Expand Up @@ -186,7 +186,7 @@ tar_pipeline(
tar_visnetwork()
```

![](./images/knitr-graph.png)
![](./man/figures/knitr-graph.png)

### Parameterized R Markdown

Expand Down
6 changes: 3 additions & 3 deletions index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ output:
url: "https://wlandau.github.io/targets-manual"
description: "In-depth discussion of the major functionality of targets."
github-repo: "wlandau/targets-manual"
cover-image: /images/logo.png
apple-touch-icon: "images/apple-touch-icon.png"
cover-image: /man/figures/logo.png
apple-touch-icon: "man/figures/apple-touch-icon.png"
apple-touch-icon-size: 120
favicon: "images/favicon.ico"
favicon: "man/figures/favicon.ico"
always_allow_html: yes
---

Expand Down
Loading

0 comments on commit f792c14

Please sign in to comment.