Unverified Commit 0901aa64 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[ci] clean source directory at the beginning of every Azure DevOps build (#6416)

parent 5dfe7168
#!/bin/bash #!/bin/bash
set -e -E -o pipefail
if [[ $OS_NAME == "macos" ]]; then if [[ $OS_NAME == "macos" ]]; then
if [[ $COMPILER == "clang" ]]; then if [[ $COMPILER == "clang" ]]; then
brew install libomp brew install libomp
......
#!/bin/bash #!/bin/bash
set -e -E -o pipefail
if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "gcc" ]]; then if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "gcc" ]]; then
export CXX=g++-11 export CXX=g++-11
export CC=gcc-11 export CC=gcc-11
......
...@@ -17,14 +17,35 @@ variables: ...@@ -17,14 +17,35 @@ variables:
DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
resources: resources:
# 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
containers: containers:
- container: linux-artifact-builder - container: linux-artifact-builder
image: lightgbm/vsts-agent:manylinux_2_28_x86_64 image: lightgbm/vsts-agent:manylinux_2_28_x86_64
mountReadOnly:
work: false
externals: true
tools: true
tasks: true
- container: ubuntu-latest - container: ubuntu-latest
image: 'ubuntu:22.04' image: 'ubuntu:22.04'
options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro" options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
mountReadOnly:
work: false
externals: true
tools: true
tasks: true
- container: rbase - container: rbase
image: wch1/r-debug image: wch1/r-debug
mountReadOnly:
work: false
externals: true
tools: true
tasks: true
jobs: jobs:
########################################### ###########################################
- job: Linux - job: Linux
...@@ -65,13 +86,22 @@ jobs: ...@@ -65,13 +86,22 @@ jobs:
echo "##vso[task.prependpath]/usr/lib64/openmpi/bin" echo "##vso[task.prependpath]/usr/lib64/openmpi/bin"
echo "##vso[task.prependpath]$CONDA/bin" echo "##vso[task.prependpath]$CONDA/bin"
displayName: 'Set variables' displayName: 'Set variables'
- script: |
git clean -d -f -x
displayName: 'Clean source directory'
- script: | - script: |
echo '$(Build.SourceVersion)' > '$(Build.ArtifactStagingDirectory)/commit.txt' echo '$(Build.SourceVersion)' > '$(Build.ArtifactStagingDirectory)/commit.txt'
displayName: 'Add commit hash to artifacts archive' displayName: 'Add commit hash to artifacts archive'
- bash: $(Build.SourcesDirectory)/.ci/setup.sh - task: Bash@3
displayName: Setup displayName: Setup
- bash: $(Build.SourcesDirectory)/.ci/test.sh inputs:
filePath: $(Build.SourcesDirectory)/.ci/setup.sh
targetType: filePath
- task: Bash@3
displayName: Test displayName: Test
inputs:
filePath: $(Build.SourcesDirectory)/.ci/test.sh
targetType: filePath
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
condition: and(succeeded(), in(variables['TASK'], 'regular', 'sdist', 'bdist', 'swig'), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))) condition: and(succeeded(), in(variables['TASK'], 'regular', 'sdist', 'bdist', 'swig'), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
inputs: inputs:
...@@ -139,10 +169,21 @@ jobs: ...@@ -139,10 +169,21 @@ jobs:
/tmp/docker exec -t -u 0 ci-container \ /tmp/docker exec -t -u 0 ci-container \
sh -c "apt-get update && apt-get -o Dpkg::Options::="--force-confold" -y install sudo" sh -c "apt-get update && apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
displayName: 'Install sudo' displayName: 'Install sudo'
- bash: $(Build.SourcesDirectory)/.ci/setup.sh - 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 displayName: Setup
- bash: $(Build.SourcesDirectory)/.ci/test.sh inputs:
filePath: $(Build.SourcesDirectory)/.ci/setup.sh
targetType: 'filePath'
- task: Bash@3
displayName: Test displayName: Test
inputs:
filePath: $(Build.SourcesDirectory)/.ci/test.sh
targetType: 'filePath'
########################################### ###########################################
- job: QEMU_multiarch - job: QEMU_multiarch
########################################### ###########################################
...@@ -170,6 +211,9 @@ jobs: ...@@ -170,6 +211,9 @@ jobs:
- script: | - script: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
displayName: 'Enable Docker multi-architecture support' displayName: 'Enable Docker multi-architecture support'
- script: |
git clean -d -f -x
displayName: 'Clean source directory'
- script: | - script: |
export ROOT_DOCKER_FOLDER=/LightGBM export ROOT_DOCKER_FOLDER=/LightGBM
cat > docker.env <<EOF cat > docker.env <<EOF
...@@ -245,10 +289,19 @@ jobs: ...@@ -245,10 +289,19 @@ jobs:
echo "##vso[task.prependpath]$CONDA/bin" echo "##vso[task.prependpath]$CONDA/bin"
echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME_8_X64" echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME_8_X64"
displayName: 'Set variables' displayName: 'Set variables'
- bash: $(Build.SourcesDirectory)/.ci/setup.sh - script: |
git clean -d -f -x
displayName: 'Clean source directory'
- task: Bash@3
displayName: Setup displayName: Setup
- bash: $(Build.SourcesDirectory)/.ci/test.sh inputs:
filePath: $(Build.SourcesDirectory)/.ci/setup.sh
targetType: filePath
- task: Bash@3
displayName: Test displayName: Test
inputs:
filePath: $(Build.SourcesDirectory)/.ci/test.sh
targetType: filePath
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
condition: and(succeeded(), in(variables['TASK'], 'regular', 'bdist', 'swig'), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))) condition: and(succeeded(), in(variables['TASK'], 'regular', 'bdist', 'swig'), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
inputs: inputs:
...@@ -278,6 +331,9 @@ jobs: ...@@ -278,6 +331,9 @@ jobs:
- powershell: | - powershell: |
Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: 'Set Variables' displayName: 'Set Variables'
- script: |
git clean -d -f -x
displayName: 'Clean source directory'
- script: | - script: |
cmd /c "powershell -ExecutionPolicy Bypass -File %BUILD_SOURCESDIRECTORY%/.ci/install_opencl.ps1" cmd /c "powershell -ExecutionPolicy Bypass -File %BUILD_SOURCESDIRECTORY%/.ci/install_opencl.ps1"
condition: eq(variables['TASK'], 'bdist') condition: eq(variables['TASK'], 'bdist')
...@@ -304,6 +360,9 @@ jobs: ...@@ -304,6 +360,9 @@ jobs:
vmImage: 'ubuntu-22.04' vmImage: 'ubuntu-22.04'
container: rbase container: rbase
steps: steps:
- script: |
git clean -d -f -x
displayName: 'Clean source directory'
- script: | - script: |
LGB_VER=$(head -n 1 VERSION.txt | sed "s/rc/-/g") LGB_VER=$(head -n 1 VERSION.txt | sed "s/rc/-/g")
R_LIB_PATH=~/Rlib R_LIB_PATH=~/Rlib
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment