Skip to content

feat: add R language support#8263

Draft
rubenfiszel wants to merge 5 commits intomainfrom
r-language-support
Draft

feat: add R language support#8263
rubenfiszel wants to merge 5 commits intomainfrom
r-language-support

Conversation

@rubenfiszel
Copy link
Contributor

@rubenfiszel rubenfiszel commented Mar 7, 2026

Summary

Add R as a new supported scripting language in Windmill, following the Ruby executor pattern. Users can write R scripts with main() functions, use library()/require() for dependencies (auto-detected and installed from CRAN), and access Windmill variables/resources via built-in helpers.

Changes

  • Backend types: Rlang variant in ScriptLang enum, DB migration, worker tags
  • Parser (windmill-parser-r): tree-sitter-r based parser for main() signature extraction and library()/require() dependency detection
  • WASM parser: parse_r binding for frontend schema inference
  • Executor (r_executor.rs): Full resolve → install → run pipeline
    • Dependency resolution: extracts packages from code, queries CRAN for versions, caches lockfiles in DB (3-day TTL)
    • Package installation: installs to shared cache dir (R_CACHE_DIR/r_site_library/), skips already-installed versions
    • Execution: wraps user code with jsonlite-based arg passing and result serialization
    • Windmill client library: get_variable() and get_resource() using base R url() + readLines()
  • NSJail sandboxing: Separate configs for resolve, install, and run phases; # sandbox annotation support for per-script sandboxing
  • Frontend: Language picker, R icon, Monaco editor integration, syntax highlighting, editor bar actions (variable/resource/env insertion), JS fallback parser for arg inference when WASM is unavailable
  • CLI: R file extension support, bootstrap template, sync support
  • E2E tests: test_r_job, test_r_get_variable, test_r_get_resource

Test plan

  • cargo check --features rlang — compiles cleanly
  • cargo test -p windmill-parser-r — 9 parser tests pass
  • cargo test --features rlang test_r_job — basic R execution works
  • cargo test --features rlang test_r_get_variable — variable fetching works
  • cargo test --features rlang test_r_get_resource — resource fetching works
  • npm run check:fast — frontend types pass
  • Manual: create R script in UI, verify language picker, editor, and execution
  • CI: WASM parser build (requires nightly + wasm-pack)

Generated with Claude Code

Add R as a new supported scripting language in Windmill, following the
same pattern used for Ruby. Includes:

- Backend: ScriptLang::Rlang enum variant, DB migration, tree-sitter-r
  parser crate with tests, WASM parser binding, R executor with NSJail
  sandboxing, job dispatch and signature parsing
- Frontend: language picker, R icon, syntax highlighting, editor bar
  insertions (Sys.getenv, get_variable, get_resource), schema inference,
  init code template, BETA badge
- CLI: .r extension mapping, sync support, bootstrap template

R scripts use `main <- function(...)` syntax, jsonlite for JSON
serialization, and system curl for the Windmill client helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 7, 2026

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: f9b91fb
Status:🚫  Build failed.

View logs

rubenfiszel and others added 4 commits March 7, 2026 17:11
Parse library()/require() calls from R scripts to extract dependencies.
Resolve versions from CRAN, cache lockfiles in pip_resolution_cache,
and install packages to a shared R library cache. The run step sets
R_LIBS_USER so installed packages are available to the script.

- Parser: parse_r_requirements() extracts package names from AST
- Executor: resolve() generates lockfile, install() installs from CRAN
- Worker lockfiles: wire up R resolve for dependency jobs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…_resource

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant