Skip to content

Commit

Permalink
[ci] [R-package] re-enable 'rchk' checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Feb 20, 2024
1 parent 45a60a7 commit 77b2399
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .ci/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ else # Linux
fi
fi

if [[ "${TASK}" != "r-package" ]] && [[ "${TASK}" != "r-rchk" ]]; then
if [[ "${TASK}" != "r-package" ]]; then
if [[ $SETUP_CONDA != "false" ]]; then
sh miniforge.sh -b -p $CONDA
fi
Expand Down
28 changes: 28 additions & 0 deletions .ci/test-r-package-rchk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -E -e -u -o pipefail

echo "Checking R package with rchk"
sh build-cran-package.sh --no-build-vignettes

mkdir -p ./packages
PKG_TARBALL="lightgbm_*.tar.gz"
cp ./${PKG_TARBALL} ./packages/${PKG_TARBALL}

RCHK_LOG_FILE="rchk-logs.txt"
docker run \
--rm \
-v $(pwd)/packages:/rchk/packages \
kalibera/rchk:latest \
"/rchk/packages/${PKG_TARBALL}" \
2>&1 > ${RCHK_LOG_FILE} \
|| (cat ${RCHK_LOG_FILE} && exit 1)

# the exceptions below are 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 -v "in function RunGenCollect" \
# | grep --count -E '\[PB\]|ERROR'
# )
2 changes: 1 addition & 1 deletion .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
export LC_ALL="en_US.UTF-8"
fi

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

# Manually install Depends and Imports libraries + 'knitr', 'markdown', 'RhpcBLASctl', 'testthat'
# to avoid a CI-time dependency on devtools (for devtools::install_deps())
# NOTE: testthat is not required when running rchk
if [[ "${TASK}" == "r-rchk" ]]; then
packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'R6', 'RhpcBLASctl')"
else
packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'R6', 'RhpcBLASctl', 'testthat')"
fi
packages="c('data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'R6', 'RhpcBLASctl', 'testthat')"
compile_from_source="both"
if [[ $OS_NAME == "macos" ]]; then
packages+=", type = 'binary'"
Expand Down Expand Up @@ -170,29 +165,6 @@ 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 exceptions below are 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 -v "in function RunGenCollect" \
| 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
31 changes: 21 additions & 10 deletions .github/workflows/r_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,6 @@ jobs:
r_version: 4.3
build_type: cran
container: null
################
# Other checks #
################
- os: ubuntu-latest
task: r-rchk
compiler: gcc
r_version: 4.3
build_type: cran
container: 'ubuntu:22.04'
steps:
- name: Prevent conversion of line endings on Windows
if: startsWith(matrix.os, 'windows')
Expand Down Expand Up @@ -313,10 +304,30 @@ jobs:
echo "NOTEs, WARNINGs, or ERRORs have been found by R CMD check"
exit 1
fi
test-r-rchk:
name: r-package (R-devel, rchk)
timeout-minutes: 60
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 5
submodules: true
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: 'devel'
- name: Build package and run rchk tests
shell: bash
run: |
./.ci/test-r-package-rchk.sh
all-r-package-jobs-successful:
if: always()
runs-on: ubuntu-latest
needs: [test, test-r-sanitizers, test-r-debian-clang]
needs: [test, test-r-sanitizers, test-r-debian-clang, test-r-rchk]
steps:
- name: Note that all tests succeeded
uses: re-actors/alls-green@v1.2.2
Expand Down

0 comments on commit 77b2399

Please sign in to comment.