Merge pull request #2 from tmelliott/feature/ci

Add github CI
This commit is contained in:
Tom Elliott 2025-01-22 21:23:18 +13:00 committed by GitHub
commit 4a21b0f763
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 101 additions and 19 deletions

View File

@ -1,3 +1,5 @@
^LICENSE\.md$
^README\.Rmd$
^Makefile$
node_modules
^\.github$

1
.github/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.html

29
.github/workflows/R-CMD-check.yaml vendored Normal file
View File

@ -0,0 +1,29 @@
# 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, pull_request]
name: R CMD check
permissions: read-all
jobs:
R-CMD-check:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

42
.github/workflows/check-demo.yaml vendored Normal file
View File

@ -0,0 +1,42 @@
# 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, pull_request]
name: Check demo
permissions: read-all
jobs:
run-sampler:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck, local::.
needs: check
- uses: pnpm/action-setup@v4
with:
version: 9.12
# the rest of this must run from tests/testthat/sampler
- run: pnpm install --frozen-lockfile
working-directory: tests/testthat/sampler
- run: pnpm build
working-directory: tests/testthat/sampler
- name: Start Rserve
run: pnpm rserve &
working-directory: tests/testthat/sampler
- run: pnpm start
working-directory: tests/testthat/sampler

View File

@ -10,11 +10,9 @@ License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
Imports:
cli,
js,
rlang,
Rserve
Suggests:
testthat (>= 3.0.0)

View File

@ -8,6 +8,9 @@ document:
install: document
R CMD INSTALL .
check:
Rscript -e "devtools::check()"
README.md: README.Rmd install
Rscript -e "rmarkdown::render('README.Rmd')"
@rm README.html

View File

@ -50,10 +50,6 @@ ts_compile.character <- function(
sprintf("export default {\n %s\n};", paste(ls(e), collapse = ",\n "))
)
# if (file != "" && file.exists(file)) {
# stop(sprintf("File exists: %s", file))
# return()
# }
cat(src, file = file, sep = "\n")
invisible()

View File

@ -82,19 +82,18 @@ ts_function <- function(f, ..., result = ts_void()) {
}
#' @export
print.ts_function <- function(x, ...) {
cli::cli_h3("Ocap function")
h3("Ocap function")
cli::cli_text("Arguments:")
cat("Arguments:\n")
args <- lapply(x$args, \(z) z$input_type)
lapply(names(args), \(n) {
cat("- ", n, ": ", args[[n]], "\n", sep = "")
})
cli::cli_text("\n\n")
cat("\n\n")
cli::cli_text("Return type:")
cat("Return type:\n")
cat(x$result$return_type)
}

9
R/helpers.R Normal file
View File

@ -0,0 +1,9 @@
h3 <- function(x) {
cat("\n---", x, "\n")
}
# TODO: figure out how to format (modern) JS code from R?
format_js <- function(x) {
x
}

View File

@ -27,21 +27,20 @@ ts_object <- function(input_type = "any",
#' @export
print.ts_object <- function(x, ...) {
# name <- deparse(substitute(x))
cli::cli_ul()
cli::cli_h3("Input type: ")
h3("Input type: ")
if (nchar(x$input_type) > 50) {
cat(js::uglify_reformat(x$input_type, beautify = TRUE), "\n")
cat(format_js(x$input_type), "\n")
} else {
cat(x$input_type, "\n")
}
cli::cli_h3("Return type: ")
h3("Return type: ")
if (nchar(x$return_type) > 50) {
print(x$return_type)
cat(js::uglify_reformat(x$return_type, beautify = TRUE), "\n")
cat(format_js(x$return_type), "\n")
} else {
cat(x$return_type, "\n")
}
cli::cli_end()
cat("\n")
}
#' @describeIn ts_object Check if an object is a ts object

View File

@ -16,6 +16,8 @@ knitr::opts_chunk$set(
# ts
<!-- badges: start -->
[![R-CMD-check](https://github.com/tmelliott/ts/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tmelliott/ts/actions/workflows/R-CMD-check.yaml)
[![Demo](https://github.com/tmelliott/ts/actions/workflows/check-demo.yaml/badge.svg)](https://github.com/tmelliott/ts/actions/workflows/check-demo.yaml)
<!-- badges: end -->
The **ts** package makes it easy for users to write functions that can be used in [**rserve-ts**](https://www.npmjs.com/package/rserve-ts) applications.

View File

@ -5,6 +5,8 @@
<!-- badges: start -->
[![R-CMD-check](https://github.com/tmelliott/ts/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tmelliott/ts/actions/workflows/R-CMD-check.yaml)
[![Demo](https://github.com/tmelliott/ts/actions/workflows/check-demo.yaml/badge.svg)](https://github.com/tmelliott/ts/actions/workflows/check-demo.yaml)
<!-- badges: end -->
The **ts** package makes it easy for users to write functions that can