diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index 85c277e42a57..0e660ba8581b 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -69,10 +69,10 @@ packages="c('data.table', 'jsonlite', 'Matrix', 'R6', 'testthat')" if [[ $OS_NAME == "macos" ]]; then packages+=", type = 'binary'" fi -Rscript --vanilla -e "install.packages(${packages}, repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}')" || exit -1 +Rscript --vanilla -e "install.packages(${packages}, repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1 cd ${BUILD_DIRECTORY} -Rscript build_r.R || exit -1 +Rscript build_r.R --skip-install || exit -1 PKG_TARBALL="lightgbm_${LGB_VER}.tar.gz" LOG_FILE_NAME="lightgbm.Rcheck/00check.log" diff --git a/build_r.R b/build_r.R index 88133c248071..29a4d3cc382d 100644 --- a/build_r.R +++ b/build_r.R @@ -5,6 +5,9 @@ # Sys.setenv("CXX" = "/usr/local/bin/g++-8") # Sys.setenv("CC" = "/usr/local/bin/gcc-8") +args <- commandArgs(trailingOnly = TRUE) +INSTALL_AFTER_BUILD <- !("--skip-install" %in% args) + # R returns FALSE (not a non-zero exit code) if a file copy operation # breaks. Let's fix that .handle_result <- function(res) { @@ -86,4 +89,8 @@ version <- gsub( tarball <- file.path(getwd(), sprintf("lightgbm_%s.tar.gz", version)) cmd <- sprintf("R CMD INSTALL %s --no-multiarch --with-keep.source", tarball) -.run_shell_command(cmd) +if (INSTALL_AFTER_BUILD) { + .run_shell_command(cmd) +} else { + print(sprintf("Skipping installation. Install the package with command '%s'", cmd)) +}