[CI] Test R package with CMake (#10087)

* [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
This commit is contained in:
Philip Hyunsu Cho 2024-03-04 12:32:44 -08:00 committed by GitHub
parent d07b7fe8c8
commit 23a37dcaf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 4 deletions

View File

@ -46,7 +46,7 @@ jobs:
MAKEFLAGS="-j$(nproc)" R CMD INSTALL R-package/ MAKEFLAGS="-j$(nproc)" R CMD INSTALL R-package/
Rscript tests/ci_build/lint_r.R $(pwd) Rscript tests/ci_build/lint_r.R $(pwd)
test-R-on-Windows: test-Rpkg:
runs-on: ${{ matrix.config.os }} 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 }} name: Test R on OS ${{ matrix.config.os }}, R ${{ matrix.config.r }}, Compiler ${{ matrix.config.compiler }}, Build ${{ matrix.config.build }}
strategy: strategy:
@ -54,11 +54,17 @@ jobs:
matrix: matrix:
config: config:
- {os: windows-latest, r: 'release', compiler: 'mingw', build: 'autotools'} - {os: windows-latest, r: 'release', compiler: 'mingw', build: 'autotools'}
- {os: ubuntu-latest, r: 'release', compiler: 'none', build: 'cmake'}
env: env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }} RSPM: ${{ matrix.config.rspm }}
steps: 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 - uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
with: with:
submodules: 'true' submodules: 'true'
@ -89,6 +95,12 @@ jobs:
- name: Test R - name: Test R
run: | run: |
python tests/ci_build/test_r_package.py --compiler='${{ matrix.config.compiler }}' --build-tool="${{ matrix.config.build }}" --task=check 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: test-R-on-Debian:
name: Test R package on Debian name: Test R package on Debian

View File

@ -26,7 +26,6 @@ endif()
target_compile_definitions( target_compile_definitions(
xgboost-r PUBLIC xgboost-r PUBLIC
-DXGBOOST_STRICT_R_MODE=1 -DXGBOOST_STRICT_R_MODE=1
-DXGBOOST_CUSTOMIZE_GLOBAL_PRNG=1
-DDMLC_LOG_BEFORE_THROW=0 -DDMLC_LOG_BEFORE_THROW=0
-DDMLC_DISABLE_STDIN=1 -DDMLC_DISABLE_STDIN=1
-DDMLC_LOG_CUSTOMIZE=1 -DDMLC_LOG_CUSTOMIZE=1

View File

@ -277,6 +277,19 @@ def test_with_cmake(args: argparse.Namespace) -> None:
"Release", "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: else:
raise ValueError("Wrong compiler") raise ValueError("Wrong compiler")
with DirectoryExcursion(R_PACKAGE): with DirectoryExcursion(R_PACKAGE):
@ -333,9 +346,9 @@ if __name__ == "__main__":
parser.add_argument( parser.add_argument(
"--compiler", "--compiler",
type=str, type=str,
choices=["mingw", "msvc"], choices=["mingw", "msvc", "none"],
help="Compiler used for compiling CXX code. Only relevant for windows build", help="Compiler used for compiling CXX code. Only relevant for windows build",
default="mingw", default="none",
required=False, required=False,
) )
parser.add_argument( parser.add_argument(