From a2895f54c773d43e998036341506c44f1af50bb0 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 29 Mar 2020 21:46:40 -0500 Subject: [PATCH 1/3] [R-package] [ci] Add option to skip installation in build_r.R --- .ci/test_r_package.sh | 2 +- build_r.R | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index 85c277e42a57..aebf8204f518 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -72,7 +72,7 @@ fi Rscript --vanilla -e "install.packages(${packages}, repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}')" || 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..c9bfde1d1ad4 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)) +} From 2a32b92b46d8cd338a061bdafc598662fa647611 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 29 Mar 2020 23:51:42 -0500 Subject: [PATCH 2/3] fixed linting issues --- build_r.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_r.R b/build_r.R index c9bfde1d1ad4..e4c54c578680 100644 --- a/build_r.R +++ b/build_r.R @@ -5,7 +5,7 @@ # Sys.setenv("CXX" = "/usr/local/bin/g++-8") # Sys.setenv("CC" = "/usr/local/bin/gcc-8") -args <- commandArgs(trailingOnly=TRUE) +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 @@ -89,7 +89,7 @@ version <- gsub( tarball <- file.path(getwd(), sprintf("lightgbm_%s.tar.gz", version)) cmd <- sprintf("R CMD INSTALL %s --no-multiarch --with-keep.source", tarball) -if (INSTALL_AFTER_BUILD){ +if (INSTALL_AFTER_BUILD) { .run_shell_command(cmd) } else { print(sprintf("Skipping installation. Install the package with command '%s'", cmd)) From fb54631f64b6a0a44013df76d90a9257c28b4e82 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 31 Mar 2020 00:23:21 +0100 Subject: [PATCH 3/3] Update build_r.R Co-Authored-By: Nikita Titov --- build_r.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_r.R b/build_r.R index e4c54c578680..29a4d3cc382d 100644 --- a/build_r.R +++ b/build_r.R @@ -91,6 +91,6 @@ tarball <- file.path(getwd(), sprintf("lightgbm_%s.tar.gz", version)) cmd <- sprintf("R CMD INSTALL %s --no-multiarch --with-keep.source", tarball) if (INSTALL_AFTER_BUILD) { .run_shell_command(cmd) -} else { +} else { print(sprintf("Skipping installation. Install the package with command '%s'", cmd)) }