Skip to content

Commit

Permalink
update readme and switch over to shiny-workflow for r-cmd check
Browse files Browse the repository at this point in the history
  • Loading branch information
parmsam committed Apr 10, 2024
1 parent a07a949 commit 2305764
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 27 deletions.
227 changes: 203 additions & 24 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,229 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_call:
inputs:
extra-packages:
type: string
default: ""
required: false
cache-version:
type: string
default: "2"
required: false
pandoc-version:
type: string
default: "3.x"
required: false
extra-check-args:
type: string
# default: '"--run-donttest", "--no-manual", "--as-cran"'
default: "NULL"
required: false
macOS:
type: string
default: "macOS-latest"
required: false
windows:
type: string
default: "windows-latest"
required: false
ubuntu:
type: string
required: false
# To test more versions, they must be separated by a space. Ex: `"ubuntu-18.04 ubuntu-20.04`
default: "ubuntu-20.04"
minimum-r-version:
type: string
required: false
default: ""
force-windows-src:
type: boolean
required: false
default: false
rtools-35:
type: boolean
default: true
required: false
rtools-40:
type: boolean
default: true
required: false

name: R-CMD-check

jobs:
setup:
name: setup
runs-on: ubuntu-latest
outputs:
config: ${{ steps.config.outputs.config }}
steps:
# - name: devel
# id: devel
# uses: r-lib/actions/setup-r@v2
# with:
# r-version: devel
# install-r: false

- name: release
id: release
uses: r-lib/actions/setup-r@v2
with:
r-version: release
install-r: false

- name: oldrel-1
id: oldrel-1
uses: r-lib/actions/setup-r@v2
with:
r-version: oldrel-1
install-r: false

- name: oldrel-2
id: oldrel-2
uses: r-lib/actions/setup-r@v2
with:
r-version: oldrel-2
install-r: false

- name: oldrel-3
id: oldrel-3
uses: r-lib/actions/setup-r@v2
with:
r-version: oldrel-3
install-r: false

- name: oldrel-4
id: oldrel-4
uses: r-lib/actions/setup-r@v2
with:
r-version: oldrel-4
install-r: false

- name: Checkout GitHub repo
uses: rstudio/shiny-workflows/.github/internal/checkout@v1

# R is a pre-installed software
- name: Config
id: config
shell: Rscript {0}
run: |
mac <- "${{ inputs.macOS }}"
windows <- "${{ inputs.windows }}"
ubuntu <- strsplit("${{ inputs.ubuntu }}", "[[:space:],]+")[[1]]
has_src <- dir.exists("src")
min_r_ver <- "${{ inputs.minimum-r-version }}"
test_on_rtools35 <- identical("${{ inputs.rtools-35 }}", "true")
test_on_rtools40 <- identical("${{ inputs.rtools-40 }}", "true")
force_windows_src <- identical("${{ inputs.force-windows-src }}", "true")
if (force_windows_src) has_src <- TRUE
rver <- list(
# devel = "${{ steps.devel.outputs.installed-r-version }}",
# When R 4.3 was released, R version 4.4.0 was not recognized.
# However, `"devel"` is recognized within `r-lib/actions/setup-r`.
devel = "devel",
release = "${{ steps.release.outputs.installed-r-version }}",
oldrel1 = "${{ steps.oldrel-1.outputs.installed-r-version }}",
oldrel2 = "${{ steps.oldrel-2.outputs.installed-r-version }}",
oldrel3 = "${{ steps.oldrel-3.outputs.installed-r-version }}",
oldrel4 = "${{ steps.oldrel-4.outputs.installed-r-version }}"
)
job <- function(os, r, ...) {
list(os = os, r = r, ...)
}
is_valid_os <- function(os, r_ver = "") {
if (identical(os, "false")) return(FALSE)
if (identical(os, "")) return(FALSE)
if (any(nchar(c(r_ver, min_r_ver)) == 0)) return(TRUE)
if (identical(r_ver, "devel")) return(TRUE)
r_ver >= min_r_ver
}
config <- c(
list(
if (is_valid_os(mac, rver$release)) job(mac, rver$release),
if (has_src && is_valid_os(windows, "devel")) job(windows, "devel", "rtools-version" = "44"),
if (is_valid_os(windows, rver$release)) job(windows, rver$release, "rtools-version" = "43"),
if (has_src && is_valid_os(windows, "4.2")) job(windows, "4.2", "rtools-version" = "42"),
if (has_src && test_on_rtools40 && is_valid_os(windows, "4.1")) job(windows, "4.1"),
if (has_src && test_on_rtools35 && is_valid_os(windows, "3.6")) job(windows, "3.6"),
if (is_valid_os(ubuntu, rver$devel)) job(ubuntu[[1]], rver$devel, "http-user-agent" = "release")
),
if (is_valid_os(ubuntu))
unlist(recursive = FALSE, lapply(ubuntu, function(ubuntu_) {
list(
if (is_valid_os(ubuntu_, rver$release)) job(ubuntu_, rver$release),
if (is_valid_os(ubuntu_, rver$oldrel1)) job(ubuntu_, rver$oldrel1),
if (is_valid_os(ubuntu_, rver$oldrel2)) job(ubuntu_, rver$oldrel2),
if (is_valid_os(ubuntu_, rver$oldrel3)) job(ubuntu_, rver$oldrel3),
if (is_valid_os(ubuntu_, rver$oldrel4)) job(ubuntu_, rver$oldrel4)
)
}))
)
## Drop NULLs
config <- config[!vapply(config, is.null, logical(1))]
## Convert to JSON manually to save 10s installing `jsonlite`
join_and_wrap <- function(x, start, end, sep = ",") {
paste0(start, paste0(x, collapse = sep), end)
}
entries_json <- vapply(config, character(1), FUN = function(entry) {
join_and_wrap(
paste0("\"", names(entry), "\":\"", unname(entry), "\""),
"{", "}"
)
})
config_json <- join_and_wrap(entries_json, "[", "]")
cat("Config:\n", config_json, "\n", sep = "")
cat("config=", config_json, "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

needs: [setup]
strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
config: ${{ fromJSON(needs.setup.outputs.config) }}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2
- name: Checkout GitHub repo
uses: rstudio/shiny-workflows/.github/internal/checkout@v1

- uses: r-lib/actions/setup-r@v2
- name: Install R, system dependencies, and package dependencies
uses: rstudio/shiny-workflows/setup-r-package@v1
with:
rtools-version: ${{ matrix.config.rtools-version }}
pandoc-version: ${{ inputs.pandoc-version }}
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
cache-version: ${{ inputs.cache-version }}
needs: check
extra-packages: |
any::rcmdcheck
${{ inputs.extra-packages }}
- uses: r-lib/actions/setup-r-dependencies@v2
- name: Check package
uses: r-lib/actions/check-r-package@v2
timeout-minutes: 30
with:
extra-packages: any::rcmdcheck
needs: check
check-dir: '"check"' # matches directory below
args: 'c(${{ inputs.extra-check-args }}, "--no-manual", "--as-cran")'

- uses: r-lib/actions/check-r-package@v2
- name: "Show `testthat` output"
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
- name: "Show install logs"
if: always()
run: find check -name '00install.out' -exec cat '{}' \; || true
shell: bash
- name: "Upload 'Check package' results"
if: failure()
uses: actions/upload-artifact@main
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results
path: "check"
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ knitr::opts_chunk$set(
<!-- badges: end -->


The goal of lzstringr is to provide an R wrapper for the [lzstring C++ library](https://github.com/andykras/lz-string-cpp). [lzstring](https://github.com/pieroxy/lz-string) is originally a JavaScript library that provides fast and efficient string compression and decompression using a [LZ-based algorithm](https://en.wikipedia.org/wiki/Lempel–Ziv–Welch). Credit goes to [Winston Chang](https://github.com/wch) for spotting this missing R package and doing the majority of the work over at the R Shinylive repo—check out his awesome contributions which this repo is based on [here](https://github.com/posit-dev/r-shinylive/issues/70) and [here](https://github.com/posit-dev/r-shinylive/pull/71). Also, shoutout to Andy Kras for his implementation in C++ of lzstring, which you can find right [here](https://github.com/andykras/lz-string-cpp), and [pieroxy](https://github.com/pieroxy), the original brain behind lzstring in JavaScript—peek at his work over [here](https://github.com/pieroxy/lz-string).
The goal of lzstringr is to provide an R wrapper for the [lzstring C++ library](https://github.com/andykras/lz-string-cpp). [lzstring](https://github.com/pieroxy/lz-string) is originally a JavaScript library that provides fast and efficient string compression and decompression using a [LZ-based algorithm](https://en.wikipedia.org/wiki/Lempel–Ziv–Welch). Credit goes to [Winston Chang](https://github.com/wch) for spotting this missing R package and guiding me over at the R Shinylive repo—check out his awesome contributions which this repo is based on [here](https://github.com/posit-dev/r-shinylive/issues/70) and [here](https://github.com/posit-dev/r-shinylive/pull/71). Also, shoutout to Andy Kras for his implementation in C++ of lzstring, which you can find right [here](https://github.com/andykras/lz-string-cpp), and [pieroxy](https://github.com/pieroxy), the original brain behind lzstring in JavaScript—peek at his work over [here](https://github.com/pieroxy/lz-string).

## Installation

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ JavaScript library that provides fast and efficient string compression
and decompression using a [LZ-based
algorithm](https://en.wikipedia.org/wiki/Lempel–Ziv–Welch). Credit goes
to [Winston Chang](https://github.com/wch) for spotting this missing R
package and doing the majority of the work over at the R Shinylive
repo—check out his awesome contributions which this repo is based on
package and guiding me over at the R Shinylive repo—check out his
awesome contributions which this repo is based on
[here](https://github.com/posit-dev/r-shinylive/issues/70) and
[here](https://github.com/posit-dev/r-shinylive/pull/71). Also, shoutout
to Andy Kras for his implementation in C++ of lzstring, which you can
Expand Down

0 comments on commit 2305764

Please sign in to comment.