Skip to content

Commit

Permalink
[R-package] [ci] Add option to skip installation in build_r.R (#2957)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
  • Loading branch information
jameslamb and StrikerRUS authored Mar 31, 2020
1 parent e6de39a commit dbc3d05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .ci/test_r_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion build_r.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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))
}

0 comments on commit dbc3d05

Please sign in to comment.