diff --git a/.appveyor.yml b/.appveyor.yml index bb15958136c3..da16fd6e50f8 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -27,10 +27,10 @@ install: - set PYTHON_VERSION=%CONFIGURATION% - set CONDA_ENV="test-env" - ps: | + $env:CMAKE_BUILD_PARALLEL_LEVEL = 4 $env:MINICONDA = "C:\Miniconda3-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 diff --git a/.ci/test.sh b/.ci/test.sh index 1b8a31340130..4e632320a5c6 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -10,6 +10,8 @@ SANITIZERS=${SANITIZERS:-""} ARCH=$(uname -m) +LGB_VER=$(head -n 1 ${BUILD_DIRECTORY}/VERSION.txt) + if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "gcc" ]]; then export CXX=g++-11 export CC=gcc-11 diff --git a/.ci/test_windows.ps1 b/.ci/test_windows.ps1 index 12f90f71cd05..1942dfaf7c6d 100644 --- a/.ci/test_windows.ps1 +++ b/.ci/test_windows.ps1 @@ -6,6 +6,8 @@ function Check-Output { } } +$env:LGB_VER = (Get-Content $env:BUILD_SOURCESDIRECTORY\VERSION.txt).trim() + # unify environment variable for Azure DevOps and AppVeyor if (Test-Path env:APPVEYOR) { $env:APPVEYOR = "true" diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index b7f825b245b8..39ecde4e1e7e 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -8,53 +8,41 @@ on: branches: - master - release/* + # Run manually by clicking a button in the UI + workflow_dispatch: + inputs: + restart_docker: + description: 'Restart nvidia-docker on the runner before building?' + required: true + type: boolean + default: false # automatically cancel in-progress builds if another commit is pushed concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - github_actions: 'true' - os_name: linux - conda_env: test-env - jobs: - test: - name: ${{ matrix.task }} ${{ matrix.cuda_version }} ${{ matrix.method }} (linux, ${{ matrix.compiler }}, Python ${{ matrix.python_version }}) + # Optionally reinstall + restart docker on the runner before building. + # This is safe as long as only 1 of these jobs runs at a time. + restart-docker: + name: set up docker runs-on: [self-hosted, linux] - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - method: wheel - compiler: gcc - python_version: "3.11" - cuda_version: "11.8.0" - task: cuda - - method: source - compiler: gcc - python_version: "3.9" - cuda_version: "12.2.0" - task: cuda - - method: pip - compiler: clang - python_version: "3.10" - cuda_version: "11.8.0" - task: cuda + timeout-minutes: 30 steps: - name: Setup or update software on host machine + if: ${{ inputs.restart_docker }} run: | + # install core packages 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 + # set up nvidia-docker 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 - @@ -67,43 +55,76 @@ jobs: 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: mark job successful + run: | + exit 0 + test: + name: ${{ matrix.task }} ${{ matrix.cuda_version }} ${{ matrix.method }} (linux, ${{ matrix.compiler }}, Python ${{ matrix.python_version }}) + runs-on: [self-hosted, linux] + needs: [restart-docker] + container: + image: ${{ matrix.image }} + env: + CMAKE_BUILD_PARALLEL_LEVEL: 4 + COMPILER: ${{ matrix.compiler }} + CONDA: /tmp/miniforge + CONDA_ENV: test-env + DEBIAN_FRONTEND: noninteractive + METHOD: ${{ matrix.method }} + OS_NAME: linux + PYTHON_VERSION: ${{ matrix.python_version }} + TASK: ${{ matrix.task }} + options: --gpus all + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + include: + - method: wheel + compiler: gcc + python_version: "3.11" + cuda_version: "11.8.0" + image: nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu20.04 + task: cuda + - method: source + compiler: gcc + python_version: "3.9" + cuda_version: "12.2.0" + image: nvcr.io/nvidia/cuda:12.2.0-devel-ubuntu22.04 + task: cuda + - method: pip + compiler: clang + python_version: "3.10" + cuda_version: "11.8.0" + image: nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu20.04 + task: cuda + steps: + - name: Install latest git + run: | + apt-get update + apt-get install --no-install-recommends -y \ + ca-certificates \ + software-properties-common + add-apt-repository ppa:git-core/ppa -y + apt-get update + apt-get install --no-install-recommends -y \ + git - name: Checkout repository - uses: actions/checkout@v1 + uses: actions/checkout@v4 with: fetch-depth: 5 submodules: true - name: Setup and run tests run: | - export ROOT_DOCKER_FOLDER=/LightGBM - cat > docker.env < docker-script.sh <