diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index 7a12d3fdc1d4..b7af507a87b9 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -23,8 +23,8 @@ if [[ "${R_MAJOR_VERSION}" == "3" ]]; then elif [[ "${R_MAJOR_VERSION}" == "4" ]]; then export R_MAC_VERSION=4.2.2 export R_MAC_PKG_URL=${CRAN_MIRROR}/bin/macosx/base/R-${R_MAC_VERSION}.pkg - export R_LINUX_VERSION="4.2.2-1.2004.0" - export R_APT_REPO="focal-cran40/" + export R_LINUX_VERSION="4.2.2-1.2204.0" + export R_APT_REPO="jammy-cran40/" else echo "Unrecognized R version: ${R_VERSION}" exit -1 @@ -38,14 +38,15 @@ fi if [[ $OS_NAME == "linux" ]]; then sudo apt-key adv \ --keyserver keyserver.ubuntu.com \ - --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 + --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 || exit -1 sudo add-apt-repository \ - "deb ${CRAN_MIRROR}/bin/linux/ubuntu ${R_APT_REPO}" + "deb ${CRAN_MIRROR}/bin/linux/ubuntu ${R_APT_REPO}" || exit -1 sudo apt-get update sudo apt-get install \ --no-install-recommends \ - -y --allow-downgrades \ + -y \ devscripts \ + r-base-core=${R_LINUX_VERSION} \ r-base-dev=${R_LINUX_VERSION} \ texinfo \ texlive-latex-extra \ @@ -60,8 +61,18 @@ if [[ $OS_NAME == "linux" ]]; then --no-install-recommends \ -y \ autoconf=$(cat R-package/AUTOCONF_UBUNTU_VERSION) \ + automake \ || exit -1 fi + if [[ $INSTALL_CMAKE_FROM_RELEASES == "true" ]]; then + curl -O -L \ + https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-x86_64.sh \ + || exit -1 + + sudo mkdir /opt/cmake || exit -1 + sudo sh cmake-3.25.1-linux-x86_64.sh --skip-license --prefix=/opt/cmake || exit -1 + sudo ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake || exit -1 + fi fi # Installing R precompiled for Mac OS 10.11 or higher @@ -211,6 +222,27 @@ if [[ $check_succeeded == "no" ]]; then exit -1 fi +used_correct_r_version=$( + cat $LOG_FILE_NAME \ + | grep --count "using R version ${R_VERSION}" +) +if [[ $used_correct_r_version -ne 1 ]]; then + echo "Unexpected R version was used. Expected '${R_VERSION}'." + exit -1 +fi + +if [[ $R_BUILD_TYPE == "cmake" ]]; then + passed_correct_r_version_to_cmake=$( + cat $BUILD_LOG_FILE \ + | grep --count "R version passed into FindLibR.cmake: ${R_VERSION}" + ) + if [[ $used_correct_r_version -ne 1 ]]; then + echo "Unexpected R version was passed into cmake. Expected '${R_VERSION}'." + exit -1 + fi +fi + + if grep -q -E "NOTE|WARNING|ERROR" "$LOG_FILE_NAME"; then echo "NOTEs, WARNINGs, or ERRORs have been found by R CMD check" exit -1 diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 72d24eb9a39a..ab21f37141cc 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -30,6 +30,7 @@ jobs: test: name: ${{ matrix.task }} (${{ matrix.os }}, ${{ matrix.compiler }}, R ${{ matrix.r_version }}, ${{ matrix.build_type }}) runs-on: ${{ matrix.os }} + container: ${{ matrix.container }} timeout-minutes: 60 strategy: fail-fast: false @@ -38,58 +39,68 @@ jobs: ################ # CMake builds # ################ - - os: ubuntu-22.04 + - os: ubuntu-latest task: r-package compiler: gcc r_version: 3.6 build_type: cmake - - os: ubuntu-22.04 + container: 'ubuntu:18.04' + - os: ubuntu-latest task: r-package compiler: gcc r_version: 4.2 build_type: cmake - - os: ubuntu-22.04 + container: 'ubuntu:22.04' + - os: ubuntu-latest task: r-package compiler: clang r_version: 3.6 build_type: cmake - - os: ubuntu-22.04 + container: 'ubuntu:18.04' + - os: ubuntu-latest task: r-package compiler: clang r_version: 4.2 build_type: cmake + container: 'ubuntu:22.04' - os: macOS-latest task: r-package compiler: gcc r_version: 3.6 build_type: cmake + container: null - os: macOS-latest task: r-package compiler: gcc r_version: 4.2 build_type: cmake + container: null - os: macOS-latest task: r-package compiler: clang r_version: 3.6 build_type: cmake + container: null - os: macOS-latest task: r-package compiler: clang r_version: 4.2 build_type: cmake + container: null - os: windows-latest task: r-package compiler: MINGW toolchain: MINGW r_version: 3.6 build_type: cmake + container: null - os: windows-latest task: r-package compiler: MINGW toolchain: MSYS r_version: 4.2 build_type: cmake + container: null # Visual Studio 2019 - os: windows-2019 task: r-package @@ -97,6 +108,7 @@ jobs: toolchain: MSVC r_version: 3.6 build_type: cmake + container: null # Visual Studio 2022 - os: windows-2022 task: r-package @@ -104,6 +116,7 @@ jobs: toolchain: MSVC r_version: 4.2 build_type: cmake + container: null ############### # CRAN builds # ############### @@ -113,35 +126,64 @@ jobs: toolchain: MINGW r_version: 3.6 build_type: cran + container: null - os: windows-latest task: r-package compiler: MINGW toolchain: MSYS r_version: 4.2 build_type: cran - - os: ubuntu-22.04 + container: null + - os: ubuntu-latest task: r-package compiler: gcc r_version: 4.2 build_type: cran + container: 'ubuntu:22.04' - os: macOS-latest task: r-package compiler: clang r_version: 4.2 build_type: cran + container: null ################ # Other checks # ################ - - os: ubuntu-22.04 + - os: ubuntu-latest task: r-rchk compiler: gcc r_version: 4.2 build_type: cran + container: 'ubuntu:22.04' steps: - name: Prevent conversion of line endings on Windows if: startsWith(matrix.os, 'windows') shell: pwsh run: git config --global core.autocrlf false + - name: Install packages used by third-party actions + if: startsWith(matrix.os, 'ubuntu') + shell: bash + run: | + apt-get update -y + apt-get install --no-install-recommends -y \ + ca-certificates \ + dirmngr \ + gpg \ + gpg-agent \ + software-properties-common \ + sudo + # install newest version of git + # ref: + # - https://unix.stackexchange.com/a/170831/550004 + # - https://git-scm.com/download/linux + add-apt-repository ppa:git-core/ppa -y + apt-get update -y + apt-get install --no-install-recommends -y \ + git + - name: Trust git cloning LightGBM + if: startsWith(matrix.os, 'ubuntu') + run: | + git config --global --add safe.directory "${GITHUB_WORKSPACE}" - name: Checkout repository uses: actions/checkout@v3 with: @@ -156,7 +198,7 @@ jobs: CTAN_MIRROR: https://ctan.math.illinois.edu/systems/win32/miktex TINYTEX_INSTALLER: TinyTeX - name: Setup and run tests on Linux and macOS - if: matrix.os == 'macOS-latest' || matrix.os == 'ubuntu-22.04' + if: matrix.os == 'macOS-latest' || matrix.os == 'ubuntu-latest' shell: bash run: | export TASK="${{ matrix.task }}" @@ -164,8 +206,14 @@ jobs: export GITHUB_ACTIONS="true" if [[ "${{ matrix.os }}" == "macOS-latest" ]]; then export OS_NAME="macos" - elif [[ "${{ matrix.os }}" == "ubuntu-22.04" ]]; then + elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then export OS_NAME="linux" + export IN_UBUNTU_BASE_CONTAINER="true" + # the default version of cmake provided on Ubuntu 18.04 (v3.10.2), is not supported by LightGBM + # see https://github.com/microsoft/LightGBM/issues/5642 + if [[ "${{ matrix.container }}" == "ubuntu:18.04" ]]; then + export INSTALL_CMAKE_FROM_RELEASES="true" + fi fi export BUILD_DIRECTORY="$GITHUB_WORKSPACE" export R_VERSION="${{ matrix.r_version }}"