.vsts-ci.yml 17 KB
Newer Older
1
2
3
trigger:
  branches:
    include:
4
      - master
5
6
  tags:
    include:
7
      - v*
8
pr:
9
  - master
10
variables:
11
  AZURE: 'true'
12
  CMAKE_BUILD_PARALLEL_LEVEL: 4
13
  PYTHON_VERSION: '3.13'
14
15
  runCodesignValidationInjection: false
  skipComponentGovernanceDetection: true
16
17
  Codeql.Enabled: false
  Codeql.SkipTaskAutoInjection: true
18
19
  DOTNET_CLI_TELEMETRY_OPTOUT: true
  DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
20
  SKBUILD_STRICT_CONFIG: true
21
resources:
22
23
24
25
26
27
  # The __work/ directory, where Azure DevOps writes the source files, needs to be read-write because
  # LightGBM's CI jobs write files in the source directory.
  #
  # For all the containers included here, all other directories that Azure mounts in are mounted as read-only
  # to minimize the risk of side effects from one run affecting future runs.
  # ref: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/resources-containers-container
28
  containers:
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    - container: linux-artifact-builder
      image: lightgbm/vsts-agent:manylinux_2_28_x86_64
      mountReadOnly:
        work: false
        externals: true
        tools: true
        tasks: true
    - container: ubuntu-latest
      image: 'ubuntu:22.04'
      options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
      mountReadOnly:
        work: false
        externals: true
        tools: true
        tasks: true
    - container: rbase
      image: wch1/r-debug
      mountReadOnly:
        work: false
        externals: true
        tools: true
        tasks: true
51
jobs:
52
53
54
  ###############
  # Maintenance #
  ###############
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
  - job: Maintenance
    pool: mariner-20240410-0
    container: ubuntu-latest
    # routine maintenance (like periodically deleting old files),
    # to be run on 1 random CI runner in the self-hosted pool each runner
    steps:
      - script: |
          print-diagnostics(){
            echo "---- df -h -m ----"
            df -h -m
            echo "---- docker system df ----"
            /tmp/docker system df
            echo "---- docker images ----"
            /tmp/docker images
          }
          # check disk usage
          print-diagnostics
          # remove old containers, container images, volumes
          # ref: https://stackoverflow.com/a/32723127/3986677
          # ref: https://depot.dev/blog/docker-clear-cache#removing-everything-with-docker-system-prune
          echo "---- running 'docker system prune' ----"
          /tmp/docker system prune \
            --all \
            --force \
            --volumes \
            --filter until=720h
          # check disk usage again
          print-diagnostics
        displayName: Clean
84
85
86
  #########
  # Linux #
  #########
87
88
89
90
91
92
93
94
95
96
97
98
  - job: Linux
    variables:
      COMPILER: gcc
      SETUP_CONDA: 'false'
      OS_NAME: 'linux'
      PRODUCES_ARTIFACTS: 'true'
    pool: mariner-20240410-0
    container: linux-artifact-builder
    strategy:
      matrix:
        regular:
          TASK: regular
99
          PYTHON_VERSION: '3.11'
100
101
        sdist:
          TASK: sdist
102
          PYTHON_VERSION: '3.9'
103
104
        bdist:
          TASK: bdist
105
          PYTHON_VERSION: '3.10'
106
107
108
109
110
        inference:
          TASK: if-else
        mpi_source:
          TASK: mpi
          METHOD: source
111
          PYTHON_VERSION: '3.10'
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
        gpu_source:
          TASK: gpu
          METHOD: source
        swig:
          TASK: swig
    steps:
      - script: |
          echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY"
          echo "##vso[task.prependpath]/usr/lib64/openmpi/bin"
          echo "##vso[task.prependpath]$CONDA/bin"
        displayName: 'Set variables'
      - script: |
          git clean -d -f -x
        displayName: 'Clean source directory'
      - script: |
          echo '$(Build.SourceVersion)' > '$(Build.ArtifactStagingDirectory)/commit.txt'
        displayName: 'Add commit hash to artifacts archive'
      - task: Bash@3
        displayName: Setup
        inputs:
          filePath: $(Build.SourcesDirectory)/.ci/setup.sh
          targetType: filePath
      - task: Bash@3
        displayName: Test
        inputs:
          filePath: $(Build.SourcesDirectory)/.ci/test.sh
          targetType: filePath
      - task: PublishBuildArtifacts@1
140
141
142
143
144
145
        condition: >
          and(
          succeeded(),
          in(variables['TASK'], 'regular', 'sdist', 'bdist', 'swig'),
          not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
          )
146
147
148
149
        inputs:
          pathtoPublish: '$(Build.ArtifactStagingDirectory)'
          artifactName: PackageAssets
          artifactType: container
150
151
152
  ################
  # Linux_latest #
  ################
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
  - job: Linux_latest
    variables:
      COMPILER: clang-17
      DEBIAN_FRONTEND: 'noninteractive'
      IN_UBUNTU_BASE_CONTAINER: 'true'
      OS_NAME: 'linux'
      SETUP_CONDA: 'true'
    pool: mariner-20240410-0
    container: ubuntu-latest
    strategy:
      matrix:
        regular:
          TASK: regular
        sdist:
          TASK: sdist
        bdist:
          TASK: bdist
170
          PYTHON_VERSION: '3.11'
171
172
173
174
175
176
177
178
        inference:
          TASK: if-else
        mpi_source:
          TASK: mpi
          METHOD: source
        mpi_pip:
          TASK: mpi
          METHOD: pip
179
          PYTHON_VERSION: '3.12'
180
181
182
        mpi_wheel:
          TASK: mpi
          METHOD: wheel
183
          PYTHON_VERSION: '3.10'
184
185
186
        gpu_source:
          TASK: gpu
          METHOD: source
187
          PYTHON_VERSION: '3.12'
188
189
190
        gpu_pip:
          TASK: gpu
          METHOD: pip
191
          PYTHON_VERSION: '3.11'
192
193
194
        gpu_wheel:
          TASK: gpu
          METHOD: wheel
195
          PYTHON_VERSION: '3.10'
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
        cpp_tests:
          TASK: cpp-tests
          METHOD: with-sanitizers
    steps:
      - script: |
          echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY"
          CONDA=$HOME/miniforge
          echo "##vso[task.setvariable variable=CONDA]$CONDA"
          echo "##vso[task.prependpath]$CONDA/bin"
        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'
      - script: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends git
          git clean -d -f -x
        displayName: 'Clean source directory'
      - task: Bash@3
        displayName: Setup
        inputs:
          filePath: $(Build.SourcesDirectory)/.ci/setup.sh
          targetType: 'filePath'
      - task: Bash@3
        displayName: Test
        inputs:
          filePath: $(Build.SourcesDirectory)/.ci/test.sh
          targetType: 'filePath'
226
227
228
  ##################
  # QEMU_multiarch #
  ##################
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
  - job: QEMU_multiarch
    variables:
      BUILD_DIRECTORY: /LightGBM
      COMPILER: gcc
      PRODUCES_ARTIFACTS: 'true'
    pool:
      vmImage: ubuntu-22.04
    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: |
          git clean -d -f -x
        displayName: 'Clean source directory'
      - script: |
          cat > docker-script.sh <<EOF
          export CONDA=\$HOME/miniforge
          export PATH=\$CONDA/bin:/opt/rh/llvm-toolset-7.0/root/usr/bin:\$PATH
          export LD_LIBRARY_PATH=/opt/rh/llvm-toolset-7.0/root/usr/lib64:\$LD_LIBRARY_PATH
          \$BUILD_DIRECTORY/.ci/setup.sh || exit 1
          \$BUILD_DIRECTORY/.ci/test.sh || exit 1
          EOF
          IMAGE_URI="lightgbm/vsts-agent:manylinux2014_aarch64"
          docker pull "${IMAGE_URI}" || exit 1
          PLATFORM=$(docker inspect --format='{{.Os}}/{{.Architecture}}' "${IMAGE_URI}") || exit 1
          echo "detected image platform: ${PLATFORM}"
          docker run \
            --platform "${PLATFORM}" \
            --rm \
            --env AZURE=true \
            --env BUILD_ARTIFACTSTAGINGDIRECTORY=$BUILD_ARTIFACTSTAGINGDIRECTORY \
            --env BUILD_DIRECTORY=$BUILD_DIRECTORY \
            --env COMPILER=$COMPILER \
            --env METHOD=$METHOD \
            --env OS_NAME=linux \
            --env PRODUCES_ARTIFACTS=$PRODUCES_ARTIFACTS \
            --env PYTHON_VERSION=$PYTHON_VERSION \
            --env TASK=$TASK \
            -v "$(Build.SourcesDirectory)":"$BUILD_DIRECTORY" \
            -v "$(Build.ArtifactStagingDirectory)":"$(Build.ArtifactStagingDirectory)" \
            "${IMAGE_URI}" \
            /bin/bash $BUILD_DIRECTORY/docker-script.sh
        displayName: 'Setup and run tests'
      - task: PublishBuildArtifacts@1
287
288
289
290
291
292
        condition: >
          and(
          succeeded(),
          in(variables['TASK'], 'bdist'),
          not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
          )
293
294
295
296
        inputs:
          pathtoPublish: '$(Build.ArtifactStagingDirectory)'
          artifactName: PackageAssets
          artifactType: container
297
298
299
  #########
  # macOS #
  #########
300
301
302
303
304
305
306
307
308
309
310
  - job: macOS
    variables:
      COMPILER: clang
      OS_NAME: 'macos'
      PRODUCES_ARTIFACTS: 'true'
    pool:
      vmImage: 'macOS-13'
    strategy:
      matrix:
        regular:
          TASK: regular
311
          PYTHON_VERSION: '3.11'
312
313
        sdist:
          TASK: sdist
314
          PYTHON_VERSION: '3.10'
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
        bdist:
          TASK: bdist
        swig:
          TASK: swig
        cpp_tests:
          TASK: cpp-tests
          METHOD: with-sanitizers
          SANITIZERS: "address;undefined"
    steps:
      - script: |
          echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY"
          CONDA=$AGENT_HOMEDIRECTORY/miniforge
          echo "##vso[task.setvariable variable=CONDA]$CONDA"
          echo "##vso[task.prependpath]$CONDA/bin"
          echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME_8_X64"
        displayName: 'Set variables'
      - script: |
          git clean -d -f -x
        displayName: 'Clean source directory'
      - task: Bash@3
        displayName: Setup
        inputs:
          filePath: $(Build.SourcesDirectory)/.ci/setup.sh
          targetType: filePath
      - task: Bash@3
        displayName: Test
        inputs:
          filePath: $(Build.SourcesDirectory)/.ci/test.sh
          targetType: filePath
      - task: PublishBuildArtifacts@1
345
346
347
348
349
350
        condition: >
          and(
          succeeded(),
          in(variables['TASK'], 'regular', 'bdist', 'swig'),
          not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
          )
351
352
353
354
        inputs:
          pathtoPublish: '$(Build.ArtifactStagingDirectory)'
          artifactName: PackageAssets
          artifactType: container
355
356
357
  ###########
  # Windows #
  ###########
358
359
360
361
362
363
364
  - job: Windows
    pool:
      vmImage: 'windows-2019'
    strategy:
      matrix:
        regular:
          TASK: regular
365
          PYTHON_VERSION: '3.11'
366
367
        sdist:
          TASK: sdist
368
          PYTHON_VERSION: '3.10'
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
        bdist:
          TASK: bdist
        swig:
          TASK: swig
        cpp_tests:
          TASK: cpp-tests
    steps:
      - powershell: |
          Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
        displayName: 'Set Variables'
      - script: |
          git clean -d -f -x
        displayName: 'Clean source directory'
      - script: |
          cmd /c "powershell -ExecutionPolicy Bypass -File %BUILD_SOURCESDIRECTORY%/.ci/install-opencl.ps1"
        condition: eq(variables['TASK'], 'bdist')
        displayName: 'Install OpenCL'
      - script: |
          cmd /c "conda config --remove channels defaults"
          cmd /c "conda config --add channels nodefaults"
          cmd /c "conda config --add channels conda-forge"
          cmd /c "conda config --set channel_priority strict"
          cmd /c "conda init powershell"
          cmd /c "powershell -ExecutionPolicy Bypass -File %BUILD_SOURCESDIRECTORY%/.ci/test-windows.ps1"
        displayName: Test
      - task: PublishBuildArtifacts@1
395
396
397
398
399
400
        condition: >
          and(
          succeeded(),
          in(variables['TASK'], 'regular', 'bdist', 'swig'),
          not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
          )
401
402
403
404
        inputs:
          pathtoPublish: '$(Build.ArtifactStagingDirectory)'
          artifactName: PackageAssets
          artifactType: container
405
406
407
  ##############
  # R_artifact #
  ##############
408
409
410
411
412
413
414
415
416
  - job: R_artifact
    condition: not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
    pool:
      vmImage: 'ubuntu-22.04'
    container: rbase
    steps:
      - script: |
          git clean -d -f -x
        displayName: 'Clean source directory'
417
      # yamllint disable rule:line-length
418
419
420
421
422
423
424
425
      - script: |
          LGB_VER=$(head -n 1 VERSION.txt | sed "s/rc/-/g")
          R_LIB_PATH=~/Rlib
          export R_LIBS=${R_LIB_PATH}
          mkdir -p ${R_LIB_PATH}
          RDscript -e "install.packages(c('R6', 'data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'RhpcBLASctl'),  lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'), repos = 'https://cran.rstudio.com', Ncpus = parallel::detectCores())" || exit 1
          sh build-cran-package.sh --r-executable=RD || exit 1
          mv lightgbm_${LGB_VER}.tar.gz $(Build.ArtifactStagingDirectory)/lightgbm-${LGB_VER}-r-cran.tar.gz
426
        # yamllint enable rule:line-length
427
428
429
430
431
432
433
        displayName: 'Build CRAN R-package'
      - task: PublishBuildArtifacts@1
        condition: succeeded()
        inputs:
          pathtoPublish: $(Build.ArtifactStagingDirectory)
          artifactName: R-package
          artifactType: container
Guolin Ke's avatar
Guolin Ke committed
434

435
436
437
  ###########
  # Package #
  ###########
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
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
  - job: Package
    dependsOn:
      - Linux
      - Linux_latest
      - QEMU_multiarch
      - macOS
      - Windows
      - R_artifact
    condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
    pool:
      vmImage: 'ubuntu-22.04'
    steps:
      # Create archives with complete source code included (with git submodules)
      - task: ArchiveFiles@2
        displayName: Create zip archive
        condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
        inputs:
          rootFolderOrFile: $(Build.SourcesDirectory)
          includeRootFolder: false
          archiveType: zip
          archiveFile: '$(Build.ArtifactStagingDirectory)/archives/LightGBM-complete_source_code_zip.zip'
          replaceExistingArchive: true
      - task: ArchiveFiles@2
        displayName: Create tar.gz archive
        condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
        inputs:
          rootFolderOrFile: $(Build.SourcesDirectory)
          includeRootFolder: false
          archiveType: tar
          tarCompression: gz
          archiveFile: '$(Build.ArtifactStagingDirectory)/archives/LightGBM-complete_source_code_tar_gz.tar.gz'
          replaceExistingArchive: true
      # Download all agent packages from all previous phases
      - task: DownloadBuildArtifacts@0
        displayName: Download package assets
        inputs:
          artifactName: PackageAssets
          downloadPath: $(Build.SourcesDirectory)/binaries
      - task: DownloadBuildArtifacts@0
        displayName: Download R-package
        condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
        inputs:
          artifactName: R-package
          downloadPath: $(Build.SourcesDirectory)/R
      - script: |
          python "$(Build.SourcesDirectory)/.ci/create-nuget.py" "$(Build.SourcesDirectory)/binaries/PackageAssets"
        displayName: 'Create NuGet configuration files'
      - task: NuGetCommand@2
        inputs:
          command: pack
          packagesToPack: '$(Build.SourcesDirectory)/.ci/nuget/*.nuspec'
          packDestination: '$(Build.ArtifactStagingDirectory)/nuget'
      - task: PublishBuildArtifacts@1
        inputs:
          pathtoPublish: '$(Build.ArtifactStagingDirectory)/nuget'
          artifactName: NuGet
          artifactType: container
      - task: GitHubRelease@0
        displayName: 'Create GitHub Release'
        condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
        inputs:
          gitHubConnection: guolinke
          repositoryName: '$(Build.Repository.Name)'
          action: 'create'
          target: '$(Build.SourceVersion)'
          tagSource: 'auto'
          title: '$(Build.SourceBranchName)'
          assets: |
            $(Build.SourcesDirectory)/binaries/PackageAssets/*
            $(Build.SourcesDirectory)/R/R-package/*
            $(Build.ArtifactStagingDirectory)/nuget/*.nupkg
            $(Build.ArtifactStagingDirectory)/archives/*
          assetUploadMode: 'delete'
          isDraft: true
          isPreRelease: false
          addChangeLog: false