Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'scripts/prepare-sess.js'
# Arity file discovery honours .gitignore.
- '.gitignore'
- '.github/workflows/r.yml'
Expand All @@ -29,6 +30,44 @@ permissions:
contents: read

jobs:
coverage-sess:
name: sess coverage
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
- uses: r-lib/actions/setup-r@f9a764fea8d5c63df6ef9a5c7795bf7deb5d7e05 # v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@f9a764fea8d5c63df6ef9a5c7795bf7deb5d7e05 # v2
with:
working-directory: sess
# Include sess Suggests so optional package tests contribute coverage.
extra-packages: |
any::remotes
any::xml2
- name: Install covr 4.0.0
# covr 4.0.0 Suggests itself, which conflicts with an exact pak pin
# when setup-r-dependencies includes all suggested dependencies.
run: remotes::install_version("covr", version = "4.0.0", dependencies = NA, upgrade = "never")
shell: Rscript {0}
- name: Prepare sess package
run: node scripts/prepare-sess.js
- name: Measure sess coverage
run: Rscript --vanilla scripts/coverage-sess.R
- name: Upload sess coverage report and test logs
if: ${{ !cancelled() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: sess-coverage
path: dist/coverage/sess
if-no-files-found: ignore
retention-days: 14

format:
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ Rscript -e 'tinytest::test_package("sess")'

`pnpm run build` installs the bundled sess and its dependencies, including suggested packages, into the selected R library. jgd checks need the jgd and systemfonts packages; standard graphics uses svglite or PNG. Runtime suites build private pure R sess installations and use disposable sessions/libraries. Keep `R_LIBS` set for the commands below.

To measure sess coverage, install covr 4.0.0 and xml2 in the same test library:

```sh
Rscript -e 'remotes::install_version("covr", version = "4.0.0", dependencies = NA, upgrade = "never"); install.packages("xml2")'
pnpm run coverage:sess
```

The command prepares a disposable sess bundle and runs its tinytest suite under covr. Open `dist/coverage/sess/report.html` to inspect uncovered code; keep the adjacent `lib` directory with the HTML report. The output also includes Cobertura XML, an R coverage object and test logs. The R workflow runs this check on Ubuntu and uploads the full directory as `sess-coverage`, with the line coverage percentage in the job summary. Test or tooling failures fail the check; there is no minimum coverage percentage. Install sess's suggested packages for a comparable local result. This measures the R package tests; separate extension and arf runtime tests do not contribute to this report, and platform-specific paths can remain uncovered.

```sh
pnpm run test:interactive
ARF_PATH=/path/to/arf pnpm run test:interactive
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,7 @@
"test:sess-identity": "Rscript --vanilla R/tests/sess_source.R",
"test:sess-attach": "Rscript --vanilla R/tests/attach_sess.R",
"test:sess-source": "node --test scripts/sess-source.test.js && pnpm run test:sess-identity && pnpm run test:sess-attach",
"coverage:sess": "node scripts/prepare-sess.js && Rscript --vanilla scripts/coverage-sess.R",
"test:tool-library": "Rscript --vanilla R/tests/tool-library.R",
"test:tool-consent": "Rscript --vanilla R/tests/tool-consent.R",
"test:prepare-jgd": "Rscript --vanilla R/tests/prepare-jgd.R",
Expand Down
32 changes: 32 additions & 0 deletions scripts/coverage-sess.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Run from the repository root after node scripts/prepare-sess.js.
if (!requireNamespace("covr", quietly = TRUE) || utils::packageVersion("covr") != "4.0.0") {
stop("sess coverage requires covr 4.0.0; see CONTRIBUTING.md for setup instructions.")
}
# The package's test runner skips tests when tinytest is absent.
for (package in c("tinytest", "htmltools", "xml2")) {
loadNamespace(package)
}

output_dir <- file.path("dist", "coverage", "sess")
unlink(output_dir, recursive = TRUE)
dir.create(output_dir, recursive = TRUE)
coverage <- covr::package_coverage(
path = file.path("dist", "resources", "sess"),
type = "tests",
outDir = file.path(normalizePath(output_dir), "tests"),
allow_failures = FALSE
)
print(coverage)
saveRDS(coverage, file.path(output_dir, "coverage.rds"))
covr::cobertura(coverage, file = file.path(output_dir, "cobertura.xml"))
covr::report(coverage, file = file.path(output_dir, "report.html"), browse = FALSE)

summary <- sprintf(
"sess line coverage (covr 4.0.0): %.2f%%\n\nSee the sess-coverage artifact for the HTML report, coverage data and test logs.\n",
covr::percent_coverage(coverage, by = "line")
)
cat(summary)
summary_file <- Sys.getenv("GITHUB_STEP_SUMMARY")
if (nzchar(summary_file)) {
cat(summary, file = summary_file, append = TRUE)
}
Loading