From b0043a6ff5b928e28f2e016b25567154e825551e Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 13 Oct 2021 23:28:29 -0500 Subject: [PATCH 01/12] add jobs mimicking CRAN gcc-ASAN and clang-ASAN --- .github/workflows/r_package.yml | 41 ++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 0c60471897f0..a544a16100bd 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -173,16 +173,29 @@ jobs: $env:TASK = "${{ matrix.task }}" & "$env:GITHUB_WORKSPACE/.ci/test_windows.ps1" test-r-sanitizers: - name: r-package (ubuntu-latest, R-devel, GCC ASAN/UBSAN) - timeout-minutes: 60 + name: r-package (ubuntu-latest, R-devel, ${{ matrix.compiler }} ASAN/UBSAN) runs-on: ubuntu-latest - container: rhub/rocker-gcc-san + container: wch1/r-debug + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + ################ + # CMake builds # + ################ + - r_customization: san + compiler: gcc + - r_customization: csan + compiler: clang + env: + # env variables from CRAN's configuration: https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt + ASAN_OPTIONS: "detect_leaks=0:detect_odr_violation=0" + UBSAN_OPTIONS: "print_stacktrace=1" + RJAVA_JVM_STACK_WORKAROUND: 0 + RGL_USE_NULL: true + R_DONT_USE_TK: true steps: - - name: Install Git before checkout - shell: bash - run: | - apt-get update --allow-releaseinfo-change - apt-get install --no-install-recommends -y git - name: Checkout repository uses: actions/checkout@v2.3.4 with: @@ -191,16 +204,18 @@ jobs: - name: Install packages shell: bash run: | - Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" + RDscript${{ matrix.r_customization }} -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" sh build-cran-package.sh - Rdevel CMD INSTALL lightgbm_*.tar.gz || exit -1 + RD${{ matrix.r_customization }} CMD INSTALL lightgbm_*.tar.gz || exit -1 - name: Run tests with sanitizers shell: bash run: | cd R-package/tests - Rscriptdevel testthat.R 2>&1 > ubsan-tests.log - cat ubsan-tests.log - exit $(cat ubsan-tests.log | grep --count "runtime error") + exit_code=$( + RDscript${{ matrix.r_customization }} testthat.R >> tests.log 2>&1 + ) + cat ./tests.log + exit ${exit_code} test-r-debian-clang: name: r-package (debian, R-devel, clang) timeout-minutes: 60 From 899fbb4574b99a8125b28761425e3e821bfdfef1 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 13 Oct 2021 23:30:55 -0500 Subject: [PATCH 02/12] comment out CI --- .appveyor.yml | 43 --- .github/workflows/cuda.yml | 103 ------- .github/workflows/python_package.yml | 79 ------ .github/workflows/r_package.yml | 358 +++++++++++------------ .github/workflows/static_analysis.yml | 85 ------ .vsts-ci.yml | 390 -------------------------- 6 files changed, 179 insertions(+), 879 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .github/workflows/cuda.yml delete mode 100644 .github/workflows/python_package.yml delete mode 100644 .github/workflows/static_analysis.yml delete mode 100644 .vsts-ci.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 229a495588a8..000000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,43 +0,0 @@ -version: 3.3.0.99.{build} - -image: Visual Studio 2015 -platform: x64 -configuration: # a trick to construct a build matrix with multiple Python versions - - 3.7 - -# only build pull requests and -# commits to 'master' -branches: - only: - - master - -environment: - matrix: - - COMPILER: MSVC - TASK: python - - COMPILER: MINGW - TASK: python - -clone_depth: 5 - -install: - - git submodule update --init --recursive # get `external_libs` folder - - set PATH=%PATH:C:\Program Files\Git\usr\bin;=% # delete sh.exe from PATH (mingw32-make fix) - - set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH% - - set PYTHON_VERSION=%CONFIGURATION% - - set CONDA_ENV="test-env" - - ps: | - switch ($env:PYTHON_VERSION) { - "3.6" {$env:MINICONDA = "C:\Miniconda36-x64"} - "3.7" {$env:MINICONDA = "C:\Miniconda37-x64"} - default {$env:MINICONDA = "C:\Miniconda37-x64"} - } - $env:PATH = "$env:MINICONDA;$env:MINICONDA\Scripts;$env:PATH" - $env:BUILD_SOURCESDIRECTORY = "$env:APPVEYOR_BUILD_FOLDER" - $env:LGB_VER = (Get-Content $env:APPVEYOR_BUILD_FOLDER\VERSION.txt).trim() - -build: false - -test_script: - - conda init powershell - - powershell.exe -ExecutionPolicy Bypass -File %APPVEYOR_BUILD_FOLDER%\.ci\test_windows.ps1 diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml deleted file mode 100644 index 822ea2d44b82..000000000000 --- a/.github/workflows/cuda.yml +++ /dev/null @@ -1,103 +0,0 @@ -name: CUDA Version - -on: - push: - branches: - - master - pull_request: - branches: - - master - -env: - github_actions: 'true' - os_name: linux - task: cuda - conda_env: test-env - -jobs: - test: - name: cuda ${{ matrix.cuda_version }} ${{ matrix.method }} (linux, ${{ matrix.compiler }}, Python ${{ matrix.python_version }}) - runs-on: [self-hosted, linux] - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - method: source - compiler: gcc - python_version: 3.7 - cuda_version: "11.4.2" - - method: pip - compiler: clang - python_version: 3.8 - cuda_version: "10.0" - - method: wheel - compiler: gcc - python_version: 3.9 - cuda_version: "9.0" - steps: - - name: Setup or update software on host machine - run: | - sudo apt-get update - sudo apt-get install --no-install-recommends -y \ - apt-transport-https \ - ca-certificates \ - curl \ - git \ - gnupg-agent \ - lsb-release \ - software-properties-common - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -y - curl -sL https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - - curl -sL https://nvidia.github.io/nvidia-docker/$(. /etc/os-release;echo $ID$VERSION_ID)/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list - sudo apt-get update - sudo apt-get install --no-install-recommends -y \ - containerd.io \ - docker-ce \ - docker-ce-cli \ - nvidia-docker2 - sudo chmod a+rw /var/run/docker.sock - sudo systemctl restart docker - - name: Remove old folder with repository - run: sudo rm -rf $GITHUB_WORKSPACE - - name: Checkout repository - uses: actions/checkout@v1 - with: - fetch-depth: 5 - submodules: true - - name: Setup and run tests - run: | - export ROOT_DOCKER_FOLDER=/LightGBM - cat > docker.env < docker-script.sh < docker.env < docker-script.sh < Date: Wed, 13 Oct 2021 23:48:25 -0500 Subject: [PATCH 03/12] fix redirection --- .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 b5fb88f8b612..40f597756f92 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -210,10 +210,10 @@ jobs: - name: Run tests with sanitizers shell: bash run: | + echo "running" cd R-package/tests - exit_code=$( - RDscript${{ matrix.r_customization }} testthat.R >> tests.log 2>&1 - ) + exit_code=0 + RDscript${{ matrix.r_customization }} testthat.R >> tests.log 2>&1 || exit_code=1 cat ./tests.log exit ${exit_code} # test-r-debian-clang: From eeb15a25d4a63ccc5d07f1695938f8ad06a4557c Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 14 Oct 2021 00:16:44 -0500 Subject: [PATCH 04/12] remove unnecessary echo --- .github/workflows/r_package.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 40f597756f92..b281abfa1c2e 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -210,7 +210,6 @@ jobs: - name: Run tests with sanitizers shell: bash run: | - echo "running" cd R-package/tests exit_code=0 RDscript${{ matrix.r_customization }} testthat.R >> tests.log 2>&1 || exit_code=1 From c02e83f204fcfafbc066b387f7bcc962e695f02c Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 14 Oct 2021 00:18:57 -0500 Subject: [PATCH 05/12] Revert "comment out CI" This reverts commit 899fbb4574b99a8125b28761425e3e821bfdfef1. --- .appveyor.yml | 43 +++ .github/workflows/cuda.yml | 103 +++++++ .github/workflows/python_package.yml | 79 ++++++ .github/workflows/r_package.yml | 358 +++++++++++------------ .github/workflows/static_analysis.yml | 85 ++++++ .vsts-ci.yml | 390 ++++++++++++++++++++++++++ 6 files changed, 879 insertions(+), 179 deletions(-) create mode 100644 .appveyor.yml create mode 100644 .github/workflows/cuda.yml create mode 100644 .github/workflows/python_package.yml create mode 100644 .github/workflows/static_analysis.yml create mode 100644 .vsts-ci.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000000..229a495588a8 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,43 @@ +version: 3.3.0.99.{build} + +image: Visual Studio 2015 +platform: x64 +configuration: # a trick to construct a build matrix with multiple Python versions + - 3.7 + +# only build pull requests and +# commits to 'master' +branches: + only: + - master + +environment: + matrix: + - COMPILER: MSVC + TASK: python + - COMPILER: MINGW + TASK: python + +clone_depth: 5 + +install: + - git submodule update --init --recursive # get `external_libs` folder + - set PATH=%PATH:C:\Program Files\Git\usr\bin;=% # delete sh.exe from PATH (mingw32-make fix) + - set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH% + - set PYTHON_VERSION=%CONFIGURATION% + - set CONDA_ENV="test-env" + - ps: | + switch ($env:PYTHON_VERSION) { + "3.6" {$env:MINICONDA = "C:\Miniconda36-x64"} + "3.7" {$env:MINICONDA = "C:\Miniconda37-x64"} + default {$env:MINICONDA = "C:\Miniconda37-x64"} + } + $env:PATH = "$env:MINICONDA;$env:MINICONDA\Scripts;$env:PATH" + $env:BUILD_SOURCESDIRECTORY = "$env:APPVEYOR_BUILD_FOLDER" + $env:LGB_VER = (Get-Content $env:APPVEYOR_BUILD_FOLDER\VERSION.txt).trim() + +build: false + +test_script: + - conda init powershell + - powershell.exe -ExecutionPolicy Bypass -File %APPVEYOR_BUILD_FOLDER%\.ci\test_windows.ps1 diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml new file mode 100644 index 000000000000..822ea2d44b82 --- /dev/null +++ b/.github/workflows/cuda.yml @@ -0,0 +1,103 @@ +name: CUDA Version + +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + github_actions: 'true' + os_name: linux + task: cuda + conda_env: test-env + +jobs: + test: + name: cuda ${{ matrix.cuda_version }} ${{ matrix.method }} (linux, ${{ matrix.compiler }}, Python ${{ matrix.python_version }}) + runs-on: [self-hosted, linux] + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + - method: source + compiler: gcc + python_version: 3.7 + cuda_version: "11.4.2" + - method: pip + compiler: clang + python_version: 3.8 + cuda_version: "10.0" + - method: wheel + compiler: gcc + python_version: 3.9 + cuda_version: "9.0" + steps: + - name: Setup or update software on host machine + run: | + sudo apt-get update + sudo apt-get install --no-install-recommends -y \ + apt-transport-https \ + ca-certificates \ + curl \ + git \ + gnupg-agent \ + lsb-release \ + software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -y + curl -sL https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - + curl -sL https://nvidia.github.io/nvidia-docker/$(. /etc/os-release;echo $ID$VERSION_ID)/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list + sudo apt-get update + sudo apt-get install --no-install-recommends -y \ + containerd.io \ + docker-ce \ + docker-ce-cli \ + nvidia-docker2 + sudo chmod a+rw /var/run/docker.sock + sudo systemctl restart docker + - name: Remove old folder with repository + run: sudo rm -rf $GITHUB_WORKSPACE + - name: Checkout repository + uses: actions/checkout@v1 + with: + fetch-depth: 5 + submodules: true + - name: Setup and run tests + run: | + export ROOT_DOCKER_FOLDER=/LightGBM + cat > docker.env < docker-script.sh <> tests.log 2>&1 || exit_code=1 cat ./tests.log exit ${exit_code} - # test-r-debian-clang: - # name: r-package (debian, R-devel, clang) - # timeout-minutes: 60 - # runs-on: ubuntu-latest - # container: rhub/debian-clang-devel - # steps: - # - name: Install Git before checkout - # shell: bash - # run: | - # apt-get update --allow-releaseinfo-change - # apt-get install --no-install-recommends -y git - # - name: Checkout repository - # uses: actions/checkout@v2.3.4 - # with: - # fetch-depth: 5 - # submodules: true - # - name: Install packages and run tests - # shell: bash - # run: | - # export PATH=/opt/R-devel/bin/:${PATH} - # Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" - # sh build-cran-package.sh - # R CMD check --as-cran --run-donttest lightgbm_*.tar.gz || exit -1 - # if grep -q -E "NOTE|WARNING|ERROR" lightgbm.Rcheck/00check.log; then - # echo "NOTEs, WARNINGs, or ERRORs have been found by R CMD check" - # exit -1 - # fi + test-r-debian-clang: + name: r-package (debian, R-devel, clang) + timeout-minutes: 60 + runs-on: ubuntu-latest + container: rhub/debian-clang-devel + steps: + - name: Install Git before checkout + shell: bash + run: | + apt-get update --allow-releaseinfo-change + apt-get install --no-install-recommends -y git + - name: Checkout repository + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 5 + submodules: true + - name: Install packages and run tests + shell: bash + run: | + export PATH=/opt/R-devel/bin/:${PATH} + Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" + sh build-cran-package.sh + R CMD check --as-cran --run-donttest lightgbm_*.tar.gz || exit -1 + if grep -q -E "NOTE|WARNING|ERROR" lightgbm.Rcheck/00check.log; then + echo "NOTEs, WARNINGs, or ERRORs have been found by R CMD check" + exit -1 + fi all-successful: # https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert runs-on: ubuntu-latest - needs: [test-r-sanitizers] + needs: [test, test-r-sanitizers, test-r-debian-clang] steps: - name: Note that all tests succeeded run: echo "🎉" diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml new file mode 100644 index 000000000000..cdc917903f46 --- /dev/null +++ b/.github/workflows/static_analysis.yml @@ -0,0 +1,85 @@ +# contains non-functional tests, like checks on docs +# and code style +name: Static Analysis + +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + COMPILER: 'gcc' + CONDA_ENV: test-env + GITHUB_ACTIONS: 'true' + OS_NAME: 'linux' + PYTHON_VERSION: 3.9 + +jobs: + test: + name: ${{ matrix.task }} + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + - task: lint + - task: check-docs + steps: + - name: Checkout repository + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 5 + submodules: false + - name: Setup and run tests + shell: bash + run: | + export TASK="${{ matrix.task }}" + export BUILD_DIRECTORY="$GITHUB_WORKSPACE" + export CONDA=${HOME}/miniconda + export PATH=${CONDA}/bin:$HOME/.local/bin:${PATH} + $GITHUB_WORKSPACE/.ci/setup.sh || exit -1 + $GITHUB_WORKSPACE/.ci/test.sh || exit -1 + r-check-docs: + name: r-package-check-docs + timeout-minutes: 60 + runs-on: ubuntu-latest + container: rocker/verse + steps: + - name: Checkout repository + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 5 + submodules: true + - name: Install packages + shell: bash + run: | + Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'roxygen2', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" + sh build-cran-package.sh || exit -1 + R CMD INSTALL --with-keep.source lightgbm_*.tar.gz || exit -1 + - name: Test documentation + shell: bash --noprofile --norc {0} + run: | + Rscript --vanilla -e "roxygen2::roxygenize('R-package/', load = 'installed')" || exit -1 + num_doc_files_changed=$( + git diff --name-only | grep --count -E "\.Rd|NAMESPACE" + ) + if [[ ${num_doc_files_changed} -gt 0 ]]; then + echo "Some R documentation files have changed. Please re-generate them and commit those changes." + echo "" + echo " sh build-cran-package.sh" + echo " R CMD INSTALL --with-keep.source lightgbm_*.tar.gz" + echo " Rscript -e \"roxygen2::roxygenize('R-package/', load = 'installed')\"" + echo "" + exit -1 + fi + all-successful: + # https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert + runs-on: ubuntu-latest + needs: [test, r-check-docs] + steps: + - name: Note that all tests succeeded + run: echo "🎉" diff --git a/.vsts-ci.yml b/.vsts-ci.yml new file mode 100644 index 000000000000..059ebf9d35b4 --- /dev/null +++ b/.vsts-ci.yml @@ -0,0 +1,390 @@ +trigger: + branches: + include: + - master + tags: + include: + - v* +pr: +- master +variables: + AZURE: 'true' + PYTHON_VERSION: 3.9 + CONDA_ENV: test-env +resources: + containers: + - container: ubuntu1404 + image: lightgbm/vsts-agent:ubuntu-14.04 + - container: ubuntu-latest + image: 'ubuntu:latest' + options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro" + - container: rbase + image: rocker/r-base +jobs: +########################################### +- job: Linux +########################################### + variables: + COMPILER: gcc + SETUP_CONDA: 'false' + OS_NAME: 'linux' + PRODUCES_ARTIFACTS: 'true' + pool: sh-ubuntu + container: ubuntu1404 + strategy: + matrix: + regular: + TASK: regular + sdist: + TASK: sdist + PYTHON_VERSION: 3.7 + bdist: + TASK: bdist + inference: + TASK: if-else + mpi_source: + TASK: mpi + METHOD: source + PYTHON_VERSION: 3.8 + gpu_source: + TASK: gpu + METHOD: source + swig: + TASK: swig + steps: + - script: | + echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY" + echo "##vso[task.setvariable variable=LGB_VER]$(head -n 1 VERSION.txt)" + echo "##vso[task.prependpath]$CONDA/bin" + AMDAPPSDK_PATH=$BUILD_SOURCESDIRECTORY/AMDAPPSDK + echo "##vso[task.setvariable variable=AMDAPPSDK_PATH]$AMDAPPSDK_PATH" + LD_LIBRARY_PATH=$AMDAPPSDK_PATH/lib/x86_64:$LD_LIBRARY_PATH + echo "##vso[task.setvariable variable=LD_LIBRARY_PATH]$LD_LIBRARY_PATH" + echo "##vso[task.setvariable variable=OPENCL_VENDOR_PATH]$AMDAPPSDK_PATH/etc/OpenCL/vendors" + displayName: 'Set variables' + - bash: $(Build.SourcesDirectory)/.ci/setup.sh + displayName: Setup + - bash: $(Build.SourcesDirectory)/.ci/test.sh + displayName: Test + - task: PublishBuildArtifacts@1 + condition: and(succeeded(), in(variables['TASK'], 'regular', 'sdist', 'bdist', 'swig'), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))) + inputs: + pathtoPublish: '$(Build.ArtifactStagingDirectory)' + artifactName: PackageAssets + artifactType: container +########################################### +- job: Linux_latest +########################################### + variables: + COMPILER: clang + DEBIAN_FRONTEND: 'noninteractive' + IN_UBUNTU_LATEST_CONTAINER: 'true' + OS_NAME: 'linux' + SETUP_CONDA: 'true' + pool: sh-ubuntu + container: ubuntu-latest + strategy: + matrix: + regular: + TASK: regular + PYTHON_VERSION: 3.6 + sdist: + TASK: sdist + bdist: + TASK: bdist + PYTHON_VERSION: 3.8 + inference: + TASK: if-else + mpi_source: + TASK: mpi + METHOD: source + mpi_pip: + TASK: mpi + METHOD: pip + PYTHON_VERSION: 3.8 + mpi_wheel: + TASK: mpi + METHOD: wheel + PYTHON_VERSION: 3.7 + gpu_source: + TASK: gpu + METHOD: source + gpu_pip: + TASK: gpu + METHOD: pip + PYTHON_VERSION: 3.6 + gpu_wheel: + TASK: gpu + METHOD: wheel + PYTHON_VERSION: 3.7 + cpp_tests: + TASK: cpp-tests + METHOD: with-sanitizers + steps: + - script: | + echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY" + echo "##vso[task.setvariable variable=LGB_VER]$(head -n 1 VERSION.txt)" + CONDA=$HOME/miniconda + echo "##vso[task.setvariable variable=CONDA]$CONDA" + echo "##vso[task.prependpath]$CONDA/bin" + AMDAPPSDK_PATH=$BUILD_SOURCESDIRECTORY/AMDAPPSDK + echo "##vso[task.setvariable variable=AMDAPPSDK_PATH]$AMDAPPSDK_PATH" + LD_LIBRARY_PATH=$AMDAPPSDK_PATH/lib/x86_64:$LD_LIBRARY_PATH + echo "##vso[task.setvariable variable=LD_LIBRARY_PATH]$LD_LIBRARY_PATH" + echo "##vso[task.setvariable variable=OPENCL_VENDOR_PATH]$AMDAPPSDK_PATH/etc/OpenCL/vendors" + displayName: 'Set variables' + # https://github.com/microsoft/azure-pipelines-agent/issues/2043#issuecomment-687983301 + - script: | + /tmp/docker exec -t -u 0 ci-container \ + sh -c "apt-get update && apt-get -o Dpkg::Options::="--force-confold" -y install sudo" + displayName: 'Install sudo' + - bash: $(Build.SourcesDirectory)/.ci/setup.sh + displayName: Setup + - bash: $(Build.SourcesDirectory)/.ci/test.sh + displayName: Test +########################################### +- job: QEMU_multiarch +########################################### + variables: + COMPILER: gcc + OS_NAME: 'linux' + PRODUCES_ARTIFACTS: 'true' + pool: + vmImage: ubuntu-latest + timeoutInMinutes: 180 + strategy: + matrix: + bdist: + TASK: bdist + ARCH: aarch64 + steps: + - script: | + sudo apt-get update + sudo apt-get install --no-install-recommends -y \ + binfmt-support \ + qemu \ + qemu-user \ + qemu-user-static + displayName: 'Install QEMU' + - script: | + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + displayName: 'Enable Docker multi-architecture support' + - script: | + export ROOT_DOCKER_FOLDER=/LightGBM + cat > docker.env < docker-script.sh < Date: Thu, 21 Oct 2021 20:29:53 -0400 Subject: [PATCH 06/12] remove redundant env variables and update README --- .github/workflows/r_package.yml | 7 ----- R-package/README.md | 45 +++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index c3dd4e53faee..a117eb8e59d8 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -188,13 +188,6 @@ jobs: compiler: gcc - r_customization: csan compiler: clang - env: - # env variables from CRAN's configuration: https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt - ASAN_OPTIONS: "detect_leaks=0:detect_odr_violation=0" - UBSAN_OPTIONS: "print_stacktrace=1" - RJAVA_JVM_STACK_WORKAROUND: 0 - RGL_USE_NULL: true - R_DONT_USE_TK: true steps: - name: Checkout repository uses: actions/checkout@v2.3.4 diff --git a/R-package/README.md b/R-package/README.md index e761f1b910cd..ce894fb700df 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -363,24 +363,49 @@ Alternatively, GitHub Actions can run code above for you. On a pull request, cre #### UBSAN -All packages uploaded to CRAN must pass a build using `gcc` instrumented with two sanitizers: the Address Sanitizer (ASAN) and the Undefined Behavior Sanitizer (UBSAN). For more background, see [this blog post](http://dirk.eddelbuettel.com/code/sanitizers.html). +All packages uploaded to CRAN must pass builds using `gcc` and `clang`, instrumented with two sanitizers: the Address Sanitizer (ASAN) and the Undefined Behavior Sanitizer (UBSAN). + +For more background, see + +* [this blog post](http://dirk.eddelbuettel.com/code/sanitizers.html) +* [top-level CRAN documentation on these checks](https://cran.r-project.org/web/checks/check_issue_kinds.html) +* [CRAN's configuration of these checks](https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt) You can replicate these checks locally using Docker. +For more information on the image used for testing, see https://github.com/wch/r-debug. -```shell -docker run \ - -v $(pwd):/opt/LightGBM \ - -w /opt/LightGBM \ - -it rhub/rocker-gcc-san \ - /bin/bash +In the code below, environment variable `R_CUSTOMIZATION` should be set to one of two environment variables. -Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.rstudio.com', Ncpus = parallel::detectCores())" +* `"san"` = replicates CRAN's `gcc-ASAN` and `gcc-UBSAN` checks +* `"csan"` = replicates CRAN's `clang-ASAN` and `clang-UBSAN` checks +```shell +docker run \ + --rm \ + -it \ + -v $(pwd):/opt/LightGBM \ + -w /opt/LightGBM \ + --env R_CUSTOMIZATION=san \ + wch1/r-debug:latest \ + /bin/bash + +# install dependencies +RDscript${R_CUSTOMIZATION} \ + -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())" + +# install lightgbm sh build-cran-package.sh +RD${R_CUSTOMIZATION} \ + CMD INSTALL lightgbm_*.tar.gz -Rdevel CMD install lightgbm_*.tar.gz +# run tests cd R-package/tests -Rscriptdevel testthat.R +rm -f ./tests.log +RDscript${R_CUSTOMIZATION} testthat.R >> tests.log 2>&1 + +# check that tests passed +echo "test exit code: $?" +tail -300 ./tests.log ``` #### Valgrind From cec4267f7733c8cef8e6b1332a02e1a08f76ac2a Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 21 Oct 2021 20:34:04 -0400 Subject: [PATCH 07/12] remove inaccurate comment --- .github/workflows/r_package.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index a117eb8e59d8..5f14c82f779d 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -181,9 +181,6 @@ jobs: fail-fast: false matrix: include: - ################ - # CMake builds # - ################ - r_customization: san compiler: gcc - r_customization: csan From eddfffd19a5bffbcd46a649df5b458f56bde0624 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 21 Oct 2021 23:11:00 -0400 Subject: [PATCH 08/12] change test title --- .github/workflows/r_package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 5f14c82f779d..61abbd09e094 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -173,7 +173,7 @@ jobs: $env:TASK = "${{ matrix.task }}" & "$env:GITHUB_WORKSPACE/.ci/test_windows.ps1" test-r-sanitizers: - name: r-package (ubuntu-latest, R-devel, ${{ matrix.compiler }} ASAN/UBSAN) + name: r-sanitizers (ubuntu-latest, R-devel, ${{ matrix.compiler }} ASAN/UBSAN) runs-on: ubuntu-latest container: wch1/r-debug timeout-minutes: 60 From 24c275ba84f1f182275f74ff4ad2e510bb18f4bd Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 21 Oct 2021 23:48:08 -0400 Subject: [PATCH 09/12] Revert "Fix ASAN issues with `std::function` usage (#4673)" This reverts commit 13ed38ca55dc7d454712d794281c628f62301a0f. --- include/LightGBM/dataset_loader.h | 2 +- src/io/dataset_loader.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/LightGBM/dataset_loader.h b/include/LightGBM/dataset_loader.h index 27bea113b052..e72dd4910804 100644 --- a/include/LightGBM/dataset_loader.h +++ b/include/LightGBM/dataset_loader.h @@ -67,7 +67,7 @@ class DatasetLoader { /*! \brief Random generator*/ Random random_; /*! \brief prediction function for initial model */ - const PredictFunction predict_fun_; + const PredictFunction& predict_fun_; /*! \brief number of classes */ int num_class_; /*! \brief index of label column */ diff --git a/src/io/dataset_loader.cpp b/src/io/dataset_loader.cpp index 51ee7e4e540a..2d2c4d622b1c 100644 --- a/src/io/dataset_loader.cpp +++ b/src/io/dataset_loader.cpp @@ -1143,7 +1143,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector* text_dat double tmp_label = 0.0f; auto& ref_text_data = *text_data; std::vector feature_row(dataset->num_features_); - if (!predict_fun_) { + if (predict_fun_ == nullptr) { OMP_INIT_EX(); // if doesn't need to prediction with initial model #pragma omp parallel for schedule(static) private(oneline_features) firstprivate(tmp_label, feature_row) @@ -1262,7 +1262,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector* text_dat void DatasetLoader::ExtractFeaturesFromFile(const char* filename, const Parser* parser, const std::vector& used_data_indices, Dataset* dataset) { std::vector init_score; - if (predict_fun_) { + if (predict_fun_ != nullptr) { init_score = std::vector(dataset->num_data_ * num_class_); } std::function&)> process_fun = From 94561e749df72d3c3fec0555e919cfa4d6a2e666 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 24 Oct 2021 16:11:34 -0400 Subject: [PATCH 10/12] Revert "Revert "Fix ASAN issues with `std::function` usage (#4673)"" This reverts commit 24c275ba84f1f182275f74ff4ad2e510bb18f4bd. --- include/LightGBM/dataset_loader.h | 2 +- src/io/dataset_loader.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/LightGBM/dataset_loader.h b/include/LightGBM/dataset_loader.h index e72dd4910804..27bea113b052 100644 --- a/include/LightGBM/dataset_loader.h +++ b/include/LightGBM/dataset_loader.h @@ -67,7 +67,7 @@ class DatasetLoader { /*! \brief Random generator*/ Random random_; /*! \brief prediction function for initial model */ - const PredictFunction& predict_fun_; + const PredictFunction predict_fun_; /*! \brief number of classes */ int num_class_; /*! \brief index of label column */ diff --git a/src/io/dataset_loader.cpp b/src/io/dataset_loader.cpp index 2d2c4d622b1c..51ee7e4e540a 100644 --- a/src/io/dataset_loader.cpp +++ b/src/io/dataset_loader.cpp @@ -1143,7 +1143,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector* text_dat double tmp_label = 0.0f; auto& ref_text_data = *text_data; std::vector feature_row(dataset->num_features_); - if (predict_fun_ == nullptr) { + if (!predict_fun_) { OMP_INIT_EX(); // if doesn't need to prediction with initial model #pragma omp parallel for schedule(static) private(oneline_features) firstprivate(tmp_label, feature_row) @@ -1262,7 +1262,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector* text_dat void DatasetLoader::ExtractFeaturesFromFile(const char* filename, const Parser* parser, const std::vector& used_data_indices, Dataset* dataset) { std::vector init_score; - if (predict_fun_ != nullptr) { + if (predict_fun_) { init_score = std::vector(dataset->num_data_ * num_class_); } std::function&)> process_fun = From b9d3027dc75981742afb139b666931b11caa4dba Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 24 Oct 2021 16:14:37 -0400 Subject: [PATCH 11/12] revert unnecessary change in config order --- .github/workflows/r_package.yml | 2 +- R-package/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 61abbd09e094..6f07c6e4f394 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -174,9 +174,9 @@ jobs: & "$env:GITHUB_WORKSPACE/.ci/test_windows.ps1" 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 - timeout-minutes: 60 strategy: fail-fast: false matrix: diff --git a/R-package/README.md b/R-package/README.md index ce894fb700df..a1875de30ce4 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -374,7 +374,7 @@ For more background, see You can replicate these checks locally using Docker. For more information on the image used for testing, see https://github.com/wch/r-debug. -In the code below, environment variable `R_CUSTOMIZATION` should be set to one of two environment variables. +In the code below, environment variable `R_CUSTOMIZATION` should be set to one of two values. * `"san"` = replicates CRAN's `gcc-ASAN` and `gcc-UBSAN` checks * `"csan"` = replicates CRAN's `clang-ASAN` and `clang-UBSAN` checks From fdc0ba927c00f92493563ab252f99347be262781 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 26 Oct 2021 16:26:33 -0400 Subject: [PATCH 12/12] Apply suggestions from code review Co-authored-by: Nikita Titov --- R-package/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R-package/README.md b/R-package/README.md index a1875de30ce4..918db731c48a 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -361,13 +361,13 @@ Alternatively, GitHub Actions can run code above for you. On a pull request, cre **NOTE:** Please do this only once you see that other R tests on a pull request are passing. R Hub is a free resource with limited capacity, and we want to be respectful community members. -#### UBSAN +#### ASAN and UBSAN All packages uploaded to CRAN must pass builds using `gcc` and `clang`, instrumented with two sanitizers: the Address Sanitizer (ASAN) and the Undefined Behavior Sanitizer (UBSAN). For more background, see -* [this blog post](http://dirk.eddelbuettel.com/code/sanitizers.html) +* [this blog post](https://dirk.eddelbuettel.com/code/sanitizers.html) * [top-level CRAN documentation on these checks](https://cran.r-project.org/web/checks/check_issue_kinds.html) * [CRAN's configuration of these checks](https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt)