Skip to content

Commit bf13e30

Browse files
committed
Rearrange GHA vignette
1 parent a0e7be0 commit bf13e30

File tree

1 file changed

+48
-37
lines changed

1 file changed

+48
-37
lines changed

vignettes/github-actions.Rmd

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,54 @@ vignette: >
99

1010
## Introduction
1111

12-
Using the set of GitHub Actions provided by [r-wasm/actions](https://github.com/r-wasm/actions), it is possible to build a list of Wasm R packages and automatically deploy the resulting package repository or library image to a GitHub Pages URL. This workflow simplifies the process of deploying a set of R packages for use with webR, and enables continuous integration.
12+
Using the set of GitHub Actions provided by [r-wasm/actions](https://github.com/r-wasm/actions), it is possible to automatically build and deploy WebAssembly binary versions of R packages. This workflow simplifies the process of deploying R packages for use with webR, and facilitates continuous integration.
1313

14-
## Setting up the GitHub repository
14+
## Deploying an R package on release
15+
16+
It is possible to build an R package for WebAssembly, optionally including other R package dependencies in the output, using the `release-file-system-image.yml` GitHub Actions workflow.
17+
18+
First, add the GitHub action to your R package repository:
19+
20+
```r
21+
usethis::use_github_action(
22+
url = "https://raw.githubusercontent.com/r-wasm/actions/v1/examples/release-file-system-image.yml"
23+
)
24+
```
25+
26+
Commit the new GitHub Actions file, then make a package release through the GitHub web interface. GitHub Actions will build a Wasm filesystem image for your package and its dependencies and upload it as asset files for that specific package release.
27+
28+
Once the Github Action has finished running, the asset files `library.data` and `library.js.metadata` can be downloaded from the GitHub releases page.
29+
30+
If you are using your Wasm R package in a Shiny app with `shinylive::export()`, it will now be downloaded automatically as part of the app export. Otherwise, read on for details on how to make the resulting R package binaries available to a webR application.
31+
32+
### Hosting the resulting package
33+
34+
In principle, it is possible to directly mount the filesystem image from the release asset URL using `webr::mount()`. However, in web browsers this will likely be blocked due to the [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) mechanism. Instead, the files should be uploaded to static hosting in some way, for example by additional GitHub Actions steps that uploads the release assets to GitHub Pages.
35+
36+
An example GitHub action that uploads release assets to GitHub pages, in addition to pkgdown documentation, can be found [here](https://github.com/r-wasm/actions/blob/main/examples/rwasm-binary-and-pkgdown-site.yml).
37+
38+
Once the files have been hosted on GitHub Pages, or otherwise, mount the filesystem image in webR and set the `.libPaths()` to load R packages from the package library:
39+
40+
```{r eval=FALSE}
41+
webr::mount("/my-library", "https://org.github.io/repo/download/library.data")
42+
.libPaths(c(.libPaths(), "/my-library"))
43+
library(dplyr)
44+
#> Attaching package: ‘dplyr’
45+
#>
46+
#> The following objects are masked from ‘package:stats’:
47+
#>
48+
#> filter, lag
49+
#>
50+
#> The following objects are masked from ‘package:base’:
51+
#>
52+
#> intersect, setdiff, setequal, union
53+
```
54+
55+
Further information about Emscripten filesystem images can be found in the `vignette("mount-fs-image.Rmd")` article.
56+
57+
## Creating a WebAssembly CRAN-like repository
58+
59+
Alternatively, if you have multiple R packages you may want to build a custom WebAssembly CRAN-like repository on GitHub Pages. This workflow is useful if you want to manage several packages and do not mind creating a new repository, separate from your R package source, to do so.
1560

1661
First, create a new GitHub repository [following GitHub's instructions](https://docs.github.com/en/get-started/quickstart/create-a-repo#) to initialise a new empty git repo.
1762

@@ -63,8 +108,7 @@ jobs:
63108
64109
Commit the new GitHub Actions file changes, then push the commit to GitHub.
65110
66-
67-
## The GitHub Actions build process
111+
### The GitHub Actions build process
68112
69113
The GitHub Actions workflow should automatically start to run and build your list of packages. You should be able to see progress of the website build step in the **Actions** section of your GitHub project.
70114
@@ -76,36 +120,3 @@ webr::install("cli", repos = "http://username.github.io/my-wasm-repo/")
76120
```
77121

78122
Further usage details can be found in the [r-wasm/actions GitHub documentation](https://github.com/r-wasm/actions/blob/v1/.github/workflows/README.md).
79-
80-
## Using an R package library image
81-
82-
An Emscripten filesystem image containing an R package library may also be built and attached to a GitHub package release. If you'd prefer to mount an R package library, rather than install packages from a CRAN-like repo, use the `release-file-system-image.yml` workflow.
83-
84-
```r
85-
usethis::use_github_action(
86-
url = "https://raw.githubusercontent.com/r-wasm/actions/v1/examples/release-file-system-image.yml"
87-
)
88-
```
89-
90-
Commit the new GitHub Actions file, then make a release through the GitHub web interface. GitHub Actions will build a Wasm filesystem image for your package and its dependencies and upload it as asset files for that specific package release.
91-
92-
Once the Github Action has finished, the `library.data` and `library.js.metadata` assets files can be downloaded from the GitHub releases page. The filesystem image files should then be made available through static hosting in some way, for example though further GitHub Actions steps to upload the filesystem image files as part of a custom GitHub Pages website.^[In principle, it is possible to directly mount the filesystem image from the release asset URL using `webr::mount()`. However, in web browsers this will likely be blocked due to the [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) mechanism.]
93-
94-
Finally, in webR, mount the statically hosted filesystem image and set the `.libPaths()` to load a package from the package library:
95-
96-
```{r eval=FALSE}
97-
webr::mount("/my-library", "https://org.github.io/repo/download/library.data")
98-
.libPaths(c(.libPaths(), "/my-library"))
99-
library(dplyr)
100-
#> Attaching package: ‘dplyr’
101-
#>
102-
#> The following objects are masked from ‘package:stats’:
103-
#>
104-
#> filter, lag
105-
#>
106-
#> The following objects are masked from ‘package:base’:
107-
#>
108-
#> intersect, setdiff, setequal, union
109-
```
110-
111-
Further information about Emscripten filesystem images can be found in the `vignette("mount-fs-image.Rmd")` article.

0 commit comments

Comments
 (0)