Skip to content

Package housekeeping: R CMD check clean, silent tests, GHA CI#70

Merged
smjenness merged 6 commits intomainfrom
chore/package-housekeeping
Apr 20, 2026
Merged

Package housekeeping: R CMD check clean, silent tests, GHA CI#70
smjenness merged 6 commits intomainfrom
chore/package-housekeeping

Conversation

@smjenness
Copy link
Copy Markdown
Contributor

@smjenness smjenness commented Apr 20, 2026

Addresses three package-hygiene items before resuming the duration/dissolution work on #63.

1. R CMD check: (1 WARNING, 3 NOTES) → (0, 0, 0)

Issue Fix
WARNING: undocumented build_epistats arg race.level Add @param race.level with the allowed category values
NOTE: race.cat.num undefined global Add to utils::globalVariables() in R/globals.R (dplyr::select(d, race.cat.num, ...) was flagged)
NOTE: hidden file inst/validation/snapshots/.gitkeep in build .Rbuildignore the inst/validation/snapshots directory
NOTE: non-standard top-level CLAUDE.md .Rbuildignore CLAUDE.md and .github/

Final check:

── R CMD check results ─────────────────────────────────────── ARTnet 2.9.0 ────
Duration: 31.3s
0 errors ✔ | 0 warnings ✔ | 0 notes ✔

2. Silent tabular testthat output

Root cause: tests/testthat/test-workflow-{standard,cea}.R were full ERGM estimation scripts — netest() + netdx() + print() + plot() — running as bare scripts (no test_that() wrapping). testthat executes every .R file in tests/testthat/ as test code, so they spewed hundreds of lines of SAN / MCMC progress per run.

Moved to tests/workflows/workflow-{standard,cea}.R with a tests/workflows/README.md explaining they're manual integration scripts. testthat::test_local() and the tests/testthat.R runner invoked by R CMD check only scan tests/testthat/, so the move cleanly excludes them without deleting functionality.

Also cleaned up a stale Rplots.pdf artifact from those scripts' plot() calls and added Rplots.pdf to .gitignore.

Before/after:

# Before: garbage for RStudio's test panel
⠏ |          0 | workflow-cea
Starting simulated annealing (SAN)
Iteration 1 of at most 3
...
[several hundred more lines per run]

# After: clean table
✔ |         77 | joint-dyad  [1.9s]
✔ |         78 | joint-model [1.3s]
✔ |         29 | joint-netstats [2.0s]
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 184 ]     Duration: 5.3s

3. GitHub Actions CI for R CMD check

.github/workflows/R-CMD-check.yaml using the standard r-lib/actions template. Single-OS matrix (ubuntu-latest, R release) because ARTnet isn't CRAN-published — no need to burn minutes testing multi-OS portability. Runs on push to main, PRs targeting main, and manual dispatch.

ARTnetData in CI: installed, not skipped

ARTnetData IS the package's reason to exist, so tests that exercise it must run in CI. The default GITHUB_TOKEN can't see private repos in the same org, so the workflow uses a user-configured secret EPIMODEL_PAT.

One-time setup required in repo settings (commit 49b016e):

  1. Create a fine-grained PAT with Contents: Read scoped to:
    • EpiModel/ARTnetData
    • EpiModel/EpiModelHIV-p
  2. Add it to EpiModel/ARTnet → Settings → Secrets and variables → Actions → New repository secret, named EPIMODEL_PAT.

After that, CI installs both private packages, runs the full testthat suite including all joint-model / joint-dyad / joint-netstats tests, and runs R CMD check end-to-end. Suggests-gated skip_without_artnetdata() guards in tests stay in place as defensive no-ops (they skip gracefully in local dev if ARTnetData isn't installed, but never fire in CI once the secret is configured).

README gets a status badge linking to the workflow runs.

Test plan

  • Local devtools::check(): 0 errors / 0 warnings / 0 notes
  • Local devtools::test(): 184/184 pass, clean tabular output
  • First CI run on this PR fails at dependency resolution (expected — EPIMODEL_PAT secret not yet configured)
  • After EPIMODEL_PAT is added to repo secrets: re-run the workflow; should go green end-to-end with all ARTnetData-dependent tests actually executing

Bookkeeping only — no user-facing behavior changes. Byte-identical output for build_netparams() / build_netstats() is preserved and still verified by the inst/validation/ snapshot harness locally.

smjenness and others added 6 commits April 19, 2026 21:43
R CMD check goes from (1 WARNING, 3 NOTEs) to (0 errors, 0 warnings,
0 notes):

- WARNING: undocumented build_epistats argument race.level is now
  described with a proper @param roxygen tag.
- NOTE: race.cat.num added to the globalVariables list in globals.R
  (dplyr::select(d, race.cat.num, ...) in build_epistats was being
  flagged as an unresolved symbol by the code-analysis checker).
- NOTE: inst/validation/snapshots is .Rbuildignore'd so the local
  .gitkeep doesn't ship in the built tarball.
- NOTE: CLAUDE.md and .github/ are .Rbuildignore'd as non-standard
  top-level files / infra.

Testthat is now silent and tabular. The two test-workflow-*.R files
in tests/testthat/ were actually full end-to-end ERGM estimation
scripts (netest + netdx + print + plot) that ran as bare scripts
under testthat — not test_that() blocks — and produced hundreds of
lines of MCMC / SAN progress output per run. Moved to tests/workflows/
with a README.md explaining they are manual integration scripts.
testthat::test_local() and the tests/testthat.R runner invoked by
R CMD check only scan tests/testthat/, so they're excluded cleanly.

After the move, testthat on-load output is clean:

  ✔ | F W S  OK | Context
  ✔ |         77 | joint-dyad
  ✔ |         78 | joint-model
  ✔ |         29 | joint-netstats

  [ FAIL 0 | WARN 0 | SKIP 0 | PASS 184 ]    Duration: 5.3s

Also removed stale tests/testthat/Rplots.pdf (from the old workflow
scripts' plot() calls) and added Rplots.pdf to .gitignore.

GitHub Actions CI added at .github/workflows/R-CMD-check.yaml based
on the standard r-lib/actions template. Matrix covers
ubuntu-latest x (release, devel, oldrel-1), plus macos-latest and
windows-latest on release. ARTnetData is private and not installed
in CI — the package's build_* functions guard on its presence and
the test suite skips when absent, so CI runs fast without needing
a PAT. README.md gets a status badge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ARTnet is not CRAN-published, so the full (5-OS × 3-R-version) portability
matrix is overkill. Drop to a single Linux runner on R release — covers
the 95% case and keeps CI runs fast and cheap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Skipping ARTnetData-dependent tests in CI was the wrong call —
ARTnetData IS the package's reason to exist, and skipping means CI
would miss regressions in the main code paths.

The default GITHUB_TOKEN provided to Actions is scoped to the repo
where the workflow runs, so it can't see private repos in the same
org (EpiModel/ARTnetData, EpiModel/EpiModelHIV-p). Workflow now
reads a user-configured secret EPIMODEL_PAT instead.

One-time setup needed in the repo settings:
1. Create a fine-grained PAT with Contents: Read on
   EpiModel/ARTnetData and EpiModel/EpiModelHIV-p.
2. Add it as repo secret EPIMODEL_PAT.

Falls back to GITHUB_TOKEN if the secret is unset, so forks without
the secret produce a clean resolution-error message rather than a
YAML-level failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Every EpiModelHIV reference in R/ is a docstring comment — the package
has no runtime dependency on EpiModelHIV. It was vestigial from when
the workflow scripts lived under tests/testthat/. Those scripts are now
under tests/workflows/ (manual integration only, not run by testthat),
and the reference copies in inst/validation/epimodelhiv_template_ref/
are static files read for comparison, never sourced or loaded.

Removing the Suggests entry (and its Remotes line for EpiModel/EpiModelHIV-p)
also fixes the CI dependency-resolution failure: pak couldn't map the
package name "EpiModelHIV" to the "-p" repo suffix, and the package
doesn't need it at all.

Local R CMD check: 0 errors / 0 warnings / 0 notes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
r-lib/actions currently defaults error-on to "warning", but silent
upstream defaults can drift. Pin it explicitly so any WARNING from
R CMD check fails the job.

rcmdcheck supports "never" / "note" / "warning" / "error". "warning"
is the right level for ARTnet: NOTEs (e.g., vestigial hidden files)
may be benign and situational, but any WARNING — undocumented args,
undefined globals, misuse of Suggests — should block merge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Closes the CI coverage gap flagged in PR #70 review: the existing
test-joint-{model,netstats,dyad}.R files all exercise Atlanta +
race = TRUE, leaving several real-world parameterizations exercised
only by the manual tests/workflows/ scripts or inst/validation/.

New test-parameterizations.R hits:

1. No-geog (national) -- epistats\$geog.lvl = NULL; build_* must work
   without geogYN in the formulas. Exercises both method = "existing"
   and method = "joint".

2. sex.cess.mod (CEA-style) -- age.limits = c(15, 100) with
   age.sexual.cessation = 65, young.prop = 0.99. Verifies active.sex
   contains both 0 and 1, the post-cessation age group has
   nodefactor_age.grp = 0, and internal consistency holds under
   method = "joint" with inactive-node zeroing.

3. Non-Atlanta city -- "New York City" as a smoke test that other
   geog.cat values work the same as Atlanta.

4. Custom age.breaks / age.limits -- age.limits = c(20, 50) with
   age.breaks = c(30, 40), giving 3 age groups. Verifies
   nodefactor_age.grp has length 3 on every layer and sampled ages
   fall within limits.

5. Non-default time.unit -- monthly (30) vs weekly (7). Verifies
   unit-invariant md.main is identical between methods and
   per-time-unit md.inst scales by 30/7 as expected.

Each block also runs expect_netstats_contract() against the public
fields model_{main,casl,ooff}.R in EpiModelHIV-Template actually
read (kept in sync with inst/validation/netstats_contract.md).

Total suite now: 451 assertions / 8.1 s, still clean tabular output.
R CMD check still 0/0/0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@smjenness smjenness merged commit 30afed0 into main Apr 20, 2026
1 check passed
@smjenness smjenness deleted the chore/package-housekeeping branch April 20, 2026 02:19
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