Skip to content

Commit 1827584

Browse files
authored
fix: use uvr run instead of bare Rscript in CI/justfile (#32)
uvr r install downloads R to ~/.uvr/r-versions/ but never puts it on PATH - CI's "Rscript: command not found" (exit 127) on both the test and docs-build steps, since the previous migration removed r-lib/actions/setup-r and nothing else provided an Rscript binary. This worked locally only by coincidence: this machine's separate system R happened to already be the same pinned version. scripts/run-tests.R wraps testthat::test_dir()/test_file() (uvr run only accepts a script file, not an inline -e expression) so the test recipe becomes `uvr run scripts/run-tests.R`, matching gen-rd.R's existing `uvr run scripts/gen-rd.R` pattern - both now run via uvr's own R resolution instead of depending on PATH at all. Updated in justfile, ci.yml, and CLAUDE.md's single-test-file command. Verified locally: `uvr run scripts/run-tests.R` (and with -- <file> for a single test) and `just docs-build`'s full 13-page render both pass. Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent f225ac1 commit 1827584

5 files changed

Lines changed: 28 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ jobs:
5555
run: jarl check .
5656

5757
- name: Run tests with testthat
58-
run: Rscript -e "testthat::test_dir('src/package_name/__tests__')"
58+
run: uvr run scripts/run-tests.R

.github/workflows/generate-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
- name: Generate API reference (box + rd2qmd)
4444
run: |
45-
Rscript scripts/gen-rd.R
45+
uvr run scripts/gen-rd.R
4646
rm -rf docs/reference && mkdir -p docs/reference
4747
rd2qmd man/ -f md -o docs/reference/
4848
rm -rf man

CLAUDE.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ just install # uvr r install $(cat .r-version) && uvr sync — installs R i
1818
just update # uvr update — bump deps to latest allowed versions
1919
just lint # jarl check .
2020
just format # r-air format --check . (drop --check to auto-fix: r-air format .)
21-
just test # Rscript -e "testthat::test_dir('src/package_name/__tests__')"
22-
just docs-build # scripts/gen-rd.R + rd2qmd generate docs/reference/*.md, then `quarto render docs/` builds docs/html
21+
just test # uvr run scripts/run-tests.R
22+
just docs-build # uvr run scripts/gen-rd.R + rd2qmd generate docs/reference/*.md, then `quarto render docs/` builds docs/html
2323
just pre-commit-install # one-time: installs pre-commit + pre-push + commit-msg hooks via prek
2424
just pre-commit # prek run --all-files --hook-stage pre-push
2525
```
2626

27-
Run a single test file directly: `Rscript -e "testthat::test_file('src/package_name/__tests__/test-hello.R')"`.
27+
Run a single test file directly: `uvr run scripts/run-tests.R -- src/package_name/__tests__/test-hello.r`.
2828

2929
CI (`.github/workflows/ci.yml`) runs, in order: `air format --check .`, `jarl check .`, then the testthat suite.
3030
Match that order locally before pushing.
@@ -42,7 +42,7 @@ There is no `library()`/`require()` for internal code — everything is `box::us
4242
test directory can be run either via `testthat::test_dir()` directly or by `box::use()`-ing it as a module.
4343
- `__tests__/helper-module.r` does `box::use(.. / hello[...])` to pull the parent module's exports into scope
4444
for the tests — add an equivalent `box::use()` line here when testing a new sibling module.
45-
- New test files follow the `test-<module>.R` naming convention testthat expects.
45+
- New test files follow the `test-<module>.r` naming convention testthat expects.
4646

4747
**`docs/` is a single hand-authored Quarto website** (`docs/_quarto.yml`, see ADR-004) that combines the root
4848
README (`docs/index.qmd` includes it via `{{< include _readme.md >}}`), the architecture/ADR markdown
@@ -65,13 +65,15 @@ Note: ADR-002 covers running Git hooks via `prek`, a dependency-free Rust binary
6565
site structure. ADR-006 covers `uvr` vs `rv` (superseding ADR-003) for R dependency management.
6666

6767
**`uvr` (via `uvr.toml` / `uvr.lock` / `.r-version`) manages both R itself and R dependencies** — installs the
68-
pinned R version (`uvr r install $(cat .r-version)`) and syncs packages into `.uvr/library`, which a small
69-
`uvr`-managed block in `.Rprofile` adds to `.libPaths()` automatically, so plain `Rscript`/interactive R
70-
sessions see the project library with no wrapper needed. Unlike `rv`, `uvr` has native dev-only dependency
71-
support — tooling deps (`languageserver`, `testthat`, `roxygen2`) live in `uvr.toml`'s `[dev-dependencies]`,
72-
separate from runtime deps in `[dependencies]`. `rd2qmd` (used by `docs-build`) and Git hooks (`prek`, via
73-
`.pre-commit-config.yaml`) are standalone Rust binaries installed outside uvr — no Python/uv install required
74-
for either.
68+
pinned R version (`uvr r install $(cat .r-version)`) and syncs packages into `.uvr/library`. `uvr r install`
69+
does *not* put R on `PATH`, so scripts here run through `uvr run <script>` (e.g. `scripts/run-tests.R`,
70+
`scripts/gen-rd.R`) rather than bare `Rscript``uvr run` finds the right R itself, no PATH needed. A small
71+
`uvr`-managed block in `.Rprofile` still adds `.uvr/library` to `.libPaths()` automatically for interactive/IDE
72+
sessions that already have *some* R on `PATH` (the devcontainer symlinks the pinned R to `/usr/local/bin/R`
73+
for exactly this). Unlike `rv`, `uvr` has native dev-only dependency support — tooling deps
74+
(`languageserver`, `testthat`, `roxygen2`) live in `uvr.toml`'s `[dev-dependencies]`, separate from runtime
75+
deps in `[dependencies]`. `rd2qmd` (used by `docs-build`) and Git hooks (`prek`, via `.pre-commit-config.yaml`)
76+
are standalone Rust binaries installed outside uvr — no Python/uv install required for either.
7577

7678
**Releases** are automated via `release-please` (conventional commits → version bump in `uvr.toml`, `NEWS.md`,
7779
`.release-please-manifest.json`). Commit messages must follow Conventional Commits (enforced by a commit-msg

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ format:
3131

3232
# Run testthat
3333
test:
34-
Rscript -e "testthat::test_dir('src/package_name/__tests__')"
34+
uvr run scripts/run-tests.R
3535

3636
# Build docs (box's own doc parser generates .Rd, rd2qmd converts, Quarto renders the docs/ website)
3737
docs-build:
38-
Rscript scripts/gen-rd.R
38+
uvr run scripts/gen-rd.R
3939
rm -rf docs/reference && mkdir -p docs/reference
4040
rd2qmd man/ -f md -o docs/reference/
4141
rm -rf man

scripts/run-tests.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env Rscript
2+
# Run the testthat suite. With no args, runs the whole __tests__ dir; with a
3+
# file path arg (after `--` when invoked via `uvr run`), runs just that file.
4+
5+
args <- commandArgs(trailingOnly = TRUE)
6+
7+
if (length(args) > 0) {
8+
testthat::test_file(args[[1]])
9+
} else {
10+
testthat::test_dir("src/package_name/__tests__")
11+
}

0 commit comments

Comments
 (0)