Skip to content

Fix CI: commit test snapshots, drop the stats blanket import, roxygen2 8.1.0 - #36

Open
billdenney wants to merge 6 commits into
masterfrom
claude/ci-failure-master-77fa06
Open

billdenney wants to merge 6 commits into
masterfrom
claude/ci-failure-master-77fa06

Conversation

@billdenney

Copy link
Copy Markdown
Collaborator

R-CMD-check and test-coverage have failed on every platform since the new
workflows landed. There were two independent causes; neither was the workflow
configuration.

1. Test snapshots were never committed

.gitignore listed tests/testthat/_snaps, so none of the 23 snapshots existed
on CI. testthat treats a missing snapshot as a warning locally but as a
failure when the CI environment variable is set — which is exactly why
this passed locally and failed on GitHub Actions.

Reproduced with:

CI=true NOT_CRAN=true Rscript -e 'testthat::test_local()'

23 failures across test-calc.R, test-misc.R, test-nm.R and test-plot.R,
matching both checking tests ... ERROR in R-CMD-check and
running the tests in 'testthat.R' failed in test-coverage.

Fix: un-ignore _snaps and commit the snapshots.

The vdiffr SVG snapshots embed textLength values computed from the system
sans font, which resolves to DejaVu Sans on Linux, Helvetica on macOS and
Arial on Windows — so committed baselines can only be compared on one platform.
The two figure tests are now guarded with skip_on_os(c("mac", "windows")).

2. @import stats collided with dplyr::filter

get_auc() carried a blanket @import stats. importFrom(dplyr, filter) then
replaced stats::filter, emitting replacing previous import 'stats::filter' by 'dplyr::filter' when loading 'pmxTools' at load time.
r-lib/actions/check-r-package runs with error-on: warning, so that install
warning alone failed the check even independently of the test failures.

Fix: drop the blanket import and use stats:: at the 19 call sites
(aggregate.data.frame, median, pchisq, pnorm, qnorm, quantile,
reshape, sd, setNames).

Also in this commit

  • Refreshed all three workflows with usethis::use_github_action(). They were
    already up to date with the r-lib/actions v2 examples — the only resulting
    change was the R-CMD-check badge added to README.md.
  • Regenerated the documentation with roxygen2 8.1.0, which replaces
    RoxygenNote: 7.3.3 with Config/roxygen2/version: 8.1.0 and rewrites
    \link{f}() cross-references as \link[=f]{f()}.

Verification

Run locally under CI conditions (CI=true, NOT_CRAN=true,
_R_CHECK_CRAN_INCOMING_=false, _R_CHECK_FORCE_SUGGESTS_=false):

  • rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning")
    → 0 errors, 0 warnings. The single remaining NOTE is .git being a file
    in the git worktree used for development; it does not occur in a normal
    checkout.
  • covr::package_coverage() completes: 65.06%.

Follow-ups not included here

  • import(utils) is the same class of blanket import as the stats one fixed
    here (6 functions across 5 files) and could be converted the same way.
    import(ggplot2) is left as a conventional blanket

billdenney and others added 6 commits August 27, 2026 16:51
R-CMD-check and test-coverage failed on every platform for two
independent reasons.

Tests: `tests/testthat/_snaps` was listed in `.gitignore`, so none of
the 23 snapshots were ever committed. testthat treats a missing
snapshot as a warning locally but as a *failure* when `CI` is set, so
all snapshot expectations in `test-calc.R`, `test-misc.R`,
`test-nm.R` and `test-plot.R` failed on GitHub Actions, giving
"checking tests ... ERROR" and the covr test failure. Un-ignore
`_snaps` and commit the generated snapshots.

vdiffr SVG snapshots record text metrics from the system "sans" font,
which resolves to DejaVu Sans on Linux but Helvetica on macOS and
Arial on Windows, so the committed figures can only be compared on
Linux. Guard the two figure tests with `skip_on_os()`.

Namespace: `@import stats` in `get_auc()` pulled in `stats::filter`,
which `@importFrom dplyr filter` then replaced, emitting "replacing
previous import" at load time. r-lib/actions/check-r-package uses
`error-on: warning`, so that install warning alone failed the check.
Replace the blanket import with `stats::` at the call sites.

Also refresh the workflows with usethis (they were already current;
only the R-CMD-check README badge was added) and regenerate the
documentation with roxygen2 8.1.0, which replaces `RoxygenNote` with
`Config/roxygen2/version`.

R CMD check --as-cran now reports 0 errors and 0 warnings with
`error_on = "warning"`, and covr completes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`.DS_Store` had no trailing newline, so appending the two testthat
entries in the previous commit produced the pattern
`.DS_Storetests/testthat/_problems` — which ignored neither
`.DS_Store` nor the problems directory. Rewrite the file with a
trailing newline so each pattern is on its own line.

README carried a corrupted R-CMD-check badge whose image URL was
repeated three times, and `usethis::use_github_action()` did not
recognise it, so it appended a second one. Repair the original badge
in place and drop the duplicate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`@import utils` was the same defect as the `stats` one: a blanket
import that can be silently overridden by a later `importFrom`.
Replace it with `utils::` at the call sites (`count.fields`,
`globalVariables`, `head`, `modifyList`, `read.table`) and drop the
tag from `read_nmcov()`, which used no `utils` functions at all.
`import(ggplot2)` is kept, as a blanket import is conventional for a
plotting package.

NEWS.md had no section for 1.6 even though the version was bumped in
"Misc updates". Add one covering `cut_quantile()`, `datamap()`, the
`dgr_table()` named-`fields` interface, the new `purrr` and `tidyr`
dependencies, and the removal of the blanket imports.

R CMD check --as-cran still reports 0 errors and 0 warnings with
`error_on = "warning"`, with no new "no visible global function
definition" notes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…able

Two failures remained on PR CI after the snapshots were committed.

read_nm() called `xml2::read_xml(fileName, ".xml", sep = "")`, a
mangled `paste0()` refactor that passes ".xml" as libxml2's
`encoding` argument. Linux and Windows ignore the bogus encoding
silently, but macOS warns `Unsupported encoding: .xml [32]`, which
was captured by `expect_snapshot()` and failed the read_nm, sample_omega
and sample_sigma snapshots there. The same line also read the raw
`fileName` rather than the `fileName_read` resolved by
`check_file_exists()`, so `directory=` and extension-less names were
ignored; `readLines()` above it had the same defect.

sample_uncert() draws via `MASS::mvrnorm()`, which eigendecomposes
the covariance matrix. THETA4 and OMEGA(2,1) are fixed in this run,
so that matrix is singular and the eigenvectors spanning its null
space are LAPACK-dependent — the draws for a fixed seed differ
between Linux, macOS and Windows, so they cannot be snapshotted.
Replace the snapshot with assertions on what is actually determinate:
the shape and names, that the two fixed parameters are returned
exactly, and that the column means and standard deviations match the
estimates and the covariance diagonal. Ratios are compared so the
tolerance applies per parameter instead of being swamped by V2.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
macOS was the only platform left failing. THETA4 and OMEGA(2,1) have
zero variance, and on Linux and Windows `MASS::mvrnorm()` returns them
bit-identical, so `unique()` collapsed to a single value. macOS leaves
rounding noise around 1e-10 from the eigendecomposition, so `unique()`
returned 5000 distinct values just off the estimate. Compare the full
column against the estimate with a tolerance instead, which still
pins the values roughly four orders of magnitude tighter than the
smallest parameter that does vary.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The mangled `xml2::read_xml()` call meant `directory=` and
extension-less file names were silently ignored, so this is a
user-facing fix rather than a test-only one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@billdenney

Copy link
Copy Markdown
Collaborator Author

@kestrel99, Can you please take a quick look? While large, other than the read_nm() fix, it's effectively just housekeeping.

This branch has not been deployed

No deployments
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