Skip to content

Commit ca2caaa

Browse files
committed
Write out a quick README file
1 parent e45d3b3 commit ca2caaa

File tree

3 files changed

+197
-29
lines changed

3 files changed

+197
-29
lines changed

README.md

Lines changed: 88 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,113 @@
1+
12
# webr-github-action-wasm-binaries
23

34
<!-- badges: start -->
5+
46
[![R-CMD-check](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/actions/workflows/R-CMD-check.yaml)
57
[![webr-build-binary](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/actions/workflows/deploy-cran-repo.yml/badge.svg)](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/actions/workflows/deploy-cran-repo.yml)
68
<!-- badges: end -->
79

8-
Example GitHub Actions workflow with an R package that generates developmental webR binaries
10+
Example GitHub Action workflow to generate developmental webR/R WASM
11+
Package binaries
12+
13+
# Overview
14+
15+
Interested in having your R package automatically be built for
16+
[webR](https://docs.r-wasm.org/webr/latest/) through a [GitHub
17+
Action](https://github.com/features/actions)? If so, this is the
18+
repository for you! Here’s a summary of what you can find in the
19+
repository:
20+
21+
- [`.github/workflows/deploy-cran-repo.yml`](.github/workflows/deploy-cran-repo.yml):
22+
Modified version of [`r-wasm/actions`
23+
deploy-cran-repo.yml](https://github.com/r-wasm/actions/blob/d21bf7da50e539df543bbee973087ec585deaba6/examples/deploy-cran-repo.yml)
24+
- [`DESCRIPTION`](DESCRIPTION): Standard description information for an
25+
R package
26+
- [`R/in-webr.R`](R/in-webr.R): Check to see if we’re inside of webR or
27+
not.
28+
29+
You can view the pushed webR package binary parts by looking at the
30+
[`gh-pages`](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/tree/gh-pages)
31+
branch of the repository. Specifically, we can see binary package data
32+
[`bin/emscripten/contrib/4.3`](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/tree/gh-pages/bin/emscripten/contrib/4.3)
33+
and the package information in
34+
[`src/contrib`](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/tree/gh-pages/src/contrib).
35+
You can read more about package repositories that are CRAN-like in the
36+
[R Administration: 6.6 Setting up a package
37+
repository](https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Setting-up-a-package-repository).
938

10-
## Steps
39+
## Setup
1140

12-
1. Deployed
41+
You can re-create the necessary parts to automatically compile R WASM
42+
package binaries and make them available on GitHub Pages with:
1343

14-
```r
44+
``` r
45+
if(!requireNamespace("usethis", quietly = TRUE)) {install.packages("usethis")}
46+
47+
48+
# Ensure GitHub Pages is setup
49+
usethis::use_github_pages()
50+
51+
# Obtain the modified version of the rwasm repo setup
1552
usethis::use_github_action(
16-
url = "https://raw.githubusercontent.com/r-wasm/actions/v1/examples/deploy-cran-repo.yml"
53+
"https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/blob/main/.github/workflows/deploy-cran-repo.yml"
1754
)
1855
```
1956

20-
2. Modify to include `packages: .` to trigger `pak` to treat the local environment as the package
57+
Viola! Binaries will automatically be built on each new commit and
58+
published on the repository’s website served by GitHub Pages.
2159

22-
3. Enable GH pages
60+
## Accessing Binaries
2361

24-
```r
25-
usethis::use_github_pages()
26-
```
62+
Inside of a webR session, you can access the built binaries by using the
63+
repository’s GitHub Pages URL, e.g.
2764

28-
Avoids:
65+
https://gh-username.github.io/repo-name
2966

30-
```
31-
Error: Creating Pages deployment failed
32-
Error: HttpError: Not Found
33-
at /home/runner/work/_actions/actions/deploy-pages/v2/node_modules/@octokit/request/dist-node/index.js:86:1
34-
at processTicksAndRejections (node:internal/process/task_queues:96:5)
35-
at createPagesDeployment (/home/runner/work/_actions/actions/deploy-pages/v2/src/internal/api-client.js:126:1)
36-
at Deployment.create (/home/runner/work/_actions/actions/deploy-pages/v2/src/internal/deployment.js:80:1)
37-
at main (/home/runner/work/_actions/actions/deploy-pages/v2/src/index.js:30:1)
38-
Error: Error: Failed to create deployment (status: 404) with build version 0e5457c152727daecc085994d0dd749653c6ab17. Ensure GitHub Pages has been enabled: https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/settings/pages
67+
This can be set either using `options()` or specifying the location in
68+
each `webr::install()` call.
69+
70+
The easiest is probably to define the location webR should search for in
71+
`options()`.
72+
73+
``` r
74+
# Run once at the start of the session
75+
options(
76+
repos = c("https://gh-username.github.io/repo-name",
77+
"https://repo.r-wasm.org/")
78+
)
79+
80+
# Call
81+
webr::install("pkgname")
3982
```
4083

41-
4. Enable `main` or `master` branch deployments to `gh-pages` to avoid running into:
84+
Otherwise, you can specify it each time:
4285

43-
```sh
44-
Branch "main" is not allowed to deploy to github-pages due to environment protection rules.
86+
``` r
87+
webr::install("pkgname", "https://gh-username.github.io/repo-name")
4588
```
4689

47-
Perform the following steps:
90+
## Verify
91+
92+
Go to the [webR REPL Editor](https://webr.r-wasm.org/v0.2.2/) (pinned to
93+
v0.2.2) and run the following:
94+
95+
``` r
96+
# Check if package `{demorwasmbinary}` is installed
97+
"demorwasmbinary" %in% installed.packages()[,"Package"]
98+
# Install the binary from a repository
99+
webr::install(
100+
"demorwasmbinary",
101+
repos = "https://tutorials.thecoatlessprofessor.com/webr-github-action-wasm-binaries/"
102+
)
103+
# Check to see if the function works
104+
demorwasmbinary::in_webr()
105+
# View help documentation
106+
?demorwasmbinary::in_webr
107+
```
48108

49-
- Click the repository **Settings**.
50-
- Select **Environments** under Code and automation section.
51-
- Click on the **github-pages** environment.
52-
- Under **Deployment branches** click on **Add deployment branch or tag rule**.
53-
- Enter the pattern `main` or `master` depending on the name of the primary repository branch.
109+
You should receive:
54110

111+
![Screenshot of the webR REPL editor showing how to download from
112+
repository outside of repo.r-wasm.org an R package
113+
binary](man/figures/demo-of-package-working-in-webr-repl.png)

README.qmd

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
format: gfm
3+
engine: knitr
4+
---
5+
6+
# webr-github-action-wasm-binaries
7+
8+
<!-- badges: start -->
9+
[![R-CMD-check](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/actions/workflows/R-CMD-check.yaml)
10+
[![webr-build-binary](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/actions/workflows/deploy-cran-repo.yml/badge.svg)](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/actions/workflows/deploy-cran-repo.yml)
11+
<!-- badges: end -->
12+
13+
Example GitHub Action workflow to generate developmental webR/R WASM Package binaries
14+
15+
# Overview
16+
17+
Interested in having your R package automatically be built for [webR](https://docs.r-wasm.org/webr/latest/) through
18+
a [GitHub Action](https://github.com/features/actions)?
19+
If so, this is the repository for you! Here's a summary of what you can find in the repository:
20+
21+
- [`.github/workflows/deploy-cran-repo.yml`](.github/workflows/deploy-cran-repo.yml):
22+
Modified version of [`r-wasm/actions`' deploy-cran-repo.yml](https://github.com/r-wasm/actions/blob/d21bf7da50e539df543bbee973087ec585deaba6/examples/deploy-cran-repo.yml)
23+
- [`DESCRIPTION`](DESCRIPTION):
24+
Standard description information for an R package
25+
- [`R/in-webr.R`](R/in-webr.R): Check to see if we're inside of webR or not.
26+
27+
You can view the pushed webR package binary parts by looking at the
28+
[`gh-pages`](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/tree/gh-pages)
29+
branch of the repository. Specifically, we can see binary package data [`bin/emscripten/contrib/4.3`](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/tree/gh-pages/bin/emscripten/contrib/4.3)
30+
and the package information in
31+
[`src/contrib`](https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/tree/gh-pages/src/contrib). You can read more about package repositories that
32+
are CRAN-like in the [R Administration: 6.6 Setting up a package repository](https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Setting-up-a-package-repository).
33+
34+
## Setup
35+
36+
You can re-create the necessary parts to automatically compile
37+
R WASM package binaries and make them available on GitHub Pages with:
38+
39+
```r
40+
if(!requireNamespace("usethis", quietly = TRUE)) {install.packages("usethis")}
41+
42+
43+
# Ensure GitHub Pages is setup
44+
usethis::use_github_pages()
45+
46+
# Obtain the modified version of the rwasm repo setup
47+
usethis::use_github_action(
48+
"https://github.com/coatless-tutorials/webr-github-action-wasm-binaries/blob/main/.github/workflows/deploy-cran-repo.yml"
49+
)
50+
```
51+
52+
Viola! Binaries will automatically be built on each new commit and published
53+
on the repository's website served by GitHub Pages.
54+
55+
## Accessing Binaries
56+
57+
Inside of a webR session, you can access the built binaries by using
58+
the repository's GitHub Pages URL, e.g.
59+
60+
```
61+
https://gh-username.github.io/repo-name
62+
```
63+
64+
This can be set either using `options()` or specifying the location in each
65+
`webr::install()` call.
66+
67+
The easiest is probably to define the location webR should search for in
68+
`options()`.
69+
70+
```r
71+
# Run once at the start of the session
72+
options(
73+
repos = c("https://gh-username.github.io/repo-name",
74+
"https://repo.r-wasm.org/")
75+
)
76+
77+
# Call
78+
webr::install("pkgname")
79+
```
80+
81+
Otherwise, you can specify it each time:
82+
83+
```r
84+
webr::install("pkgname", "https://gh-username.github.io/repo-name")
85+
```
86+
87+
## Verify
88+
89+
Go to the [webR REPL Editor](https://webr.r-wasm.org/v0.2.2/) (pinned to v0.2.2)
90+
and run the following:
91+
92+
```r
93+
# Check if package `{demorwasmbinary}` is installed
94+
"demorwasmbinary" %in% installed.packages()[,"Package"]
95+
# Install the binary from a repository
96+
webr::install(
97+
"demorwasmbinary",
98+
repos = "https://tutorials.thecoatlessprofessor.com/webr-github-action-wasm-binaries/"
99+
)
100+
# Check to see if the function works
101+
demorwasmbinary::in_webr()
102+
# View help documentation
103+
?demorwasmbinary::in_webr
104+
```
105+
106+
You should receive:
107+
108+
![Screenshot of the webR REPL editor showing how to download from repository outside of repo.r-wasm.org an R package binary](man/figures/demo-of-package-working-in-webr-repl.png)
109+
Loading

0 commit comments

Comments
 (0)