lightgbm-org--lightgbm
396 行
14 KiB
YAML
396 行
14 KiB
YAML
name: R-package
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- master
|
|
|
|
# automatically cancel in-progress builds if another commit is pushed
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
# default to 0 permissions
|
|
# (job-level overrides add the minimal permissions needed)
|
|
permissions:
|
|
contents: none
|
|
|
|
env:
|
|
# tell scripts where to put artifacts
|
|
# (this variable name is left over from when jobs ran on Azure DevOps)
|
|
BUILD_ARTIFACTSTAGINGDIRECTORY: '${{ github.workspace }}/artifacts'
|
|
# in CMake-driven builds, parallelize compilation
|
|
CMAKE_BUILD_PARALLEL_LEVEL: 4
|
|
# on Debian-based images, avoid interactive prompts
|
|
DEBIAN_FRONTEND: noninteractive
|
|
# Fix issues like the following that can show up running 'R CMD check' on
|
|
# specific clang versions:
|
|
#
|
|
# * checking for detritus in the temp directory ... NOTE
|
|
# Found the following files/directories:
|
|
# ‘dsymutil-63923a’ ‘dsymutil-9aa721’ ‘dsymutil-b7e1bb’
|
|
#
|
|
# These are unlikely to show up in CRAN's checks. They come from
|
|
# 'dsymutil ---gen-reproducer' being run (not something LightGBM explicitly does).
|
|
#
|
|
# ref:
|
|
# - https://github.com/llvm/llvm-project/issues/61920
|
|
# - https://github.com/golang/go/issues/59026#issuecomment-1520487072
|
|
DSYMUTIL_REPRODUCER_PATH: /dev/null
|
|
# parallelize compilation (extra important for Linux, where CRAN doesn't supply pre-compiled binaries)
|
|
MAKEFLAGS: "-j4"
|
|
# hack to get around this:
|
|
# https://stat.ethz.ch/pipermail/r-package-devel/2020q3/005930.html
|
|
_R_CHECK_SYSTEM_CLOCK_: 0
|
|
# ignore R CMD CHECK NOTE checking how long it has
|
|
# been since the last submission
|
|
_R_CHECK_CRAN_INCOMING_REMOTE_: 0
|
|
# CRAN ignores the "installed size is too large" NOTE,
|
|
# so our CI can too. Setting to a large value here just
|
|
# to catch extreme problems
|
|
_R_CHECK_PKG_SIZES_THRESHOLD_: 100
|
|
|
|
jobs:
|
|
test:
|
|
# yamllint disable-line rule:line-length
|
|
name: ${{ matrix.task }} (${{ matrix.os-display-name || matrix.os }}, ${{ matrix.compiler }}, R ${{ matrix.r_version }}, ${{ matrix.build_type }})
|
|
runs-on: ${{ matrix.os }}
|
|
container: ${{ matrix.container }}
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: write
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
################
|
|
# CMake builds #
|
|
################
|
|
- os: ubuntu-latest
|
|
task: r-package
|
|
compiler: gcc
|
|
r_version: 4.3
|
|
build_type: cmake
|
|
container: 'ubuntu:22.04'
|
|
os-display-name: 'ubuntu22.04'
|
|
- os: ubuntu-latest
|
|
task: r-package
|
|
compiler: clang
|
|
r_version: 4.3
|
|
build_type: cmake
|
|
container: 'ubuntu:22.04'
|
|
os-display-name: 'ubuntu22.04'
|
|
- os: macos-15-intel
|
|
task: r-package
|
|
compiler: clang
|
|
r_version: 4.3
|
|
build_type: cmake
|
|
container: null
|
|
- os: windows-latest
|
|
task: r-package
|
|
compiler: MINGW
|
|
toolchain: MSYS
|
|
r_version: 4.3
|
|
build_type: cmake
|
|
container: null
|
|
# Visual Studio 2022
|
|
- os: windows-2022
|
|
task: r-package
|
|
compiler: MSVC
|
|
toolchain: MSVC
|
|
r_version: 4.3
|
|
build_type: cmake
|
|
container: null
|
|
###############
|
|
# CRAN builds #
|
|
###############
|
|
- os: windows-latest
|
|
task: r-package
|
|
compiler: MINGW
|
|
toolchain: MSYS
|
|
r_version: 4.3
|
|
build_type: cran
|
|
container: null
|
|
- os: ubuntu-latest
|
|
task: r-package
|
|
compiler: gcc
|
|
r_version: 4.3
|
|
build_type: cran
|
|
container: 'ubuntu:22.04'
|
|
os-display-name: 'ubuntu22.04'
|
|
produces-artifacts: 'true'
|
|
artifact-name: r-cran-package
|
|
- os: macos-15-intel
|
|
task: r-package
|
|
compiler: clang
|
|
r_version: 4.3
|
|
build_type: cran
|
|
container: null
|
|
# macos-14 = arm64
|
|
- os: macos-14
|
|
task: r-package
|
|
compiler: clang
|
|
r_version: 4.3
|
|
build_type: cran
|
|
container: null
|
|
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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
with:
|
|
fetch-depth: 5
|
|
persist-credentials: false
|
|
submodules: true
|
|
- name: Install pandoc
|
|
uses: r-lib/actions/setup-pandoc@a51a8012b0aab7c32ef9d19bf54da93f3254335e # v2.12.0
|
|
- name: Install tinytex
|
|
if: startsWith(matrix.os, 'windows')
|
|
uses: r-lib/actions/setup-tinytex@a51a8012b0aab7c32ef9d19bf54da93f3254335e # v2.12.0
|
|
env:
|
|
CTAN_MIRROR: https://ctan.math.illinois.edu/systems/win32/miktex
|
|
TINYTEX_INSTALLER: TinyTeX
|
|
- name: Setup and run tests on Linux and macOS
|
|
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
|
|
shell: bash
|
|
run: |
|
|
export TASK="${{ matrix.task }}"
|
|
export COMPILER="${{ matrix.compiler }}"
|
|
if [[ "${{ matrix.os }}" =~ ^macos ]]; then
|
|
export OS_NAME="macos"
|
|
elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
|
|
export OS_NAME="linux"
|
|
export IN_UBUNTU_BASE_CONTAINER="true"
|
|
fi
|
|
export BUILD_DIRECTORY="$GITHUB_WORKSPACE"
|
|
export LGB_VER=$(head -n 1 "${BUILD_DIRECTORY}/VERSION.txt")
|
|
export PRODUCES_ARTIFACTS="${{ matrix.produces-artifacts }}"
|
|
export R_VERSION="${{ matrix.r_version }}"
|
|
export R_BUILD_TYPE="${{ matrix.build_type }}"
|
|
$GITHUB_WORKSPACE/.ci/setup.sh
|
|
$GITHUB_WORKSPACE/.ci/test.sh
|
|
- name: Setup and run tests on Windows
|
|
if: startsWith(matrix.os, 'windows')
|
|
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 }}"
|
|
$env:COMPILER = "${{ matrix.compiler }}"
|
|
$env:TASK = "${{ matrix.task }}"
|
|
& "$env:GITHUB_WORKSPACE/.ci/test-windows.ps1"
|
|
- name: Upload artifacts
|
|
if: ${{ matrix.produces-artifacts == 'true' }}
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: ${{ matrix.artifact-name }}
|
|
path: ${{ env.BUILD_ARTIFACTSTAGINGDIRECTORY }}/*.tar.gz
|
|
if-no-files-found: error
|
|
test-r-sanitizers:
|
|
name: r-sanitizers (ubuntu-latest, R-devel, ${{ matrix.compiler }} ASAN/UBSAN)
|
|
timeout-minutes: 60
|
|
runs-on: ubuntu-latest
|
|
container: wch1/r-debug # zizmor: ignore[unpinned-images]
|
|
permissions:
|
|
contents: read
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- r_customization: san
|
|
compiler: gcc
|
|
- r_customization: csan
|
|
compiler: clang
|
|
steps:
|
|
- name: Trust git cloning LightGBM
|
|
run: |
|
|
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
|
|
- name: Checkout repository
|
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
with:
|
|
fetch-depth: 5
|
|
persist-credentials: false
|
|
submodules: true
|
|
- name: Install packages
|
|
shell: bash
|
|
run: |
|
|
RDscript${{ matrix.r_customization }} ./.ci/install-r-deps.R --build --test
|
|
sh build-cran-package.sh --r-executable=RD${{ matrix.r_customization }}
|
|
RD${{ matrix.r_customization }} CMD INSTALL lightgbm_*.tar.gz || exit 1
|
|
- name: Run tests with sanitizers
|
|
shell: bash
|
|
run: |
|
|
cd R-package/tests
|
|
exit_code=0
|
|
RDscript${{ matrix.r_customization }} testthat.R >> tests.log 2>&1 || exit_code=-1
|
|
cat ./tests.log
|
|
exit ${exit_code}
|
|
test-r-extra-checks:
|
|
name: r-package (${{ matrix.image }}, R-devel)
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: read
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# references:
|
|
# * CRAN "additional checks": https://cran.r-project.org/web/checks/check_issue_kinds.html
|
|
# * images: https://r-hub.github.io/containers/containers.html
|
|
#
|
|
# Generally, only images that are still supported, listed at
|
|
# https://r-hub.github.io/containers/#available-containers, should be used.
|
|
image:
|
|
- clang21
|
|
- clang22
|
|
- gcc16
|
|
- rchk
|
|
- ubuntu-clang
|
|
- ubuntu-gcc12
|
|
runs-on: ubuntu-latest
|
|
container: ghcr.io/r-hub/containers/${{ matrix.image }}:latest # zizmor: ignore[unpinned-images]
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
with:
|
|
fetch-depth: 5
|
|
persist-credentials: false
|
|
submodules: true
|
|
- name: Install pandoc
|
|
uses: r-lib/actions/setup-pandoc@a51a8012b0aab7c32ef9d19bf54da93f3254335e # v2.12.0
|
|
- name: Install system dependencies
|
|
shell: bash
|
|
run: |
|
|
# libuv is needed for {fs} (https://github.com/lightgbm-org/LightGBM/issues/7208)
|
|
if type -f apt 2>&1 > /dev/null; then
|
|
apt-get update
|
|
apt-get install --no-install-recommends -y \
|
|
cmake \
|
|
devscripts \
|
|
libcurl4-openssl-dev \
|
|
libuv1-dev \
|
|
texinfo \
|
|
texlive-latex-extra \
|
|
texlive-latex-recommended \
|
|
texlive-fonts-recommended \
|
|
texlive-fonts-extra \
|
|
tidy \
|
|
qpdf
|
|
else
|
|
yum update -y
|
|
yum install -y \
|
|
cmake \
|
|
devscripts \
|
|
libcurl-devel \
|
|
libuv-devel \
|
|
qpdf \
|
|
texinfo \
|
|
texinfo-tex \
|
|
texlive-amsmath \
|
|
texlive-amsfonts \
|
|
texlive-collection-fontsrecommended \
|
|
texlive-collection-latexrecommended \
|
|
texlive-latex \
|
|
tidy
|
|
fi
|
|
- name: Install packages and run tests
|
|
shell: bash
|
|
run: |
|
|
Rscript ./.ci/install-r-deps.R --build --test --exclude=testthat
|
|
sh build-cran-package.sh
|
|
|
|
# 'rchk' isn't run through 'R CMD check', use the approach documented at
|
|
# https://r-hub.github.io/containers/local.html
|
|
if [[ "${{ matrix.image }}" =~ "rchk" ]]; then
|
|
r-check "$(pwd)" \
|
|
| tee ./rchk-logs.txt 2>&1
|
|
|
|
# the '-v' exceptions below are from R/rchk itself and not LightGBM:
|
|
# https://github.com/kalibera/rchk/issues/22#issuecomment-656036156
|
|
if grep -E '\[PB\]|ERROR' ./rchk-logs.txt \
|
|
| grep -v 'too many states' \
|
|
> /dev/null; \
|
|
then
|
|
echo "rchk found issues"
|
|
exit 1
|
|
else
|
|
echo "rchk did not find any issues"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# why these packages?
|
|
#
|
|
# - 'curl' is not a dependency of {lightgbm}, but it's needed for 'R CMD check' URL checks
|
|
# - 'testthat' is not needed by 'rchk', so avoid installing it until here
|
|
#
|
|
Rscript -e "
|
|
install.packages(c('curl', 'testthat'),
|
|
repos = 'https://cran.rstudio.com',
|
|
Ncpus = parallel::detectCores())
|
|
"
|
|
|
|
if [[ "${{ matrix.image }}" =~ "clang" ]]; then
|
|
# allowing the following NOTEs (produced by default in the clang images):
|
|
#
|
|
# * checking compilation flags used ... NOTE
|
|
# Compilation used the following non-portable flag(s):
|
|
# ‘-Wp,-D_FORTIFY_SOURCE=3’
|
|
#
|
|
# even though CRAN itself sets that:
|
|
# https://www.stats.ox.ac.uk/pub/bdr/Rconfig/r-devel-linux-x86_64-fedora-clang
|
|
#
|
|
declare -i allowed_notes=1
|
|
else
|
|
declare -i allowed_notes=0
|
|
fi
|
|
|
|
bash .ci/run-r-cmd-check.sh \
|
|
"$(echo lightgbm_$(head -1 VERSION.txt).tar.gz)" \
|
|
"${allowed_notes}"
|
|
all-r-package-jobs-successful:
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- test
|
|
- test-r-sanitizers
|
|
- test-r-extra-checks
|
|
permissions:
|
|
statuses: read
|
|
steps:
|
|
- name: Note that all tests succeeded
|
|
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
|
|
with:
|
|
jobs: ${{ toJSON(needs) }}
|