You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/github-actions.Rmd
+48-37Lines changed: 48 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,54 @@ vignette: >
9
9
10
10
## Introduction
11
11
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.
13
13
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:
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:
#> 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.
15
60
16
61
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.
17
62
@@ -63,8 +108,7 @@ jobs:
63
108
64
109
Commit the new GitHub Actions file changes, then push the commit to GitHub.
65
110
66
-
67
-
## The GitHub Actions build process
111
+
### The GitHub Actions build process
68
112
69
113
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.
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.
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:
0 commit comments