11# File: template-test-minimal-conda-env-install.yml
22parameters :
3+ - name : pythonVersion
4+ type : string
5+ default : ' 3.10'
36 # Determines the type of package repository to use for testing installation (prod or dev).
47 - name : environment
58 type : string
@@ -8,19 +11,27 @@ parameters:
811 - prod
912 - dev
1013 # Maps environment names to the repositories required for each environment.
11- - name : envToRepo
14+ - name : envToVirtualRepos
1215 type : object
1316 default :
14- all :
15- - geology
16- - geophysics
17- all_deps_only :
18- - geology
19- - geophysics
17+ all : geoplus
2018 geology : geology
2119 geophysics : geophysics
2220 interop : public
23- simpeg : geophysics
21+ simpeg : public
22+ - name : envToRemoteRepos
23+ type : object
24+ default :
25+ all :
26+ - conda-forge
27+ geology :
28+ - conda-forge
29+ geophysics :
30+ - conda-forge
31+ interop :
32+ - conda-forge
33+ simpeg :
34+ - conda-forge
2435
2536stages :
2637 - stage : TestInstallationOnMinimalCondaEnv
@@ -37,30 +48,31 @@ stages:
3748 inputs :
3849 targetType : ' inline'
3950 script : |
40- envFolder="environments "
51+ buildEnvFolder="build "
4152 artifactFolder="artifact_envFiles"
4253
4354 # Create test directories and files
44- mkdir -p "$envFolder " "$artifactFolder"
55+ mkdir -p "environments " "$artifactFolder"
4556
4657 # DiscoverFiles
47- files=$(find $envFolder -name "py-3.10 -win-64-*.yml")
58+ files=$(find $buildEnvFolder -name "py-${{parameters.pythonVersion}} -win-64-*.yml")
4859 if [[ -z "$files" ]]; then
49- echo "No win-64 environment files found in $envFolder "
60+ echo "No win-64 environment files found in $buildEnvFolder "
5061 exit 1
5162 fi
5263
53- envToRepoJson='${{ convertToJson(parameters.envToRepo) }}'
64+ envToVirtualReposJson='${{ convertToJson(parameters.envToVirtualRepos) }}'
65+ envToRemoteReposJson='${{ convertToJson(parameters.envToRemoteRepos) }}'
5466
5567 # Initialize the matrix JSON
5668 matrix="{}"
5769
58- # Iterate through each key-value pair in envToRepo
70+ # Iterate through each key-value pair in envToVirtualRepos
5971 while read -r entry; do
6072 key=$(echo "$entry" | jq -r '.key')
6173 value=$(echo "$entry" | jq -r '.value')
6274 # Find the corresponding file
63- matchingFile=$(echo "$files" | grep -m 1 "$key")
75+ matchingFile=$(echo "$files" | grep -m 1 "$key\.conda\.lock ")
6476
6577 if [ -z "$matchingFile" ]; then
6678 echo "No matching file found for $key, skipping..."
@@ -75,19 +87,23 @@ stages:
7587 repos=$value
7688 fi
7789
90+ # also add repos from envToRemoteRepos for the current key
91+ remoteRepos=$(echo "$envToRemoteReposJson" | jq -r ".$key | join(\" \")")
92+
7893 # Create object
7994 object_string=$( jq -n \
8095 --arg envType "$key" \
8196 --arg filename "$filename" \
8297 --arg repositories "$repos" \
83- '{ ($envType): {name: $envType, filename: $filename, repositories: $repositories }}' )
98+ --arg remotes "$remoteRepos" \
99+ '{ ($envType): {name: $envType, filename: $filename, repositories: $repositories, remotes: $remotes }}' )
84100
85101 # Merge with the main json_obj
86102 matrix=$(echo "$matrix" | jq ". + $object_string")
87103
88104 # Copy matching files to the artifact folder
89105 cp "$matchingFile" "$artifactFolder/"
90- done < <(echo "$envToRepoJson " | jq -c 'to_entries[]')
106+ done < <(echo "$envToVirtualReposJson " | jq -c 'to_entries[]')
91107
92108 json_matrix=$(echo $matrix | jq -c .)
93109
@@ -101,8 +117,8 @@ stages:
101117 pool :
102118 vmImage : ' windows-2022'
103119 container :
104- image : mirageoscienceltd.jfrog. io/mira-docker-local /windows-servercore-ltsc2022-micromamba:latest
105- endpoint : Docker-Artifactory
120+ image : ghcr. io/mirageoscience /windows-servercore-ltsc2022-micromamba:latest
121+ endpoint : mira-github-docker
106122 dependsOn : DiscoverFiles
107123 strategy :
108124 matrix : $[ dependencies.DiscoverFiles.outputs['DiscoverFiles.matrix'] ]
@@ -118,58 +134,44 @@ stages:
118134 inputs :
119135 targetType : ' inline'
120136 script : |
121- $string = "$(repositories)"
122- $array = $string.Split(" ")
123137 $conda_channels = ""
124- $i = 0
125- foreach ($repo in $array) {
126- echo "Adding repository ${repo}-conda-${{ parameters.environment }}"
127- $url = "https://$(JFROG_ARTIFACTORY_USER):$(JFROG_ARTIFACTORY_TOKEN)@$(JFROG_ARTIFACTORY_URL)/conda/${repo}-conda-${{ parameters.environment }}"
128- micromamba config append channels $url
129- $conda_channels += $url
130- if (($array.Length - $i) -gt 1) {
131- $conda_channels += ","
132- }
133- $i++
134- }
135- echo "##vso[task.setvariable variable=conda_channels;issecret=true]$conda_channels"
136- - task : PowerShell@2
137- name : ConfigurePyPISources
138- displayName : Configure PyPI sources
139- inputs :
140- targetType : ' inline'
141- script : |
142- $string = "$(repositories)"
143- $array = $string.Split(" ")
144- $index_url = ""
145- $extra_index_url = ""
146- $i = 0
147- foreach ($repo in $array) {
148- echo "Adding repository ${repo}-pypi-${{ parameters.environment }}"
149- $url = "https://$(JFROG_ARTIFACTORY_USER):$(JFROG_ARTIFACTORY_TOKEN)@$(JFROG_ARTIFACTORY_URL)/pypi/${repo}-pypi-${{ parameters.environment }}/simple"
150- if ($i -eq 0) {
151- $index_url = $url
152- } else {
153- $extra_index_url += $url
154- if (($array.Length - $i) -gt 1) {
155- $extra_index_url += " "
138+ $conda_virtual_repos = "$(repositories)".Split(" ")
139+ if ($conda_virtual_repos -ne "") {
140+ foreach ($repo in $conda_virtual_repos) {
141+ $repo_name = "${repo}-noremote-conda-${{ parameters.environment }}"
142+ echo "Adding Conda channel for '${repo_name}'"
143+ $url = "https://$(JFROG_ARTIFACTORY_USER):$(JFROG_ARTIFACTORY_TOKEN)@$(JFROG_ARTIFACTORY_URL)/conda/${repo_name}"
144+ if ($conda_channels -ne "") {
145+ $conda_channels += ","
156146 }
147+ $conda_channels += $url
157148 }
158- $i++
159149 }
160- echo "##vso[task.setvariable variable=extra_index_url;issecret=true]$extra_index_url"
161- echo "##vso[task.setvariable variable=index_url;issecret=true]$index_url"
150+
151+ $remote_repos = "$(remotes)".Split(" ") -join ","
152+ echo "Adding Conda channels: '${remote_repos}'"
153+ if ($conda_channels -and $remote_repos) {
154+ $conda_channels += ","
155+ }
156+ $conda_channels += "${remote_repos}"
157+ echo "##vso[task.setvariable variable=conda_channels;issecret=true]$conda_channels"
162158 - task : PowerShell@2
163159 name : InstallEnvironment
164160 displayName : Install environment
165161 inputs :
166162 targetType : ' inline'
167163 script : |
168164 $Env:CONDA_CHANNELS = "$(conda_channels)"
169- $Env:CONDARC = "$(Pipeline.Workspace)/envFiles"
170- $Env:PIP_INDEX_URL = "$(index_url)"
171- $Env:PIP_EXTRA_INDEX_URL = "$(extra_index_url)"
165+ $Env:MAMBA_CHANNEL_ALIAS = "https://repo.prefix.dev"
166+ $Env:MAMBA_CHANNEL_PRIORITY = "strict" # make sure Artifactory takes precedence over conda-forge
172167 $Env:PIP_NO_DEPS = 1
173168 cd $(Pipeline.Workspace)/envFiles
174- micromamba env create -y -f $(filename) -n $(name)
175-
169+ micromamba --no-rc env create -y -f $(filename) -n $(name)
170+ - task : PowerShell@2
171+ name : CheckEnvironment
172+ displayName : Check environment
173+ inputs :
174+ targetType : ' inline'
175+ script : |
176+ micromamba --no-rc run -n $(name) python -c "import geoh5py; print(f'geoh5py version: {geoh5py.__version__}')"
177+ micromamba --no-rc run -n $(name) python -c "import numpy; print(f'numpy version: {numpy.__version__}')"
0 commit comments