diff --git a/.ci/test.sh b/.ci/test.sh index 7c68ca733fe9..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" ]]; 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 3788a1349770..ac2e442c889a 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 @@ -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 == "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 + 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..bc9ef6cbabef 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: r-package-check-docs + compiler: gcc + r_version: 4.0 - os: macOS-latest task: r-package compiler: gcc