Skip to content

Commit

Permalink
[ci] Add CI job running rchk on the R package (fixes #4400) (#4449)
Browse files Browse the repository at this point in the history
* [ci] add CI job running rchk

* try commenting out more stuff

* ignore R internal error

* pipes

* remove PROTECT()

* try removing testthat

* revert temporary testing changes
  • Loading branch information
jameslamb authored Jul 10, 2021
1 parent 96583ab commit 48257d4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ elif [[ $OS_NAME == "linux" ]] && [[ $COMPILER == "clang" ]]; then
export CC=clang
fi

if [[ "${TASK}" == "r-package" ]]; then
if [[ "${TASK}" == "r-package" ]] || [[ "${TASK}" == "r-rchk" ]]; then
bash ${BUILD_DIRECTORY}/.ci/test_r_package.sh || exit -1
exit 0
fi
Expand Down
29 changes: 28 additions & 1 deletion .ci/test_r_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ fi

# Manually install Depends and Imports libraries + 'testthat'
# to avoid a CI-time dependency on devtools (for devtools::install_deps())
packages="c('data.table', 'jsonlite', 'Matrix', 'R6', 'testthat')"
# NOTE: testthat is not required when running rchk
if [[ "${TASK}" == "r-rchk" ]]; then
packages="c('data.table', 'jsonlite', 'Matrix', 'R6')"
else
packages="c('data.table', 'jsonlite', 'Matrix', 'R6', 'testthat')"
fi
compile_from_source="both"
if [[ $OS_NAME == "macos" ]]; then
packages+=", type = 'binary'"
Expand Down Expand Up @@ -130,6 +135,28 @@ elif [[ $R_BUILD_TYPE == "cran" ]]; then

./build-cran-package.sh || exit -1

if [[ "${TASK}" == "r-rchk" ]]; then
echo "Checking R package with rchk"
mkdir -p packages
cp ${PKG_TARBALL} packages
RCHK_LOG_FILE="rchk-logs.txt"
docker run \
-v $(pwd)/packages:/rchk/packages \
kalibera/rchk:latest \
"/rchk/packages/${PKG_TARBALL}" \
2>&1 > ${RCHK_LOG_FILE} \
|| (cat ${RCHK_LOG_FILE} && exit -1)
cat ${RCHK_LOG_FILE}

# the exception below is from R itself and not LightGBM:
# https://github.com/kalibera/rchk/issues/22#issuecomment-656036156
exit $(
cat ${RCHK_LOG_FILE} \
| grep -v "in function strptime_internal" \
| grep --count -E '\[PB\]|ERROR'
)
fi

# Test CRAN source .tar.gz in a directory that is not this repo or below it.
# When people install.packages('lightgbm'), they won't have the LightGBM
# git repo around. This is to protect against the use of relative paths
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/r_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ jobs:
compiler: clang
r_version: 4.0
build_type: cran
################
# Other checks #
################
- os: ubuntu-latest
task: r-rchk
compiler: gcc
r_version: 4.0
build_type: cran
steps:
- name: Prevent conversion of line endings on Windows
if: startsWith(matrix.os, 'windows')
Expand Down

0 comments on commit 48257d4

Please sign in to comment.