Last active
August 18, 2024 07:16
-
-
Save MichaelChirico/aedcc59a07d49800bcce3be71400cee1 to your computer and use it in GitHub Desktop.
r-devel CRAN sample
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
# Script to test a patched version of r-devel against a selection of CRAN packages | |
# Useful for detecting possible breaking changes by examining how changes affect actual packages | |
# Does not require a local CRAN mirror -- idea is to only test a small fraction of CRAN --> | |
# relatively small I/O cost of downloading the packages on the fly. | |
# This script is used for the patch here: | |
# https://github.com/r-devel/r-svn/pull/177 | |
# https://bugs.r-project.org/show_bug.cgi?id=18782 | |
# https://bugs.r-project.org/show_bug.cgi?id=17672 | |
PACKAGES_TO_TEST = c( | |
# packages using 'seq.POSIXt' directly in man/ | |
# https://github.com/search?q=org%3Acran+lang%3AR+%2F%5Cn%5B%5E%23%5Cn%5D*seq%5B.%5DPOSIXt%5B%28%5D%5B%5E%29%5D%2F+path%3A.Rd&type=code | |
"evsim", "forecastML", "billboarder", "funique", "EIAapi", "VulnToolkit", "leaflet.extras2", "RNewsflow", "mpathsenser", "rAmCharts", "runner", | |
# "stUPscales", "glacierSMBM", "rtsVis", # not available 2024-08-17 | |
# packages using 'DSTdays' anywhere | |
# https://github.com/search?q=org%3Acran+lang%3AR+%2F%5Cn%5B%5E%23%5Cn%5D*seq%5B%28%5D%2F+DSTdays&type=code | |
"padr", "DTSg", "geometa", "openair", "timeDate", "lattice", "PCICt", | |
# "hydrosanity", "datamart", # not available 2024-08-17 | |
# packages heavily relying on time/date objects (hand-picked plus searching for seq.Date usage) | |
"xts", "lubridate", "forecast", "anytime", "bsts", "tibbletime", "tsibble", "dateutils", "timeperiodsR", "tsensembler", "timeSeries", "tseries", "nanotime", "chron", "zoo" | |
# "TSAgg", # not available 2024-08-17 | |
) | |
RHOME = path.expand("~/svn/R-devel") | |
RDEVEL = file.path(RHOME, "bin", "R") | |
RDEVELSCRIPT = file.path(RHOME, "bin", "Rscript") | |
git_cran_https_fmt = "https://github.com/cran/%s.git" | |
# use this to make sure all the package dependencies are installed | |
# get some rest... | |
# this will likely fail the first time due to some missing system requirements... | |
# e.g. sodium (->keyring->geometa) depends on libsodium-dev | |
# (way more if this is done in a minimal docker image) | |
system2(RDEVELSCRIPT, c("-e", sprintf( | |
"'install.packages(%s, dependencies=TRUE)'", | |
paste0('"', PACKAGES_TO_TEST, '"', collapse=",") | |
)) | |
setwd(tempdir()) | |
pb <- txtProgressBar(max = length(PACKAGES_TO_TEST)) | |
for (ii in seq_along(PACKAGES_TO_TEST)) { | |
setTxtProgressBar(pb, ii) | |
package <- PACKAGES_TO_TEST[ii] | |
system(paste("git clone --quiet --depth 1", sprintf(git_cran_https_fmt, package))) | |
# https://github.com/r-lib/rcmdcheck/issues/224 | |
# https://github.com/r-lib/rcmdcheck/issues/225 | |
system2(RDEVEL, c("CMD", "build", package), stdout=FALSE, stderr=FALSE) | |
built_package <- list.files(pattern = paste0(package, '.*tar.gz')) | |
if (!length(built_package)) { cat(sprintf("Failed to build %s!\n", package)); next } | |
# https://github.com/r-lib/rcmdcheck/issues/226 | |
system2(RDEVELSCRIPT, c("-e", sprintf( | |
"'res <- rcmdcheck::rcmdcheck(\"%s\", quiet=TRUE); if (length(res$errors)) print(res)'", | |
built_package | |
)) | |
unlink(list.files(pattern = package), recursive=TRUE) | |
} | |
cat("\nDone!\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment