Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-package][ci] added CI stage for R package (fixes #2335, fixes #2569) #2530

Merged
merged 69 commits into from
Dec 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a6a292c
[R-package][ci] added CI stage for R package
jameslamb Oct 27, 2019
1002eec
fixed typo
jameslamb Oct 27, 2019
3534f42
added 'testthat'
jameslamb Oct 27, 2019
5088c91
tried non-conda R install
jameslamb Oct 27, 2019
8f9493a
fixed permissions and regenned docs
jameslamb Oct 27, 2019
a183a58
moved r-pkg task up above Python stuff so it is self-contained
jameslamb Oct 27, 2019
d1a927d
updates
jameslamb Oct 27, 2019
960ed61
added Suggests R dependencies in CI environment
jameslamb Oct 27, 2019
43ad93e
fixed typo
jameslamb Oct 27, 2019
8c02c42
removed unnecessary cd
jameslamb Oct 27, 2019
d9a2dac
what is happening
jameslamb Oct 28, 2019
33d7d6a
please work
jameslamb Oct 28, 2019
d1c6413
added boost file ignores
jameslamb Oct 28, 2019
fa83edf
changed R install strategy
jameslamb Oct 28, 2019
8ac94eb
ignoring more things
jameslamb Oct 28, 2019
e2688cd
trying R 3.5.0
jameslamb Oct 28, 2019
353d94b
test use of precompiled R distribution
jameslamb Oct 28, 2019
687f068
update channels
jameslamb Oct 28, 2019
6d487ca
added cran channel for ubuntu
jameslamb Oct 28, 2019
2d813d2
added LaTeX stuff
jameslamb Oct 29, 2019
c25dbe0
skip the latex stuff
jameslamb Oct 29, 2019
2bf7dc9
added OSX back to CI
jameslamb Oct 29, 2019
0c68f32
fixed block around mac os code in test.sh
jameslamb Oct 29, 2019
7d34a53
trying CRAN binaries for R on Mac
jameslamb Oct 29, 2019
96bf639
removed commented-out code
jameslamb Oct 30, 2019
42e20e7
fixed issue in roxygen documentation
jameslamb Nov 3, 2019
d5b4697
introduced fix for non-portable Makefiles generated by cmake
jameslamb Nov 3, 2019
5df25dc
trying a simple ignore
jameslamb Nov 5, 2019
75dba47
removed installation of suggested packages to cut build time
jameslamb Nov 5, 2019
b7ff934
trying full build
jameslamb Nov 5, 2019
fdae797
cleaned up test.sh
jameslamb Nov 6, 2019
5fcbe44
upgraded linux R CI environment to 3.6.1
jameslamb Nov 8, 2019
f8e351f
r-pkg to r-package
jameslamb Nov 8, 2019
3176fc7
moved R setup and testing into .ci/test_r_package.sh
jameslamb Nov 10, 2019
40746a8
added R CI on Azure pipelines and silenced some installations
jameslamb Nov 12, 2019
7285448
add update back in
jameslamb Nov 12, 2019
d95f3f4
fixed bugs. bugs are bad
jameslamb Nov 12, 2019
688f2ec
added apt update back in
jameslamb Nov 12, 2019
c357914
added switching for different lubuntu distributions
jameslamb Nov 13, 2019
6e50d81
fixed r version on linux
jameslamb Nov 13, 2019
4f875ad
remove unnecessary ubuntu-version stuff
jameslamb Nov 17, 2019
7cef9f3
tried to fix libomp error on Azure mac builds
jameslamb Nov 17, 2019
82a4794
commented out more stuff
jameslamb Nov 19, 2019
f2a31ff
pointed Azure CI at new lightgbm container
jameslamb Nov 20, 2019
62656c5
trying to fix libomp issue on mac
jameslamb Nov 20, 2019
6b1aefe
more logs
jameslamb Nov 20, 2019
0303d54
trying a different openmp strategy
jameslamb Nov 20, 2019
061f0ac
trying to get more logs
jameslamb Nov 20, 2019
5fa610f
another try
jameslamb Nov 20, 2019
1274876
more stuff
jameslamb Nov 20, 2019
2bd4e31
more things
jameslamb Nov 20, 2019
8316e3c
where is libomp
jameslamb Nov 20, 2019
dd5c1e6
this might just work
jameslamb Nov 20, 2019
7dc8e6e
testing removing an apt-get update
jameslamb Nov 20, 2019
e2517a0
uncommented other Azure steps
jameslamb Nov 20, 2019
356edbe
removed unnecessary environment variable
jameslamb Nov 20, 2019
9cdfe37
added clang
jameslamb Nov 21, 2019
7d220f1
tried swapping clang and gcc in CI
jameslamb Dec 2, 2019
2d20af1
fixed duplicate libomp stuff in test.sh
jameslamb Dec 3, 2019
7a82fb7
Update .ci/test_r_package.sh
jameslamb Dec 3, 2019
63ca225
fix libomp fix to respect R_MAC_VERSION variable
jameslamb Dec 3, 2019
e47b16f
tried adding support for roxygen2 7.x
jameslamb Dec 3, 2019
b9bd5ad
fixed issues with NAMESPACE
jameslamb Dec 3, 2019
9db3fa0
trying to get more latex logs
jameslamb Dec 4, 2019
d2ee4af
fixed texi2dvi issues building R package
jameslamb Dec 4, 2019
ae08c80
restored all Azure stages
jameslamb Dec 4, 2019
3285bd4
more consistent use of environment variables
jameslamb Dec 7, 2019
d98211f
switched compilers back
jameslamb Dec 8, 2019
9ab619c
switch Azure CI container back to main version
jameslamb Dec 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ if [[ $TASK == "if-else" ]]; then
exit 0
fi

if [[ $TASK == "r-package" ]]; then
StrikerRUS marked this conversation as resolved.
Show resolved Hide resolved
bash ${BUILD_DIRECTORY}/.ci/test_r_package.sh || exit -1
exit 0
fi

conda install -q -y -n $CONDA_ENV joblib matplotlib numpy pandas psutil pytest python-graphviz scikit-learn scipy

if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "clang" ]]; then
Expand Down
90 changes: 90 additions & 0 deletions .ci/test_r_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash

# set up R environment
R_LIB_PATH=~/Rlib
mkdir -p $R_LIB_PATH
echo "R_LIBS=$R_LIB_PATH" > ${HOME}/.Renviron
echo 'options(repos = "https://cran.rstudio.com")' > ${HOME}/.Rprofile
export PATH="$R_LIB_PATH/R/bin:$PATH"

# installing precompiled R for Ubuntu
# https://cran.r-project.org/bin/linux/ubuntu/#installation
# adding steps from https://stackoverflow.com/a/56378217/3986677 to get latest version
#
# This only needs to get run on Travis because R environment for Linux
# used by Azure pipelines is set up in https://github.com/guolinke/lightgbm-ci-docker
if [[ $TRAVIS == "true" ]] && [[ $OS_NAME == "linux" ]]; then
sudo add-apt-repository \
"deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/"
sudo apt-key adv \
--keyserver keyserver.ubuntu.com \
--recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt-get update
sudo apt-get install \
--no-install-recommends \
-y \
StrikerRUS marked this conversation as resolved.
Show resolved Hide resolved
r-base-dev=${R_TRAVIS_LINUX_VERSION} \
texinfo \
texlive-latex-recommended \
texlive-fonts-recommended \
texlive-fonts-extra \
qpdf \
|| exit -1
fi

# Installing R precompiled for Mac OS 10.11 or higher
if [[ $OS_NAME == "macos" ]]; then

brew install qpdf
brew cask install basictex
export PATH="/Library/TeX/texbin:$PATH"
sudo tlmgr update --self
sudo tlmgr install inconsolata helvetic

wget -q https://cran.r-project.org/bin/macosx/R-${R_MAC_VERSION}.pkg -O R.pkg
sudo installer \
-pkg $(pwd)/R.pkg \
-target /

# Fix "duplicate libomp versions" issue on Mac
# by replacing the R libomp.dylib with a symlink to the one installed with brew
if [[ $COMPILER == "clang" ]]; then
ver_arr=( ${R_MAC_VERSION//./ } )
R_MAJOR_MINOR="${ver_arr[0]}.${ver_arr[1]}"
sudo ln -sf \
"$(brew --cellar libomp)"/*/lib/libomp.dylib \
/Library/Frameworks/R.framework/Versions/${R_MAJOR_MINOR}/Resources/lib/libomp.dylib
fi
fi

conda install \
-y \
StrikerRUS marked this conversation as resolved.
Show resolved Hide resolved
-q \
--no-deps \
pandoc

# Manually install Depends and Imports libraries + 'testthat'
# to avoid a CI-time dependency on devtools (for devtools::install_deps())
Rscript -e "install.packages(c('data.table', 'jsonlite', 'Matrix', 'R6', 'testthat'))" || exit -1

cd ${BUILD_DIRECTORY}
Rscript build_r.R || exit -1

PKG_TARBALL="lightgbm_${LGB_VER}.tar.gz"
LOG_FILE_NAME="lightgbm.Rcheck/00check.log"

# suppress R CMD check warning from Suggests dependencies not being available
export _R_CHECK_FORCE_SUGGESTS_=0

# fails tests if either ERRORs or WARNINGs are thrown by
# R CMD CHECK
R CMD check ${PKG_TARBALL} \
--as-cran \
|| exit -1

if grep -q -R "WARNING" "$LOG_FILE_NAME"; then
echo "WARNINGS have been found by R CMD check!"
exit -1
fi

exit 0
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ env:
- TASK=mpi METHOD=pip
- TASK=gpu METHOD=source PYTHON_VERSION=3.5
- TASK=gpu METHOD=pip PYTHON_VERSION=3.6
- TASK=r-package

matrix:
exclude:
Expand All @@ -44,9 +45,11 @@ before_install:
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then
export OS_NAME="macos";
export COMPILER="gcc";
export R_MAC_VERSION=3.6.1;
else
export OS_NAME="linux";
export COMPILER="clang";
export R_TRAVIS_LINUX_VERSION=3.6.1-3bionic;
fi
- export CONDA="$HOME/miniconda"
- export PATH="$CONDA/bin:$PATH"
Expand Down
5 changes: 5 additions & 0 deletions .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
TASK: gpu
METHOD: source
PYTHON_VERSION: 3.6
r_package:
TASK: r-package
steps:
- script: |
echo "##vso[task.setvariable variable=HOME_DIRECTORY]$AGENT_HOMEDIRECTORY"
Expand Down Expand Up @@ -84,6 +86,8 @@ jobs:
PYTHON_VERSION: 3.5
bdist:
TASK: bdist
r_package:
TASK: r-package
steps:
- script: |
echo "##vso[task.setvariable variable=HOME_DIRECTORY]$AGENT_HOMEDIRECTORY"
Expand All @@ -95,6 +99,7 @@ jobs:
echo "##vso[task.setvariable variable=CONDA]$CONDA"
echo "##vso[task.prependpath]$CONDA/bin"
echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME_8_X64"
echo "##vso[task.setvariable variable=R_MAC_VERSION]3.6.1"
displayName: 'Set variables'
- bash: $(Build.SourcesDirectory)/.ci/setup.sh
displayName: Setup
Expand Down
11 changes: 11 additions & 0 deletions R-package/.Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@

# Code copied in at build time
^src/CMakeLists.txt$

# unnecessary files from submodules
^src/compute/.appveyor.yml$
^src/compute/.coveralls.yml$
^src/compute/.travis.yml$
^src/compute/test/$
^src/compute/index.html$
^src/compute/.git$
^src/compute/.gitignore$
^src/compute/CONTRIBUTING.md$
^src/compute/README.md$
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/compute is the boost stuff we pull in as a git submodule. It's important that the random other stuff from that repo isn't bundled with the R package, as R CMD check will complain about things like a .git/ folder being put into a source distribution.

2 changes: 1 addition & 1 deletion R-package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Imports:
jsonlite (>= 1.0),
Matrix (>= 1.1-0),
methods
RoxygenNote: 6.0.1
RoxygenNote: 7.0.2
4 changes: 2 additions & 2 deletions R-package/man/lgb.cv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions R-package/man/lgb.prepare_rules2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions R-package/src/install.libs.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,32 @@ if (!use_precompile) {

# Install
system(paste0(cmake_cmd, " .."))

# R CMD check complains about the .NOTPARALLEL directive created in the cmake
# Makefile. We don't need it here anyway since targets are built serially, so trying
# to remove it with this hack
StrikerRUS marked this conversation as resolved.
Show resolved Hide resolved
generated_makefile <- file.path(
R_PACKAGE_SOURCE
, "src"
, "build"
, "Makefile"
)
if (file.exists(generated_makefile)) {
makefile_txt <- readLines(
con = generated_makefile
)
makefile_txt <- gsub(
pattern = ".*NOTPARALLEL.*"
, replacement = ""
, x = makefile_txt
)
writeLines(
text = makefile_txt
, con = generated_makefile
, sep = "\n"
)
}

system(build_cmd)
src <- file.path(lib_folder, paste0("lib_lightgbm", SHLIB_EXT), fsep = "/")

Expand Down
6 changes: 5 additions & 1 deletion R-package/tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
library(testthat)
library(lightgbm)

test_check("lightgbm")
test_check(
package = "lightgbm"
, stop_on_failure = TRUE
, stop_on_warning = FALSE
)
2 changes: 1 addition & 1 deletion build_r.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ version <- gsub(
)
tarball <- file.path(getwd(), sprintf("lightgbm_%s.tar.gz", version))

cmd <- sprintf("R CMD INSTALL %s --no-multiarch", tarball)
cmd <- sprintf("R CMD INSTALL %s --no-multiarch --with-keep.source", tarball)
.run_shell_command(cmd)