Unverified Commit 48257d45 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[ci] Add CI job running rchk on the R package (fixes #4400) (#4449)

* [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
parent 96583ab5
......@@ -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
......
......@@ -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'"
......@@ -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
......
......@@ -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')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment