-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expand file tree
/
Copy pathci.conda.tests.yml
More file actions
194 lines (160 loc) · 7.47 KB
/
ci.conda.tests.yml
File metadata and controls
194 lines (160 loc) · 7.47 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
parameters:
- name: TestPipeline
type: boolean
default: false
- name: ServiceDirectory
type: string
default: ''
- name: CondaArtifacts
type: object
default: []
- name: TestMarkArgument
type: string
default: ''
- name: PythonVersion
type: string
default: ''
- name: OSVmImage
type: string
default: ''
- name: Matrix
type: string
- name: DependsOn
type: string
default: ''
- name: UsePlatformContainer
type: boolean
default: false
- name: TestTimeoutInMinutes
type: number
default: 0
- name: CloudConfig
type: object
default: {}
jobs:
- job:
displayName: 'Test Conda'
condition: |
and(
succeededOrFailed(),
ne(variables['Skip.TestConda'], 'true')
)
timeoutInMinutes: ${{ parameters.TestTimeoutInMinutes }}
dependsOn:
- ${{ parameters.DependsOn }}
strategy:
matrix: $[ ${{ parameters.Matrix }} ]
pool:
name: $(Pool)
vmImage: $(OSVmImage)
${{ if eq(parameters.UsePlatformContainer, 'true') }}:
# Add a default so the job doesn't fail when the matrix is empty
container: $[ variables['Container'] ]
variables:
- template: ../variables/globals.yml
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifactName: 'conda'
targetPath: $(Build.ArtifactStagingDirectory)
- template: /eng/common/pipelines/templates/steps/set-test-pipeline-version.yml
parameters:
PackageName: "azure-template"
ServiceDirectory: "template"
TestPipeline: ${{ parameters.TestPipeline }}
- task: UsePythonVersion@0
displayName: 'Use Python $(PythonVersion)'
inputs:
versionSpec: $(PythonVersion)
- pwsh: |
# due to faulty deployed scripts/how the path gets manipulated by conda actions on
# ubuntu and mac, we can't rely on bin/scripts being referenced correctly. see
# https://github.com/MicrosoftDocs/azure-devops-docs/issues/3812
$activateMethod = "source $($env:CONDA)/bin/activate"
# pypy3 is not a true python executable. in conda-land, we need to call it using pypy3, NOT python
# on windows, we need to add "--user" as otherwise pip won't successfully install/uninstall due to
# how windows holds reservation on pip.exe. this is unnecessary on ubuntu/mac.
$requirementSuffix = ""
# we always want to prepend the path with conda bin
Write-Host "##vso[task.prependpath]]$($env:CONDA)/bin"
if ($IsWindows) {
# powershell does not have an equivalent of call/source, which is necessary when
# using conda in azure devops. Note that we use `activate` natively here, as
# a later path prepend of the /scripts directory actually works.
$activateMethod = "call activate"
$requirementSuffix = " --user"
# on windows only, need to prepend with the scripts directory as well
Write-Host "##vso[task.prependpath]$($env:CONDA)/Scripts"
}
if("$(PythonVersion)" -eq "pypy3"){
Write-Host "##vso[task.setvariable variable=PyVersion]-c conda-forge pypy3.7 pip"
}
else {
Write-Host "##vso[task.setvariable variable=PyVersion]python=$(PythonVersion)"
}
# we will use these variables extensively later
Write-Host "##vso[task.setvariable variable=activate.method]$activateMethod"
Write-Host "##vso[task.setvariable variable=requirement.suffix]$requirementSuffix"
displayName: 'Evaluate OS Specific PATH and Parameters'
- ${{ each artifact in parameters.CondaArtifacts }}:
# due to the fact that `pypy3` and `conda-build` conda packages are INCOMPATIBLE, we have to create
# a separate env to install `conda-build` and use that to `conda index` the local file channel
- script: |
echo "conda create --name ${{ artifact.name }} $(PyVersion) --yes"
conda create --name ${{ artifact.name }} $(PyVersion) --yes
echo "conda create --name index-env --yes"
conda create --name index-env --yes
echo "conda install --name index-env --yes --quiet conda-build"
conda install --name index-env --yes --quiet conda-build
echo "$(activate.method) index-env"
$(activate.method) index-env
echo "conda index $(Build.ArtifactStagingDirectory)/${{ artifact.name }}"
conda index $(Build.ArtifactStagingDirectory)/${{ artifact.name }}
displayName: 'Prepare Conda Environment for Testing ${{ artifact.name }}, Index the Target Local Artifact'
- script: |
echo "$(activate.method) ${{ artifact.name }}"
$(activate.method) ${{ artifact.name }}
echo "python -m pip install -r eng/ci_tools.txt $(requirement.suffix)"
python -m pip install -r eng/ci_tools.txt $(requirement.suffix)
displayName: 'Activate Conda Environment and Install General Dependencies ${{ artifact.name }}'
- pwsh: |
mkdir $(Agent.BuildDirectory)/conda/
Write-Host "##vso[task.setvariable variable=conda.build]$(Agent.BuildDirectory)/conda_checkout"
displayName: 'Create Conda Working Directory for Testing'
- script: |
echo "$(activate.method) ${{ artifact.name }}"
$(activate.method) ${{ artifact.name }}
echo "python -m pip install -r $(Build.SourcesDirectory)/eng/conda_test_requirements.txt"
python -m pip install -r $(Build.SourcesDirectory)/eng/conda_test_requirements.txt
python -m pip uninstall azure-core -y
displayName: 'Prep Conda Environment w/ Dependencies'
- script: |
echo "conda install --name ${{ artifact.name }} ${{ artifact.name }} -c $(Build.ArtifactStagingDirectory)/${{ artifact.name }} --yes -c $(AzureSDKCondaChannel)"
conda install --name ${{ artifact.name }} ${{ artifact.name }} -c $(Build.ArtifactStagingDirectory)/${{ artifact.name }} --yes -c $(AzureSDKCondaChannel)
echo "conda install --name ${{ artifact.name }} azure-identity -c $(Build.ArtifactStagingDirectory)/${{ artifact.name }} -c $(AzureSDKCondaChannel) --yes"
conda install --name ${{ artifact.name }} azure-identity -c $(Build.ArtifactStagingDirectory)/${{ artifact.name }} -c $(AzureSDKCondaChannel) --yes
echo "$(activate.method) ${{ artifact.name }}"
$(activate.method) ${{ artifact.name }}
python -m pip freeze
displayName: 'Install ${{ artifact.name }} Conda Package'
- ${{ each checkout in artifact.checkout }}:
- pwsh:
Write-Host "Clean up Conda Build Directory $(conda.build)"
Remove-Item $(conda.build)/* -Recurse -Force
displayName: 'Clean Up Before Testing ${{ artifact.name }}'
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
parameters:
Paths:
- "${{ checkout.checkout_path }}"
- "sdk/conftest.py"
- "tools/"
Repositories:
- Name: "Azure/azure-sdk-for-python"
Commitish: "${{ checkout.Package }}_${{ checkout.Version }}"
WorkingDirectory: "$(conda.build)"
SkipDefaultCheckout: true
- script: |
echo "$(activate.method) ${{ artifact.name }}"
$(activate.method) ${{ artifact.name }}
python -m pytest $(conda.build)/${{ checkout.checkout_path }}/${{ checkout.package }}
displayName: 'Run Tests for ${{ checkout.package }}'