Skip to content

Commit d2b5118

Browse files
committed
[DEVOPS-584] Merge remote-tracking branch 'upstream/main' into DEVOPS-584
# Conflicts: # .github/workflows/reusable-python-pytest.yml # .github/workflows/reusable-python-static_analysis.yml
2 parents 247eaba + 2fe3021 commit d2b5118

21 files changed

Lines changed: 509 additions & 337 deletions
Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# File: template-test-minimal-conda-env-install.yml
22
parameters:
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

2536
stages:
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__}')"

.docker-images/windows-servercore-ltsc2022-micromamba/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2022
22
USER ContainerAdministrator
33
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://vcredist.com/install.ps1'))
44
USER ContainerUser
5-
ADD https://github.com/mamba-org/micromamba-releases/releases/download/1.5.10-0/micromamba-win-64 micromamba.exe
5+
ADD https://github.com/mamba-org/micromamba-releases/releases/download/2.1.0-0/micromamba-win-64 micromamba.exe
66
RUN mkdir %USERPROFILE%\micromamba && \
77
copy micromamba.exe %USERPROFILE%\micromamba && \
88
del micromamba.exe && \

.github/actions/reusable-python-setup_conda/action.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,44 @@ inputs:
55
description: 'Python version to use'
66
required: true
77
type: string
8+
JFROG_ARTIFACTORY_URL:
9+
description: 'JFrog Artifactory URL, needed if packages are on Artifactory'
10+
required: false
11+
type: string
12+
JFROG_ARTIFACTORY_TOKEN:
13+
description: 'JFrog Artifactory Token, needed if packages are on Artifactory'
14+
required: false
15+
type: string
16+
817

918
runs:
1019
using: "composite"
1120
steps:
1221
- uses: actions/checkout@v4
13-
- name: Setup CONDA_LOCK_ENV_FILE
22+
- name: Setup env vars
1423
shell: bash
1524
run: |
1625
os_conda=$( [[ $RUNNER_OS == "Linux" ]] && echo "linux" || echo "win")
17-
echo "os_conda=$os_conda" >> $GITHUB_ENV
18-
- name: Setup conda env
19-
uses: mamba-org/setup-micromamba@v1
26+
echo "os_conda=$os_conda" >> "$GITHUB_ENV"
27+
echo "micromamba_version=2.1.0-0" >> "$GITHUB_ENV"
28+
echo "MAMBA_CHANNEL_ALIAS=https://repo.prefix.dev" >> "$GITHUB_ENV"
29+
- name: Setup micromamba
30+
uses: mamba-org/setup-micromamba@v2
31+
with:
32+
micromamba-version: ${{ env.micromamba_version }}
33+
init-shell: bash
34+
cache-downloads: true
35+
environment-name: ""
36+
post-cleanup: none
37+
- name: Authenticate to Artifactory
38+
if: ${{ inputs.JFROG_ARTIFACTORY_URL && inputs.JFROG_ARTIFACTORY_TOKEN }}
39+
shell: 'bash -l {0}'
40+
run: |
41+
micromamba auth login ${{ inputs.JFROG_ARTIFACTORY_URL }} -u github -p ${{ inputs.JFROG_ARTIFACTORY_TOKEN }}
42+
- name: Create conda env
43+
uses: mamba-org/setup-micromamba@v2
2044
with:
21-
micromamba-version: 1.5.8-0
45+
micromamba-version: ${{ env.micromamba_version }}
2246
environment-file: ${{ env.CONDA_LOCK_ENV_FILE }}
2347
environment-name: test_env
2448
init-shell: bash
@@ -27,5 +51,6 @@ runs:
2751
env:
2852
PYTHONUTF8: 1
2953
CONDA_CHANNEL_PRIORITY: strict
54+
MAMBA_CHANNEL_PRIORITY: strict
3055
PIP_NO_DEPS: 1 # all dependencies are installed from conda
3156
CONDA_LOCK_ENV_FILE: 'environments/py-${{ inputs.python-version }}-${{ env.os_conda }}-64-dev.conda.lock.yml'

.github/actions/reusable-python-setup_poetry/action.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ inputs:
99
description: 'Runner OS'
1010
required: true
1111
type: string
12+
install-extras:
13+
description: 'Extra dependencies to install (eg. ["torch", "cuda"])'
14+
required: false
15+
type: string
1216
virtual-repo-names:
1317
description: 'Matrix of virtual repository names to resolve (eg. ["public-dev-pypi"])'
1418
required: false
@@ -25,17 +29,17 @@ runs:
2529
id: full-python-version
2630
shell: bash
2731
run: echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT
28-
- name: Install poetry
29-
shell: bash
30-
run: |
31-
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python -
32-
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
33-
- name: Config poetry
32+
- name: Install and configure Poetry
33+
uses: snok/install-poetry@v1
34+
with:
35+
version: 2.1.3
36+
plugins: poetry-dynamic-versioning
37+
virtualenvs-in-project: true
38+
virtualenvs-path: .venv
39+
installer-parallel: true
40+
- name: Config repos for Poetry
3441
shell: bash
3542
run: |
36-
poetry config virtualenvs.create true
37-
poetry config virtualenvs.in-project true
38-
3943
repository_list=$(echo '${{ inputs.virtual-repo-names }}' | jq -r '.[]')
4044
for repo_name in ${repository_list}; do
4145
first_part=$(echo "$repo_name" | cut -d'-' -f1 | tr '[:upper:]' '[:lower:]')
@@ -45,8 +49,6 @@ runs:
4549
- name: Set up cache
4650
uses: actions/cache@v4
4751
id: cache
48-
env:
49-
cache-number: ${{ inputs.cache-number }}
5052
with:
5153
path: .venv
5254
key: venv-${{ inputs.runner-os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}-{{ inputs.cache-number }}
@@ -56,4 +58,6 @@ runs:
5658
run: timeout 10s poetry run pip --version || rm -rf .venv
5759
- name: Install dependencies
5860
shell: bash
59-
run: poetry install -vvv
61+
run: |
62+
extra_args=$(echo '${{ inputs.install-extras }}' | jq -r 'map("-E " + .) | join(" ")')
63+
poetry install -vvv $(echo "$extra_args")

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ updates:
99
directory: "/"
1010
schedule:
1111
interval: "monthly"
12-
target-branch: "develop"
12+
target-branch: "main"

.github/workflows/jira-issue_to_jira.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Create JIRA issue
22

3+
permissions:
4+
issues: write
5+
36
on:
47
issues:
58
types: [opened]

.github/workflows/jira-pr_add_jira_summary.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Add JIRA issue summary
22

3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
37
on:
48
pull_request_target:
59
types: [opened]

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: pre-commit
22

3+
permissions:
4+
contents: read
5+
statuses: write
6+
37
on:
48
pull_request:
59
types: [opened, synchronize, reopened, ready_for_review]

.github/workflows/reusable-jira-issue_to_jira.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
required: true
2121
type: string
2222
components:
23-
description: 'JIRA components (eg. [{"name": "geoh5py"}])'
23+
description: 'JIRA components (e.g. [{"name": "geoh5py"}])'
2424
required: false
2525
type: string
2626

@@ -30,6 +30,14 @@ jobs:
3030
runs-on: ubuntu-latest
3131
timeout-minutes: 20
3232
steps:
33+
- name: Set Jira fields
34+
id: set_jira_fields
35+
run: |
36+
if [[ -z "${{ inputs.components }}" ]]; then
37+
echo 'jira_fields={}' >> $GITHUB_OUTPUT
38+
else
39+
echo 'jira_fields={"components": ${{ inputs.components }} }' >> $GITHUB_OUTPUT
40+
fi
3341
- name: JIRA Login
3442
uses: atlassian/gajira-login@v3.0.1
3543
env:
@@ -45,7 +53,7 @@ jobs:
4553
summary: ${{ github.event.issue.title }}
4654
description: "_from [GitHub issue #${{ github.event.issue.number }}|${{ github.event.issue.html_url }}]_"
4755
# Additional fields in JSON format
48-
fields: '{"components": ${{ inputs.components }} }'
56+
fields: "${{ steps.set_jira_fields.outputs.jira_fields }}"
4957
- name: Post JIRA link
5058
uses: peter-evans/create-or-update-comment@v4
5159
with:

0 commit comments

Comments
 (0)