Skip to content

Commit 2a3d110

Browse files
authored
[CI] Fix R build. (#11637)
- Fix R test with the latest image from rhub. - Merge lintr into R tests to avoid re-compiling XGBoost and its dependencies.
1 parent 26856a8 commit 2a3d110

File tree

3 files changed

+28
-40
lines changed

3 files changed

+28
-40
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,3 @@ jobs:
7272
run: |
7373
python3 ops/script/lint_cpp.py
7474
bash ops/script/lint_cmake.sh
75-
76-
lintr:
77-
runs-on: ubuntu-latest
78-
name: Run R linters on Ubuntu
79-
env:
80-
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
81-
steps:
82-
- uses: actions/checkout@v4
83-
with:
84-
submodules: 'true'
85-
- uses: r-lib/actions/setup-r@v2
86-
with:
87-
r-version: "release"
88-
- name: Cache R packages
89-
uses: actions/cache@v4
90-
with:
91-
path: ${{ env.R_LIBS_USER }}
92-
key: ${{ runner.os }}-r-release-7-${{ hashFiles('R-package/DESCRIPTION') }}
93-
restore-keys: ${{ runner.os }}-r-release-7-${{ hashFiles('R-package/DESCRIPTION') }}
94-
- name: Install dependencies
95-
shell: Rscript {0}
96-
run: |
97-
source("./R-package/tests/helper_scripts/install_deps.R")
98-
- name: Run lintr
99-
run: |
100-
MAKEFLAGS="-j$(nproc)" R CMD INSTALL R-package/
101-
Rscript ops/script/lint_r.R $(pwd)

.github/workflows/r_tests.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ jobs:
4242
- uses: r-lib/actions/setup-r@v2
4343
with:
4444
r-version: ${{ matrix.r }}
45-
- name: Cache R packages
46-
uses: actions/cache@v4
47-
with:
48-
path: ${{ env.R_LIBS_USER }}
49-
key: ${{ runner.os }}-r-${{ matrix.r }}-8-${{ hashFiles('R-package/DESCRIPTION') }}
50-
restore-keys: ${{ runner.os }}-r-${{ matrix.r }}-8-${{ hashFiles('R-package/DESCRIPTION') }}
5145
- uses: actions/setup-python@v5
5246
with:
5347
python-version: "3.10"
@@ -70,13 +64,12 @@ jobs:
7064
name: Test R package on Debian
7165
runs-on: ubuntu-latest
7266
container:
73-
image: rhub/debian-gcc-release
67+
image: rhub/ubuntu-release # rhub uses ubuntu for debian tests.
7468
steps:
7569
- name: Install system dependencies
7670
run: |
7771
# Must run before checkout to have the latest git installed.
78-
# No need to add pandoc, the container has it figured out.
79-
apt update && apt install libcurl4-openssl-dev libssl-dev libssh2-1-dev libgit2-dev libglpk-dev libxml2-dev libharfbuzz-dev libfribidi-dev git librsvg2-dev librsvg2-2 -y
72+
apt update && apt install libcurl4-openssl-dev libssl-dev libssh2-1-dev libgit2-dev libglpk-dev libxml2-dev libharfbuzz-dev libfribidi-dev git librsvg2-dev librsvg2-2 pandoc -y
8073
- name: Trust git cloning project sources
8174
run: |
8275
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
@@ -90,8 +83,9 @@ jobs:
9083
- name: Test R
9184
shell: bash -l {0}
9285
run: |
93-
python3 ops/script/test_r_package.py --r=/usr/bin/R --build-tool=autotools --task=check
86+
python3 ops/script/test_r_package.py --r=/opt/R/release/bin/R --build-tool=autotools --task=check
9487
- uses: dorny/paths-filter@v3
88+
# Run the document check if there are changes in the R package.
9589
id: changes
9690
with:
9791
filters: |
@@ -100,4 +94,12 @@ jobs:
10094
- name: Run document check
10195
if: steps.changes.outputs.r_package == 'true'
10296
run: |
103-
python3 ops/script/test_r_package.py --r=/usr/bin/R --task=doc
97+
python3 ops/script/test_r_package.py --r=/opt/R/release/bin/R --task=doc
98+
- name: Run lintr
99+
run: |
100+
# Prevent the linter from checking generated R scripts.
101+
if [ -d ./xgboost.Rcheck ] ; then
102+
rm -rf ./xgboost.Rcheck
103+
fi
104+
MAKEFLAGS="-j$(nproc)" R CMD INSTALL R-package/
105+
Rscript ops/script/lint_r.R $(pwd)

doc/contrib/ci.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,29 @@ project.
1515
Tips for testing
1616
****************
1717

18-
====================================
18+
=======
19+
R tests
20+
=======
21+
22+
------------------------------------
1923
Running R tests with ``noLD`` option
20-
====================================
24+
------------------------------------
25+
2126
You can run R tests using a custom-built R with compilation flag
2227
``--disable-long-double``. See `this page <https://blog.r-hub.io/2019/05/21/nold/>`_ for more
2328
details about noLD. This is a requirement for keeping XGBoost on CRAN (the R package index).
2429
Unlike other tests, this test must be invoked manually. Simply add a review comment
2530
``/gha run r-nold-test`` to a pull request to kick off the test.
2631
(Ordinary comment won't work. It needs to be a review comment.)
2732

33+
---------------------------------
34+
Using container images from r-hub
35+
---------------------------------
36+
37+
The r-hub project `provides <https://github.com/r-hub/containers>`__ a list of container
38+
`images <https://r-hub.github.io/containers/>`__ for reproducing CRAN environments.
39+
40+
2841
===============================
2942
Making changes to CI containers
3043
===============================

0 commit comments

Comments
 (0)