-
Notifications
You must be signed in to change notification settings - Fork 4k
487 lines (482 loc) · 17.1 KB
/
python_package.yml
File metadata and controls
487 lines (482 loc) · 17.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
name: Python-package
on:
push:
branches:
- master
pull_request:
branches:
- master
# automatically cancel in-progress builds if another commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
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'
# where repo sources are cloned to
BUILD_SOURCESDIRECTORY: '${{ github.workspace }}'
CMAKE_BUILD_PARALLEL_LEVEL: 4
# avoid interactive prompts in Debian-based distributions
DEBIAN_FRONTEND: noninteractive
# On runners using nvidia-container-runtime with Docker, ensure GPUs are available to running processes.
#
# ref: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html
NVIDIA_VISIBLE_DEVICES: 'all'
SKBUILD_STRICT_CONFIG: true
jobs:
test-linux-aarch64:
name: bdist wheel (manylinux2014-arm, gcc, Python 3.13)
runs-on: ubuntu-24.04-arm
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 5
persist-credentials: false
submodules: true
- name: Setup and run tests
shell: bash
# this uses 'docker run' instead of just setting 'container:'
# because actions/checkout requires GLIBC 2.28 and that is too
# new for manylinux2014
env:
BUILD_DIRECTORY: /LightGBM
run: |
cat > ./docker-script.sh <<EOF
mkdir -p \$BUILD_ARTIFACTSTAGINGDIRECTORY
export CONDA=\$HOME/miniforge
export PATH=\$CONDA/bin:\$PATH
${{ env.BUILD_DIRECTORY }}/.ci/setup.sh || exit 1
${{ env.BUILD_DIRECTORY }}/.ci/test.sh || exit 1
EOF
IMAGE_URI="lightgbm/vsts-agent:manylinux2014_aarch64"
docker pull "${IMAGE_URI}" || exit 1
docker run \
--platform "${PLATFORM}" \
--rm \
--env BUILD_DIRECTORY=${{ env.BUILD_DIRECTORY }} \
--env BUILD_ARTIFACTSTAGINGDIRECTORY=${{ env.BUILD_DIRECTORY }}/artifacts/ \
--env COMPILER=gcc \
--env METHOD=wheel \
--env OS_NAME=linux \
--env PRODUCES_ARTIFACTS=true \
--env PYTHON_VERSION="3.13" \
--env TASK=bdist \
-v "${PWD}":"${{ env.BUILD_DIRECTORY }}" \
-w ${{ env.BUILD_DIRECTORY }} \
"${IMAGE_URI}" \
/bin/bash ./docker-script.sh
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: linux-aarch64-wheel
path: artifacts/*.whl
if-no-files-found: error
test:
# yamllint disable-line rule:line-length
name: ${{ matrix.task }} ${{ matrix.method }} (${{ matrix.os-display-name || matrix.os }}, ${{ matrix.compiler }}, Python ${{ matrix.python_version }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
task: regular
compiler: gcc
python_version: '3.11'
- os: macos-15-intel
task: sdist
compiler: clang
python_version: '3.10'
- os: macos-15-intel
task: sdist
compiler: gcc
python_version: '3.12'
- os: macos-15-intel
task: bdist
method: wheel
compiler: gcc
python_version: '3.9'
- os: windows-2022
task: sdist
compiler: MSVC
python_version: '3.10'
- os: ubuntu-latest
container: &ubuntu_latest_image ubuntu:22.04
os-display-name: &ubuntu_latest_display_name 'ubuntu22.04'
task: regular
compiler: clang-17
python_version: '3.13'
in-ubuntu-base-container: 'true'
- os: ubuntu-latest
container: *ubuntu_latest_image
os-display-name: *ubuntu_latest_display_name
task: sdist
compiler: clang-17
python_version: '3.13'
in-ubuntu-base-container: 'true'
#########################
# OpenCL-based GPU jobs #
#########################
# clang-17 jobs are run on machines with actual GPUs because
# the package built with that compiler toolchain can't target the
# CPUs on GitHub's runners.
#
# ref: https://github.com/microsoft/LightGBM/pull/7096/files#r2590879590
- os: LightGBM-GPU
container: nvcr.io/nvidia/cuda:12.9.1-devel-ubuntu22.04
os-display-name: ubuntu22.04-with-gpu
task: bdist
compiler: clang-17
method: wheel
python_version: '3.11'
in-ubuntu-base-container: 'true'
- os: LightGBM-GPU
container: nvcr.io/nvidia/cuda:12.9.1-devel-ubuntu22.04
os-display-name: ubuntu22.04-with-gpu
task: gpu
compiler: clang-17
method: source
python_version: '3.12'
in-ubuntu-base-container: 'true'
- os: ubuntu-latest
container: &manylinux_amd64_image lightgbm.azurecr.io/vsts-agent:manylinux_2_28_x86_64
os-display-name: &manylinux_amd64_display_name 'manylinux_2_28'
task: gpu
method: source
compiler: gcc
python_version: '3.13'
in-ubuntu-base-container: 'false'
setup-conda: 'false'
############
# MPI jobs #
############
- os: macos-15-intel
task: mpi
compiler: gcc
method: source
python_version: '3.12'
- os: macos-15-intel
task: mpi
compiler: gcc
method: pip
python_version: '3.13'
- os: macos-15-intel
task: mpi
compiler: gcc
method: wheel
python_version: '3.10'
- os: ubuntu-latest
container: *manylinux_amd64_image
os-display-name: *manylinux_amd64_display_name
task: mpi
compiler: gcc
method: source
python_version: '3.10'
in-ubuntu-base-container: 'false'
setup-conda: 'false'
- os: ubuntu-latest
container: *ubuntu_latest_image
os-display-name: *ubuntu_latest_display_name
task: mpi
compiler: clang-17
method: source
python_version: '3.13'
in-ubuntu-base-container: 'true'
- os: ubuntu-latest
container: *ubuntu_latest_image
os-display-name: *ubuntu_latest_display_name
task: mpi
compiler: clang-17
method: pip
python_version: '3.12'
in-ubuntu-base-container: 'true'
- os: ubuntu-latest
container: *ubuntu_latest_image
os-display-name: *ubuntu_latest_display_name
task: mpi
compiler: clang-17
method: wheel
python_version: '3.10'
in-ubuntu-base-container: 'true'
#####################
# jobs that create #
# release artifacts #
#####################
- os: macos-15-intel
task: bdist
compiler: clang
method: wheel
produces-artifacts: 'true'
artifact-name: 'macosx-amd64-wheel'
python_version: '3.13'
- os: macos-14
task: bdist
compiler: clang
method: wheel
produces-artifacts: 'true'
artifact-name: 'macosx-arm64-wheel'
python_version: '3.11'
- os: macos-15-intel
task: regular
compiler: clang
produces-artifacts: 'true'
artifact-name: 'macosx-amd64-liblightgbm'
python_version: '3.11'
- os: ubuntu-latest
container: *manylinux_amd64_image
os-display-name: *manylinux_amd64_display_name
task: regular
compiler: gcc
python_version: '3.11'
in-ubuntu-base-container: 'false'
setup-conda: 'false'
produces-artifacts: 'true'
artifact-name: 'linux-amd64-liblightgbm'
- os: ubuntu-latest
container: *manylinux_amd64_image
os-display-name: *manylinux_amd64_display_name
task: bdist
compiler: gcc
method: wheel
python_version: '3.10'
in-ubuntu-base-container: 'false'
setup-conda: 'false'
produces-artifacts: 'true'
artifact-name: 'linux-amd64-wheel'
- os: ubuntu-latest
container: *manylinux_amd64_image
os-display-name: *manylinux_amd64_display_name
task: sdist
compiler: gcc
python_version: '3.9'
in-ubuntu-base-container: 'false'
setup-conda: 'false'
produces-artifacts: 'true'
artifact-name: 'sdist'
- os: windows-2022
task: bdist
compiler: MSVC
method: wheel
produces-artifacts: 'true'
artifact-name: 'windows-amd64-wheel'
python_version: '3.13'
- os: windows-2022
task: regular
compiler: MSVC
produces-artifacts: 'true'
artifact-name: 'windows-amd64-cli-and-liblightgbm'
python_version: '3.11'
steps:
- name: Install packages used by third-party actions
if: ${{ matrix.in-ubuntu-base-container == 'true' }}
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@v6
with:
fetch-depth: 5
persist-credentials: false
submodules: true
- name: Setup and run tests on Linux and macOS
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') || matrix.os == 'LightGBM-GPU'
shell: bash
run: |
export COMPILER="${{ matrix.compiler }}"
export IN_UBUNTU_BASE_CONTAINER="${{ matrix.in-ubuntu-base-container }}"
export SETUP_CONDA="${{ matrix.setup-conda }}"
export TASK="${{ matrix.task }}"
export METHOD="${{ matrix.method }}"
if [[ "${{ matrix.os }}" =~ ^macos ]]; then
export OS_NAME="macos"
elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]] || [[ "${{ matrix.os }}" == "LightGBM-GPU" ]]; then
export OS_NAME="linux"
export PATH="/usr/lib64/openmpi/bin:${PATH}"
fi
export PYTHON_VERSION="${{ matrix.python_version }}"
export BUILD_DIRECTORY="$GITHUB_WORKSPACE"
# some pre-built images already have 'CONDA' set
if [[ -z "${CONDA:-}" ]]; then
export CONDA=${HOME}/miniforge
fi
export PATH=${CONDA}/bin:${PATH}
export PRODUCES_ARTIFACTS="${{ matrix.produces-artifacts }}"
$GITHUB_WORKSPACE/.ci/setup.sh || exit 1
$GITHUB_WORKSPACE/.ci/test.sh || exit 1
- name: Install OpenCL on Windows
if: startsWith(matrix.os, 'windows') && (matrix.task == 'bdist')
shell: pwsh -command ". {0}"
run: |
& "$env:GITHUB_WORKSPACE/.ci/install-opencl.ps1"
# 'conda init powershell' needs to be run in a separate process
# ref: https://docs.conda.io/projects/conda/en/stable/dev-guide/deep-dives/activation.html
- name: Initialize conda on Windows
if: startsWith(matrix.os, 'windows')
shell: pwsh -command ". {0}"
run: |
$env:PATH = "$env:CONDA/Scripts;$env:PATH"
conda init powershell
- name: Setup and run tests on Windows
if: startsWith(matrix.os, 'windows')
shell: pwsh -command ". {0}"
run: |
$env:COMPILER = "${{ matrix.compiler }}"
$env:METHOD = "${{ matrix.method }}"
$env:PRODUCES_ARTIFACTS = "${{ matrix.produces-artifacts }}"
$env:PYTHON_VERSION = "${{ matrix.python_version }}"
$env:TASK = "${{ matrix.task }}"
& "$env:GITHUB_WORKSPACE/.ci/test-windows.ps1"
- name: Upload artifacts
if: ${{ matrix.produces-artifacts == 'true' }}
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.artifact-name }}
path: |
artifacts/*.dll
artifacts/*.dylib
artifacts/*.exe
artifacts/*.so
artifacts/*.tar.gz
artifacts/*.whl
if-no-files-found: error
create-nuget:
name: NuGet package
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [test]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 5
persist-credentials: false
submodules: false
- name: Download lib_lightgbm (all operating systems) and Windows CLI
uses: actions/download-artifact@v7
with:
merge-multiple: true
path: ${{ env.BUILD_ARTIFACTSTAGINGDIRECTORY }}
pattern: '*amd64*-liblightgbm'
run-id: ${{ github.run_id }}
- name: Setup NuGet CLI
uses: NuGet/setup-nuget@v2
# ref: https://github.com/NuGet/setup-nuget/issues/168
- name: Setup mono
run: |
sudo apt-get update -y
sudo apt-get install --no-install-recommends -y \
mono-devel
- name: Create NuGet package
run: |
python .ci/create-nuget.py "${{ env.BUILD_ARTIFACTSTAGINGDIRECTORY }}"
nuget pack \
$(pwd)/.ci/nuget/LightGBM.nuspec \
-NonInteractive \
-Verbosity detailed \
-OutputDirectory "${{ env.BUILD_ARTIFACTSTAGINGDIRECTORY }}"
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: nuget-package
path: artifacts/*.nupkg
if-no-files-found: error
test-latest-versions:
name: Python - latest versions (manylinux_2_28)
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 5
persist-credentials: false
submodules: true
- name: Create wheel
run: |
docker run \
--rm \
--env CMAKE_BUILD_PARALLEL_LEVEL=${{ env.CMAKE_BUILD_PARALLEL_LEVEL }} \
-v $(pwd):/opt/lgb-build \
-w /opt/lgb-build \
lightgbm/vsts-agent:manylinux_2_28_x86_64 \
/bin/bash -c 'PATH=/opt/miniforge/bin:$PATH sh ./build-python.sh bdist_wheel --nomp'
- name: Test compatibility
run: |
docker run \
--rm \
-v $(pwd):/opt/lgb-build \
-w /opt/lgb-build \
python:3.13 \
/bin/bash ./.ci/test-python-latest.sh
test-old-versions:
name: Python - oldest supported versions (manylinux_2_28, Python ${{ matrix.python_version }})
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
# This should always include at least the oldest
# not-yet-end-of-life Python version
python_version:
- '3.9'
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 5
persist-credentials: false
submodules: true
- name: Create wheel
run: |
docker run \
--rm \
--env CMAKE_BUILD_PARALLEL_LEVEL=${{ env.CMAKE_BUILD_PARALLEL_LEVEL }} \
-v $(pwd):/opt/lgb-build \
-w /opt/lgb-build \
lightgbm/vsts-agent:manylinux_2_28_x86_64 \
/bin/bash -c 'PATH=/opt/miniforge/bin:$PATH sh ./build-python.sh bdist_wheel --nomp'
- name: Test compatibility
run: |
docker run \
--rm \
-v $(pwd):/opt/lgb-build \
-w /opt/lgb-build \
python:${{ matrix.python_version }} \
/bin/bash ./.ci/test-python-oldest.sh
all-python-package-jobs-successful:
if: always()
runs-on: ubuntu-latest
needs:
- test-latest-versions
- test
- test-linux-aarch64
- test-old-versions
steps:
- name: Note that all tests succeeded
uses: re-actors/alls-green@v1.2.2
with:
jobs: ${{ toJSON(needs) }}