Skip to content

CRAN Repository per package repository instead of a separate single repository storing multi-package #15

@coatless

Description

@coatless

Thanks again for working on the workflows!

I've read through the documentation on rwasm GitHub Actions and Getting Started. One of the takeaways I had for repository deployment is it needs to be in a standalone repository that is geared toward having multiple R WASM binary packages present. That is, we cannot pair the action with an already existing R package repository.

So, I went off and investigated whether the workflow action could be easily deployed inside an existing package repository that has multiple workflows already present (e.g. pkgdown, r-cmd-check, et cetera). The hope is to further decrease the barrier of entry by chaining usethis::use_github_pages() (to setup GitHub Pages automatically) alongside the usethis::use_github_action() (to retrieve the deployment action). I'm particularly eyeing a custom function inside of usethis (c.f. r-lib/usethis#1932).

However, after a couple of changes:

  1. modifying the existing workflow to create a package list directly from the DESCRIPTION file (e.g. packages: '.')
  2. enabling deployments from the main/master branch to the github-pages environment

I still couldn't get the action to publish the archive onto GitHub pages.

After multiple attempts, I switched over to directly working with the r-wasm/actions/build-rwasm action and managed to get the repository up and running by using:

# Workflow derived from https://github.com/r-wasm/actions/tree/v1/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
  push:
    # Only build on main or master branch
    branches: [main, master]
  # Or when triggered manually
  workflow_dispatch: {}

name: Build WASM R package and Repo

jobs:
  deploy-cran-repo:
    # Only restrict concurrency for non-PR jobs
    concurrency:
      group: r-wasm-${{ github.event_name != 'pull_request' || github.run_id }}
    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
    permissions:
      contents: write
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Build WASM R packages
        uses: r-wasm/actions/build-rwasm@v1
        with:
          packages: "."
          repo-path: "_site"

      - name: Deploy wasm R packages to GitHub pages 🚀
        if: github.event_name != 'pull_request'
        uses: JamesIves/github-pages-deploy-action@v4.4.1
        with:
          clean: false
          branch: gh-pages
          folder: _site

I think a few folks would be interested in a workflow similar to the above. So, a few quick questions:

  1. Would you be okay to include this as an example under examples/?
  2. Do you see any glaring issues with moving toward a per-package webR CRAN repository compared to a multi-package single repository for the organization?
Demo script and screenshot showing working installation with webR REPL Editor
# Check if package `{demorwasmbinary}` is installed
"demorwasmbinary" %in% installed.packages()[,"Package"]
# Install the binary from a repository
webr::install(
  "demorwasmbinary", 
  repos = "https://tutorials.thecoatlessprofessor.com/webr-github-action-wasm-binaries/"
)
# Check to see if the function works
demorwasmbinary::in_webr()
# View help documentation
?demorwasmbinary::in_webr
Screenshot of the webR REPL editor showing how to download from repository outside of repo.r-wasm.org an R package binary

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions