Add testthat-module reusable workflow - #44
Merged
Merged
Conversation
Runs a SpaDES module's testthat suite. It is render-module-rmd.yaml with the render and commit jobs replaced by a test run; everything above them is deliberately identical, so a fix to one is a fix to both. There is no commit job, and the omission is load-bearing: the workflow runs convertToPackage(), which rewrites a module and is not reversible, so nothing it produces may be pushed back to the repository. The module is tested as a package. A module keeps its functions inline in <module>.R, so without conversion they are only ever parsed into a simList and a test cannot call one directly. convertToPackage(destinationPath = ) builds the rendition in a throwaway directory and the tests run against a real namespace. Verified end to end locally: a test calling myHelper(3L) directly passes. A module with no tests reports that and passes rather than failing. Almost every module currently carries only the dead newModule() scaffolding, and failing hard would paint the family red for the absence of tests rather than for a defect. Coverage goes to the job summary rather than codecov: module repositories have no CODECOV_TOKEN and no codecov.yml, and ~28 modules with near-zero tests would create 28 projects reading 0-5% with no history for the target: auto ratchet to compare against. Carries a temporary step installing SpaDES.core@development, because install-SpaDES installs the released SpaDES.core which lacks convertToPackage(destinationPath = ) and moduleCoverage(). Remove once released. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0125hLaqRWaPcutdboenVK2g
testthat runs with the working directory set to tests/testthat, so the module directory is two levels up and SpaDES.core's modulePath -- the directory containing modules -- is three, not one. Getting this wrong is silent: the module is simply not found and tests fail on something unrelated. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0125hLaqRWaPcutdboenVK2g
pkgload, roxygen2, testthat, covr and withr are only in SpaDES.core's
Suggests, so install-SpaDES does not provide them. The pilot run on
fireSense_EscapeFit#4 died in convertToPackage() before any test ran:
requireNamespace("pkgload", quietly = TRUE) is not TRUE.
render-module-rmd gets its tools from install-Rmd-pkgs; this is the
counterpart that was missing when the render job was replaced.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0133867aFrmKtbhpNXasToP9
eliotmcintire
added a commit
to PredictiveEcology/fireSense_EscapeFit
that referenced
this pull request
Sep 10, 2026
PredictiveEcology/actions#44 merged and its branch was deleted, so the @feat/testthat-module-workflow ref no longer resolves. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0133867aFrmKtbhpNXasToP9
This was referenced Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Runs a SpaDES module's testthat suite. This is the CI half of the module release wave — until now only the 6 CBM modules ran tests in CI, via a workflow that depended on a personal fork; the other ~200 module repos either render an Rmd or have no workflow at all.
It is
render-module-rmd.yamlwith two jobs swapped outEverything above the render step — spatial system deps, the apt retry wrapper,
install-Require,install-SpaDES, and dependency resolution straight from the module's ownreqdPkgsviaSpaDES.core::packages()— is deliberately identical, so a fix to one is a fix to both. That includes the hard-won details: the-reusableconcurrency suffix (#33),GITHUB_PATon the job, single-indexingpackages(...)[[1]], and[skip-ci]read fromhead_commit(#34).There is no commit job, and the omission is load-bearing. The workflow runs
convertToPackage(), which rewrites a module and is not reversible. Nothing it produces may be pushed back. Since it is a near-copy of a workflow that does commit, this is called out in the file itself so nobody restores it by symmetry.Three decisions
The module is tested as a package. A module keeps its functions inline in
<module>.R, so without conversion they are only parsed into asimListand a test cannot call one directly — you would writesim@.xData$.mods$myModule$myHelper(3L).convertToPackage(destinationPath = )builds the rendition in a throwaway directory, leaving the module untouched, and the tests run against a real namespace, soexpect_equal(myHelper(3L), 6L)works as in any package. Verified end to end locally.A module with no tests passes. Almost every module currently carries only the dead
newModule()scaffolding (test-template.RwithC:/Users/yonluo/...paths). Failing hard would paint the whole family red for the absence of tests rather than for a defect. The workflow reports "no tests" in the job summary and exits clean.Coverage goes to the job summary, not codecov. Module repos have no
CODECOV_TOKENand nocodecov.yml, and ~28 modules with near-zero tests would create 28 projects reading 0–5% with no history for the housetarget: autoratchet to compare against.SpaDES.core::moduleCoverage()reports against<module>.Rrather than the generatedR/copy — see PredictiveEcology/SpaDES.core#441.One temporary step
install-SpaDESinstalls the released SpaDES.core, which does not haveconvertToPackage(destinationPath = )ormoduleCoverage()(SpaDES.core #440 and #441, both merged todevelopment). Until a release carries them, the workflow installsSpaDES.core@developmentexplicitly. The step is commented as removable and names the PRs.Also added
examples/testthat-module.caller.yaml— the call siteexamples/module-tests-setup.R— a startingtests/testthat/setup.Rfor a module, which sets options and a scratch tree and deliberately installs nothingNot yet done
This has not run against a real module. I intend to pilot it on one small module (
historicFires) before rolling callers out to the wave, rather than opening 28 PRs against an untested workflow.🤖 Generated with Claude Code
https://claude.ai/code/session_0125hLaqRWaPcutdboenVK2g