Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Render and Deploy to GitHub Pages
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Render and Deploy to GitHub Pages
---
name: Render and Deploy to GitHub Pages

YAML files start with three dashes. I use the yamllint tool recommended by the YAML standard: https://yaml.org/tools/ which highlights the need to fix this issue, although another handy reference I like is from Learn X in Y Minutes: https://learnxinyminutes.com/yaml/


on:
push:
branches: [main]

jobs:
render:
runs-on: ubuntu-latest
container:
image: rocker/verse:4.4.1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
image: rocker/verse:4.4.1
image: rocker/verse:latest

Use the latest tag as listed here: https://hub.docker.com/r/rocker/verse/tags ... it's quite likely that using this 2 year old version of R is what's causing the problems you saw with ggplot.

steps:
- uses: actions/checkout@v4
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

Name all steps; naming here acts somewhat like comments do in code where you are explaining your rationale for what you're doing, as well as in your GitHub workflow graph / list.


- name: Install RStan
run: |
R -q -e 'install.packages(c("rstan", "rstantools", "bayesplot", "deSolve", "posterior"), repos = "https://cloud.r-project.org")'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
R -q -e 'install.packages(c("rstan", "rstantools", "bayesplot", "deSolve", "posterior"), repos = "https://cloud.r-project.org")'
Rscript -e 'pak::local_install_deps("stanodeffr", dependencies = TRUE)'
  1. The whole point of having a package is for you not have to explicitly specify the dependencies like you are doing here; the DESCRIPTION file does that for you. The DESCRIPTION contains Imports dependencies which are required for the package functions to run and Suggests dependencies which are required to build the vignettes. Here we are building a single vignette and the package has no functions, so the dependencies are all in the Suggests section. Unlike Imports, dependencies in the Suggests section are optional and not installed by default, because the assumption is that you may want to install a package without all the extra dependencies if you're not doing to build the vignettes. Therefore to build the vignette we have to explicitly ask for the optional Suggests dependencies to be installed using dependencies = TRUE. How would you know to use TRUE? Read the documentation for ?pak::local_install_deps.

  2. Don't use R in CI; R is meant for interactive work whereas Rscript is meant for non-interactive / batch work. See https://cloud.r-project.org/doc/manuals/r-release/R-intro.html#Scripting-with-R-1

  3. Do not override your value of repos; the default value points to a binary package repository which significantly cuts down on package installation time by skipping the compilation:

    > getOption("repos")
                                             CRAN 
    "https://p3m.dev/cran/__linux__/noble/latest"


- name: Render Rmd
run: |
R -q -e 'rmarkdown::render("stanodeffr/01-stan-ode-forcing-function.Rmd", output_format = "html_document", output_file = "index.html", output_dir = "docs")'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
R -q -e 'rmarkdown::render("stanodeffr/01-stan-ode-forcing-function.Rmd", output_format = "html_document", output_file = "index.html", output_dir = "docs")'
Rscript -e 'rmarkdown::render("stanodeffr/01-stan-ode-forcing-function.Rmd", output_format = "all", output_dir = "public")'
  1. For the conference, we are testing not only HTML vignettes, but also PDF vignettes in case the AI assistant views them differently. So render all the formats as described in the README.md

  2. The next default value for the step is public/ directory according to https://github.com/peaceiris/actions-gh-pages/blob/v4.1.0/action.yml#L27

  3. As above, use Rscript instead of R for non-interactive code.


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Create index.html pages to see all vignette files
run: |
cd public/
apt update
apt -y install tree
tree -H '.' \
-T 'Vignettes for Stan ODE forcing function'
-I index.html \
--noreport \
--houtro "" \
-o index.html

This creates an HTML file with links to all the vignette files in the directory; see https://stackoverflow.com/a/46383157

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4.1.0

Don't use an arbitrary old version, use the latest tagged version that is most up-to-date, has security fixes, etc. See https://github.com/peaceiris/actions-gh-pages/releases

with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
publish_dir: ./docs

You no longer need to specify an input directory if you're creating the default public/ it wants above using rmarkdown::render(..., output_dir = "public")

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM rocker/verse:4.4.1
RUN apt-get update && apt-get install -y --no-install-recommends libv8-dev && rm -rf /var/lib/apt/lists/*
RUN R -q -e 'install.packages(c("rstan", "rstantools", "bayesplot"), repos = "https://cloud.r-project.org")'
Comment on lines +1 to +3
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file shouldn't be part of the PR at all. You woudn't use a Dockerfile to reproduce what the CI is doing; it would be a set of bash shell commands.

5 changes: 3 additions & 2 deletions stanodeffr/01-stan-ode-forcing-function.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,9 @@ df_stan_fit |>
noisy[, c("time", "x")] |>
as.data.frame() |>
pivot_longer(-time),
group = NULL,
color = NULL,
inherit.aes = FALSE,
aes(x = time, y = value),

Comment on lines +659 to +661
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to edit this file if you're using an up-to-date rocker/rverse image instead of the 2 year old 4.4 version.

size = 0.1)
```

Expand Down