Skip to content

Commit 7226a72

Browse files
authored
Merge pull request #85 from IntelPython/update-miniconda-gh-action
Improve GitHub workflow `conda-package.yml`
2 parents 61d97d2 + 983ff5f commit 7226a72

File tree

1 file changed

+72
-19
lines changed

1 file changed

+72
-19
lines changed

.github/workflows/conda-package.yml

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,25 @@ env:
1717
jobs:
1818
build_linux:
1919
runs-on: ubuntu-latest
20+
2021
strategy:
2122
matrix:
2223
python: ["3.10", "3.11", "3.12", "3.13"]
24+
2325
steps:
26+
- name: Cancel Previous Runs
27+
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1
28+
with:
29+
access_token: ${{ github.token }}
30+
2431
- uses: actions/checkout@v4
2532
with:
2633
fetch-depth: 0
2734

2835
- name: Set pkgs_dirs
2936
run: |
3037
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
38+
3139
- name: Cache conda packages
3240
uses: actions/cache@v4
3341
env:
@@ -42,8 +50,15 @@ jobs:
4250
4351
- name: Add conda to system path
4452
run: echo $CONDA/bin >> $GITHUB_PATH
53+
4554
- name: Install conda-build
4655
run: conda install conda-build
56+
57+
- name: Store conda paths as envs
58+
shell: bash -el {0}
59+
run: |
60+
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> $GITHUB_ENV
61+
4762
- name: Build conda package
4863
run: |
4964
CHANNELS="-c https://software.repos.intel.com/python/conda -c conda-forge --override-channels"
@@ -55,29 +70,37 @@ jobs:
5570
$VERSIONS \
5671
$CHANNELS \
5772
conda-recipe
73+
5874
- name: Upload artifact
59-
uses: actions/upload-artifact@v4
75+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
6076
with:
6177
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
62-
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.conda
78+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
6379

6480
build_windows:
6581
runs-on: windows-latest
6682

6783
strategy:
6884
matrix:
6985
python: ["3.10", "3.11", "3.12", "3.13"]
70-
env:
71-
conda-bld: C:\Miniconda\conda-bld\win-64\
86+
7287
steps:
88+
- name: Cancel Previous Runs
89+
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1
90+
with:
91+
access_token: ${{ github.token }}
92+
7393
- uses: actions/checkout@v4
7494
with:
7595
fetch-depth: 0
76-
- uses: conda-incubator/setup-miniconda@v3
96+
97+
- uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
7798
with:
78-
conda-remove-defaults: true
79-
auto-activate-base: true
80-
activate-environment: ""
99+
miniforge-version: latest
100+
use-mamba: 'true'
101+
conda-remove-defaults: 'true'
102+
activate-environment: 'build'
103+
python-version: '3.13' # no python 3.14 support by conda-build
81104

82105
- name: Cache conda packages
83106
uses: actions/cache@v4
@@ -90,21 +113,29 @@ jobs:
90113
restore-keys: |
91114
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
92115
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
116+
93117
- name: Install conda-build
94118
run: conda install conda-build
95-
- name: Setup MSVC
96-
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
119+
120+
- name: Store conda paths as envs
121+
shell: bash -el {0}
122+
run: |
123+
echo "CONDA_BLD=$CONDA_PREFIX\\conda-bld\\win-64\\" >> $GITHUB_ENV
124+
97125
- name: Build conda package
98126
run: conda build --no-test --python ${{ matrix.python }} -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels conda-recipe
127+
99128
- name: Upload artifact
100129
uses: actions/upload-artifact@v4
101130
with:
102131
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
103-
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.conda
132+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
104133

105134
test_linux:
106135
needs: build_linux
136+
107137
runs-on: ubuntu-latest
138+
108139
strategy:
109140
matrix:
110141
include:
@@ -116,6 +147,7 @@ jobs:
116147
numpy: "2.3"
117148
- python: "3.13"
118149
numpy: "2.3"
150+
119151
env:
120152
CHANNELS: -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels
121153

@@ -124,10 +156,13 @@ jobs:
124156
uses: actions/download-artifact@v4
125157
with:
126158
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
159+
127160
- name: Add conda to system path
128161
run: echo $CONDA/bin >> $GITHUB_PATH
162+
129163
- name: Install conda-build
130164
run: conda install conda-build
165+
131166
- name: Create conda channel
132167
run: |
133168
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
@@ -137,16 +172,19 @@ jobs:
137172
# Test channel
138173
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
139174
cat ver.json
175+
140176
- name: Collect dependencies
141177
run: |
142178
. $CONDA/etc/profile.d/conda.sh
143179
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
144180
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
145181
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
146182
cat lockfile
183+
147184
- name: Set pkgs_dirs
148185
run: |
149186
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
187+
150188
- name: Cache conda packages
151189
uses: actions/cache@v4
152190
env:
@@ -165,8 +203,11 @@ jobs:
165203
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
166204
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
167205
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS
206+
conda activate ${{ env.TEST_ENV_NAME }}
207+
168208
# Test installed packages
169209
conda list
210+
170211
- name: Run tests
171212
run: |
172213
. $CONDA/etc/profile.d/conda.sh
@@ -175,6 +216,7 @@ jobs:
175216
176217
test_windows:
177218
needs: build_windows
219+
178220
runs-on: windows-latest
179221

180222
strategy:
@@ -188,6 +230,7 @@ jobs:
188230
numpy: "2.3"
189231
- python: "3.13"
190232
numpy: "2.3"
233+
191234
env:
192235
CHANNELS: -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels
193236

@@ -196,22 +239,28 @@ jobs:
196239
uses: actions/download-artifact@v4
197240
with:
198241
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
199-
- uses: conda-incubator/setup-miniconda@v3
242+
243+
- uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
200244
with:
201-
conda-remove-defaults: true
202-
auto-activate-base: true
203-
activate-environment: ""
204-
- name: Install conda-build
205-
# Needed to be able to run conda index
206-
run: conda install conda-build
245+
miniforge-version: latest
246+
use-mamba: 'true'
247+
conda-remove-defaults: 'true'
248+
activate-environment: 'test'
249+
python-version: '3.13' # no python 3.14 support by conda-index
250+
251+
- name: Install conda-index
252+
run: conda install conda-index
253+
207254
- name: Create conda channel
208255
run: |
209256
mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64
210257
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}\channel\win-64
211-
conda index ${{ env.GITHUB_WORKSPACE }}/channel
258+
python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel
259+
212260
# Test channel
213261
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json
214262
more ${{ env.GITHUB_WORKSPACE }}\ver.json
263+
215264
- name: Collect dependencies
216265
shell: cmd
217266
run: |
@@ -223,6 +272,7 @@ jobs:
223272
)
224273
conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} numpy=${{ matrix.numpy }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
225274
more lockfile
275+
226276
- name: Cache conda packages
227277
uses: actions/cache@v4
228278
env:
@@ -248,8 +298,11 @@ jobs:
248298
)
249299
SET "WORKAROUND_DEPENDENCIES=intel-openmp"
250300
conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %WORKAROUND_DEPENDENCIES% pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }}
301+
conda activate -n ${{ env.TEST_ENV_NAME }}
302+
251303
# Test installed packages
252304
conda list
305+
253306
- name: Run tests
254307
run: |
255308
conda activate -n ${{ env.TEST_ENV_NAME }}

0 commit comments

Comments
 (0)