Skip to content

Commit

Permalink
[CI] Test R package with CMake (#10087)
Browse files Browse the repository at this point in the history
* [CI] Test R package with CMake

* Fix

* Fix

* Update test_r_package.py

* Fix CMake flag for R package

* Install system deps

* Fix

* Use sudo
  • Loading branch information
hcho3 authored Mar 4, 2024
1 parent d07b7fe commit 23a37dc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/r_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,25 @@ jobs:
MAKEFLAGS="-j$(nproc)" R CMD INSTALL R-package/
Rscript tests/ci_build/lint_r.R $(pwd)
test-R-on-Windows:
test-Rpkg:
runs-on: ${{ matrix.config.os }}
name: Test R on OS ${{ matrix.config.os }}, R ${{ matrix.config.r }}, Compiler ${{ matrix.config.compiler }}, Build ${{ matrix.config.build }}
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release', compiler: 'mingw', build: 'autotools'}
- {os: ubuntu-latest, r: 'release', compiler: 'none', build: 'cmake'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}

steps:
- name: Install system dependencies
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev libssl-dev libssh2-1-dev libgit2-dev libglpk-dev libxml2-dev libharfbuzz-dev libfribidi-dev
if: matrix.config.os == 'ubuntu-latest'
- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
with:
submodules: 'true'
Expand Down Expand Up @@ -89,6 +95,12 @@ jobs:
- name: Test R
run: |
python tests/ci_build/test_r_package.py --compiler='${{ matrix.config.compiler }}' --build-tool="${{ matrix.config.build }}" --task=check
if: matrix.config.compiler != 'none'

- name: Test R
run: |
python tests/ci_build/test_r_package.py --build-tool="${{ matrix.config.build }}" --task=check
if: matrix.config.compiler == 'none'

test-R-on-Debian:
name: Test R package on Debian
Expand Down
1 change: 0 additions & 1 deletion R-package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ endif()
target_compile_definitions(
xgboost-r PUBLIC
-DXGBOOST_STRICT_R_MODE=1
-DXGBOOST_CUSTOMIZE_GLOBAL_PRNG=1
-DDMLC_LOG_BEFORE_THROW=0
-DDMLC_DISABLE_STDIN=1
-DDMLC_LOG_CUSTOMIZE=1
Expand Down
17 changes: 15 additions & 2 deletions tests/ci_build/test_r_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,19 @@ def test_with_cmake(args: argparse.Namespace) -> None:
"Release",
]
)
elif args.compiler == "none":
subprocess.check_call(
[
"cmake",
os.path.pardir,
"-DUSE_OPENMP=ON",
"-DR_LIB=ON",
"-DCMAKE_CONFIGURATION_TYPES=Release",
"-G",
"Unix Makefiles",
]
)
subprocess.check_call(["make", "-j", "install"])
else:
raise ValueError("Wrong compiler")
with DirectoryExcursion(R_PACKAGE):
Expand Down Expand Up @@ -333,9 +346,9 @@ def main(args: argparse.Namespace) -> None:
parser.add_argument(
"--compiler",
type=str,
choices=["mingw", "msvc"],
choices=["mingw", "msvc", "none"],
help="Compiler used for compiling CXX code. Only relevant for windows build",
default="mingw",
default="none",
required=False,
)
parser.add_argument(
Expand Down

0 comments on commit 23a37dc

Please sign in to comment.