Add Continuous Integration#1
Conversation
omsai
left a comment
There was a problem hiding this comment.
-
Apply the commits from the review as you see fit and then test that the changes you apply still build the vignette on your repository and reply with a link to the successful CI and output website.
-
If it does not work as expected you may then need to troubleshoot it in your local Docker container or add some debugging bash shell lines of code into your CI file to find what went wrong.
| @@ -0,0 +1,27 @@ | |||
| name: Render and Deploy to GitHub Pages | |||
There was a problem hiding this comment.
| 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/
| render: | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: rocker/verse:4.4.1 |
There was a problem hiding this comment.
| 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.
| container: | ||
| image: rocker/verse:4.4.1 | ||
| steps: | ||
| - uses: actions/checkout@v4 |
There was a problem hiding this comment.
| - 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")' |
There was a problem hiding this comment.
| 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)' |
-
The whole point of having a package is for you not have to explicitly specify the dependencies like you are doing here; the
DESCRIPTIONfile does that for you. TheDESCRIPTIONcontainsImportsdependencies which are required for the package functions to run andSuggestsdependencies 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 theSuggestssection. UnlikeImports, dependencies in theSuggestssection 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 optionalSuggestsdependencies to be installed usingdependencies = TRUE. How would you know to useTRUE? Read the documentation for?pak::local_install_deps. -
Don't use
Rin CI;Ris meant for interactive work whereasRscriptis meant for non-interactive / batch work. See https://cloud.r-project.org/doc/manuals/r-release/R-intro.html#Scripting-with-R-1 -
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")' |
There was a problem hiding this comment.
| 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")' |
-
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
-
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 -
As above, use
Rscriptinstead ofRfor non-interactive code.
| R -q -e 'rmarkdown::render("stanodeffr/01-stan-ode-forcing-function.Rmd", output_format = "html_document", output_file = "index.html", output_dir = "docs")' | ||
|
|
||
| - name: Deploy to GitHub Pages | ||
| uses: peaceiris/actions-gh-pages@v3 |
There was a problem hiding this comment.
| 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
| uses: peaceiris/actions-gh-pages@v3 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: ./docs |
There was a problem hiding this comment.
| 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")
| 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")' |
There was a problem hiding this comment.
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.
| inherit.aes = FALSE, | ||
| aes(x = time, y = value), | ||
|
|
There was a problem hiding this comment.
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.
| - 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")' | ||
|
|
There was a problem hiding this comment.
| - 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
Add pull request.