From 3cce5d630c746f5e4db31ee867381a3c66f80e02 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 3 Jul 2020 21:01:13 -0500 Subject: [PATCH 1/5] [ci] [R-package] catch builds that have not updated docs --- .ci/test.sh | 2 +- .ci/test_r_package.sh | 18 ++++++++++++++++++ .github/workflows/main.yml | 4 ++++ R-package/R/lgb.importance.R | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.ci/test.sh b/.ci/test.sh index 7c68ca733fe9..05802966c7f0 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -69,7 +69,7 @@ if [[ $TASK == "if-else" ]]; then exit 0 fi -if [[ $TASK == "r-package" ]]; then +if [[ $TASK == "r-package" ]] || [[ $TASK == "check-r-docs" ]]; then bash ${BUILD_DIRECTORY}/.ci/test_r_package.sh || exit -1 exit 0 fi diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index 3788a1349770..4a04f49bc860 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -90,6 +90,24 @@ if [[ $OS_NAME == "macos" ]]; then fi Rscript --vanilla -e "install.packages(${packages}, repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1 +if [[ $TASK == "check-r-docs" ]]; then + Rscript build_r.R + Rscript --vanilla -e "install.packages('roxygen2', repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1 + Rscript --vanilla -e "roxygen2::roxygenize('R-package/', load = 'installed')" || exit -1 + num_doc_files_changed=$( + git diff --name-only | grep -E "\.Rd|NAMESPACE" | wc -l + ) + if [[ ${num_doc_files_changed} -gt 0 ]]; then + echo "Some R documentation files have changed. Please re-generate them and commit those changes." + echo "" + echo " Rscript build_r.R" + echo " Rscript -e \"roxygen2::roxygenize('R-package/', load = 'installed')\"" + echo "" + exit -1 + fi + exit 0 +fi + cd ${BUILD_DIRECTORY} Rscript build_r.R --skip-install || exit -1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 87eeb6548de2..c829208bcbf1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,10 @@ jobs: task: r-package compiler: clang r_version: 4.0 + - os: ubuntu-latest + task: check-r-docs + compiler: gcc + r_version: 4.0 - os: macOS-latest task: r-package compiler: gcc diff --git a/R-package/R/lgb.importance.R b/R-package/R/lgb.importance.R index 3064673f664a..f57944d69c55 100644 --- a/R-package/R/lgb.importance.R +++ b/R-package/R/lgb.importance.R @@ -1,5 +1,5 @@ #' @name lgb.importance -#' @title Compute feature importance in a model +#' @title Compute feature importance in a model (testing) #' @description Creates a \code{data.table} of feature importances in a model. #' @param model object of class \code{lgb.Booster}. #' @param percentage whether to show importance in relative percentage. From 3ab3b491058893a62ecc1a02fd9dd4e81029be05 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 3 Jul 2020 21:40:35 -0500 Subject: [PATCH 2/5] drop reliance on .Renviron --- .ci/test_r_package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index 4a04f49bc860..ec8ebcba816c 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -4,7 +4,7 @@ CRAN_MIRROR="https://cloud.r-project.org/" R_LIB_PATH=~/Rlib mkdir -p $R_LIB_PATH -echo "R_LIBS=$R_LIB_PATH" > ${HOME}/.Renviron +export R_LIBS=$R_LIB_PATH export PATH="$R_LIB_PATH/R/bin:$PATH" # Get details needed for installing R components From 30cac1765a159ca2f0fe9aa1eba898d86f1efbe8 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 3 Jul 2020 23:21:01 -0500 Subject: [PATCH 3/5] remove docs changes --- .ci/test_r_package.sh | 2 +- R-package/R/lgb.importance.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index ec8ebcba816c..563350f352e9 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -103,7 +103,7 @@ if [[ $TASK == "check-r-docs" ]]; then echo " Rscript build_r.R" echo " Rscript -e \"roxygen2::roxygenize('R-package/', load = 'installed')\"" echo "" - exit -1 + exit -1 fi exit 0 fi diff --git a/R-package/R/lgb.importance.R b/R-package/R/lgb.importance.R index f57944d69c55..3064673f664a 100644 --- a/R-package/R/lgb.importance.R +++ b/R-package/R/lgb.importance.R @@ -1,5 +1,5 @@ #' @name lgb.importance -#' @title Compute feature importance in a model (testing) +#' @title Compute feature importance in a model #' @description Creates a \code{data.table} of feature importances in a model. #' @param model object of class \code{lgb.Booster}. #' @param percentage whether to show importance in relative percentage. From 61c103c360984899cb602a30cf9cd2964d40e79b Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 5 Jul 2020 15:31:49 -0500 Subject: [PATCH 4/5] Update .ci/test_r_package.sh Co-authored-by: Nikita Titov --- .ci/test_r_package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index 563350f352e9..9c86dcf3ecf9 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -91,7 +91,7 @@ fi Rscript --vanilla -e "install.packages(${packages}, repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1 if [[ $TASK == "check-r-docs" ]]; then - Rscript build_r.R + Rscript build_r.R || exit -1 Rscript --vanilla -e "install.packages('roxygen2', repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1 Rscript --vanilla -e "roxygen2::roxygenize('R-package/', load = 'installed')" || exit -1 num_doc_files_changed=$( From 0b17315310b2cf2f97a19fb9c907dcd8eab4e86b Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 5 Jul 2020 15:35:16 -0500 Subject: [PATCH 5/5] make all R tasks start with r-package --- .ci/test.sh | 2 +- .ci/test_r_package.sh | 2 +- .github/workflows/main.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/test.sh b/.ci/test.sh index 05802966c7f0..bee410cbc34a 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -69,7 +69,7 @@ if [[ $TASK == "if-else" ]]; then exit 0 fi -if [[ $TASK == "r-package" ]] || [[ $TASK == "check-r-docs" ]]; then +if [[ "${TASK:0:9}" == "r-package" ]]; then bash ${BUILD_DIRECTORY}/.ci/test_r_package.sh || exit -1 exit 0 fi diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index 9c86dcf3ecf9..ac2e442c889a 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -90,7 +90,7 @@ if [[ $OS_NAME == "macos" ]]; then fi Rscript --vanilla -e "install.packages(${packages}, repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1 -if [[ $TASK == "check-r-docs" ]]; then +if [[ $TASK == "r-package-check-docs" ]]; then Rscript build_r.R || exit -1 Rscript --vanilla -e "install.packages('roxygen2', repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1 Rscript --vanilla -e "roxygen2::roxygenize('R-package/', load = 'installed')" || exit -1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c829208bcbf1..bc9ef6cbabef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,7 +33,7 @@ jobs: compiler: clang r_version: 4.0 - os: ubuntu-latest - task: check-r-docs + task: r-package-check-docs compiler: gcc r_version: 4.0 - os: macOS-latest