From cdc1f9be2f3d22fdaa794a09e3fbf61988373d7c Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 23 Sep 2022 23:22:08 -0500 Subject: [PATCH 1/3] [ci] [R-package] use R 4.2.1 in Windows CI jobs (fixes #4881) --- .ci/test_r_package_windows.ps1 | 12 +++++++----- .github/workflows/r_package.yml | 1 + R-package/README.md | 5 +++++ R-package/configure.win | 3 ++- R-package/tests/testthat/test_dataset.R | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.ci/test_r_package_windows.ps1 b/.ci/test_r_package_windows.ps1 index c8f63b9c8b06..891c7cbd36e1 100644 --- a/.ci/test_r_package_windows.ps1 +++ b/.ci/test_r_package_windows.ps1 @@ -54,11 +54,13 @@ Remove-From-Path ".*PostgreSQL.*" Remove-From-Path ".*\\R\\.*" Remove-From-Path ".*R Client.*" Remove-From-Path ".*rtools40.*" +Remove-From-Path ".*rtools42.*" Remove-From-Path ".*shells.*" Remove-From-Path ".*Strawberry.*" Remove-From-Path ".*tools.*" Remove-Item C:\rtools40 -Force -Recurse -ErrorAction Ignore +Remove-Item C:\rtools42 -Force -Recurse -ErrorAction Ignore # Get details needed for installing R components # @@ -74,11 +76,11 @@ if ($env:R_MAJOR_VERSION -eq "3") { $env:RTOOLS_EXE_FILE = "rtools35-x86_64.exe" $env:R_WINDOWS_VERSION = "3.6.3" } elseif ($env:R_MAJOR_VERSION -eq "4") { - $RTOOLS_INSTALL_PATH = "C:\rtools40" + $RTOOLS_INSTALL_PATH = "C:\rtools42" $env:RTOOLS_BIN = "$RTOOLS_INSTALL_PATH\usr\bin" - $env:RTOOLS_MINGW_BIN = "$RTOOLS_INSTALL_PATH\mingw64\bin" - $env:RTOOLS_EXE_FILE = "rtools40v2-x86_64.exe" - $env:R_WINDOWS_VERSION = "4.1.3" + $env:RTOOLS_MINGW_BIN = "$RTOOLS_INSTALL_PATH\x86_64-w64-mingw32.static.posix\bin" + $env:RTOOLS_EXE_FILE = "rtools42-5253-5107.exe" + $env:R_WINDOWS_VERSION = "4.2.1" } else { Write-Output "[ERROR] Unrecognized R version: $env:R_VERSION" Check-Output $false @@ -147,7 +149,7 @@ Write-Output "Building R package" # R CMD check is not used for MSVC builds if ($env:COMPILER -ne "MSVC") { - $PKG_FILE_NAME = "lightgbm_*.tar.gz" + $PKG_FILE_NAME = "lightgbm_$env:LGB_VER.tar.gz" $LOG_FILE_NAME = "lightgbm.Rcheck/00check.log" if ($env:R_BUILD_TYPE -eq "cmake") { diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index daf51b10abf8..53f7fb872847 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -165,6 +165,7 @@ jobs: shell: pwsh -command ". {0}" run: | $env:BUILD_SOURCESDIRECTORY = $env:GITHUB_WORKSPACE + $env:LGB_VER = (Get-Content -TotalCount 1 $env:BUILD_SOURCESDIRECTORY\VERSION.txt).trim().replace('rc', '-') $env:TOOLCHAIN = "${{ matrix.toolchain }}" $env:R_VERSION = "${{ matrix.r_version }}" $env:R_BUILD_TYPE = "${{ matrix.build_type }}" diff --git a/R-package/README.md b/R-package/README.md index 05775a0e6da3..eb8c3985a2a6 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -97,6 +97,9 @@ After installing `Rtools` and `CMake`, be sure the following paths are added to - If you have `Rtools` 4.0, example: - `C:\rtools40\mingw64\bin` - `C:\rtools40\usr\bin` + - If you have `Rtools` 4.2, example: + - `C:\rtools42\x86_64-w64-mingw32.static.posix\bin` + - `C:\rtools42\user\bin` * `CMake` - example: `C:\Program Files\CMake\bin` * `R` @@ -104,6 +107,8 @@ After installing `Rtools` and `CMake`, be sure the following paths are added to NOTE: Two `Rtools` paths are required from `Rtools` 4.0 onwards because paths and the list of included software was changed in `Rtools` 4.0. +NOTE: `Rtools42` takes a very different approach to the compiler toolchain than previous releases, and how you install it changes what is required to build packages. See ["Howto: Building R 4.2 and packages on Windows"](https://cran.r-project.org/bin/windows/base/howto-R-4.2.html). + #### Windows Toolchain Options A "toolchain" refers to the collection of software used to build the library. The R package can be built with three different toolchains. diff --git a/R-package/configure.win b/R-package/configure.win index 0410e9b9b5f1..620e1e53a4ce 100755 --- a/R-package/configure.win +++ b/R-package/configure.win @@ -79,7 +79,8 @@ ac_inet_pton="no" cat > conftest.cpp < int main() { - void* p = inet_pton; + int (*fptr)(int, const char*, void*); + fptr = &inet_pton; return 0; } EOL diff --git a/R-package/tests/testthat/test_dataset.R b/R-package/tests/testthat/test_dataset.R index d48c38b68daf..bf4c826ef448 100644 --- a/R-package/tests/testthat/test_dataset.R +++ b/R-package/tests/testthat/test_dataset.R @@ -219,8 +219,8 @@ test_that("lgb.Dataset: Dataset should be able to construct from matrix and retu test_that("cpp errors should be raised as proper R errors", { testthat::skip_if( - Sys.getenv("COMPILER", "") == "MSVC" && as.integer(R.Version()[["major"]]) < 4L - , message = "Skipping on R 3.x and Visual Studio" + Sys.getenv("COMPILER", "") == "MSVC" + , message = "Skipping on Visual Studio" ) data(agaricus.train, package = "lightgbm") train <- agaricus.train From 263ad4bd802d584f5a00170747b12f82b8fee7ff Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sat, 24 Sep 2022 00:50:19 -0500 Subject: [PATCH 2/3] fix CI job labels --- .github/workflows/r_package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 53f7fb872847..c5ed1486ba3a 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -82,7 +82,7 @@ jobs: task: r-package compiler: MINGW toolchain: MSYS - r_version: 4.1 + r_version: 4.2 build_type: cmake # Visual Studio 2019 - os: windows-2019 @@ -96,7 +96,7 @@ jobs: task: r-package compiler: MSVC toolchain: MSVC - r_version: 4.1 + r_version: 4.2 build_type: cmake ############### # CRAN builds # @@ -111,7 +111,7 @@ jobs: task: r-package compiler: MINGW toolchain: MSYS - r_version: 4.1 + r_version: 4.2 build_type: cran - os: ubuntu-latest task: r-package From 58ca20f7cd74aae2c0eda3740e73960003b7c580 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sat, 8 Oct 2022 22:35:51 -0500 Subject: [PATCH 3/3] Update R-package/README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: José Morales --- R-package/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R-package/README.md b/R-package/README.md index 750233c969ef..e08d9312a4ec 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -99,7 +99,7 @@ After installing `Rtools` and `CMake`, be sure the following paths are added to - `C:\rtools40\usr\bin` - If you have `Rtools` 4.2, example: - `C:\rtools42\x86_64-w64-mingw32.static.posix\bin` - - `C:\rtools42\user\bin` + - `C:\rtools42\usr\bin` * `CMake` - example: `C:\Program Files\CMake\bin` * `R`