Skip to content

Commit d5a9a6c

Browse files
committed
Update GH action to test conda package using conda-forge channel only
1 parent f736ef3 commit d5a9a6c

File tree

2 files changed

+68
-18
lines changed

2 files changed

+68
-18
lines changed

.github/workflows/conda-package-cf.yml

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,21 @@ jobs:
3030
numpy: "2.3"
3131
- python: "3.14"
3232
numpy: "2.3"
33+
3334
steps:
35+
- name: Cancel Previous Runs
36+
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1
37+
with:
38+
access_token: ${{ github.token }}
39+
3440
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3541
with:
3642
fetch-depth: 0
3743

3844
- name: Set pkgs_dirs
3945
run: |
4046
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
47+
4148
- name: Cache conda packages
4249
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
4350
env:
@@ -52,8 +59,15 @@ jobs:
5259
5360
- name: Add conda to system path
5461
run: echo $CONDA/bin >> $GITHUB_PATH
62+
5563
- name: Install conda-build
5664
run: conda install conda-build
65+
66+
- name: Store conda paths as envs
67+
shell: bash -el {0}
68+
run: |
69+
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> $GITHUB_ENV
70+
5771
- name: Build conda package
5872
run: |
5973
CHANNELS="-c conda-forge --override-channels"
@@ -65,11 +79,12 @@ jobs:
6579
$VERSIONS \
6680
$CHANNELS \
6781
conda-recipe-cf
82+
6883
- name: Upload artifact
6984
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
7085
with:
7186
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
72-
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.conda
87+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
7388

7489
build_windows:
7590
runs-on: windows-latest
@@ -87,17 +102,24 @@ jobs:
87102
numpy: "2.3"
88103
- python: "3.14"
89104
numpy: "2.3"
90-
env:
91-
conda-bld: C:\Miniconda\conda-bld\win-64\
105+
92106
steps:
107+
- name: Cancel Previous Runs
108+
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1
109+
with:
110+
access_token: ${{ github.token }}
111+
93112
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
94113
with:
95114
fetch-depth: 0
115+
96116
- uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
97117
with:
98-
conda-remove-defaults: true
99-
auto-activate-base: true
100-
activate-environment: ""
118+
miniforge-version: latest
119+
use-mamba: 'true'
120+
conda-remove-defaults: 'true'
121+
activate-environment: 'build'
122+
python-version: '3.13' # no python 3.14 support by conda-build
101123

102124
- name: Cache conda packages
103125
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
@@ -110,20 +132,27 @@ jobs:
110132
restore-keys: |
111133
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
112134
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
135+
113136
- name: Install conda-build
114137
run: conda install conda-build
115-
- name: Setup MSVC
116-
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
138+
139+
- name: Store conda paths as envs
140+
shell: bash -el {0}
141+
run: |
142+
echo "CONDA_BLD=$CONDA_PREFIX\\conda-bld\\win-64\\" >> $GITHUB_ENV
143+
117144
- name: Build conda package
118145
run: conda build --no-test --python ${{ matrix.python }} --numpy ${{ matrix.numpy }} -c conda-forge --override-channels conda-recipe-cf
146+
119147
- name: Upload artifact
120148
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
121149
with:
122150
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
123-
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.conda
151+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
124152

125153
test_linux:
126154
needs: build_linux
155+
127156
runs-on: ubuntu-latest
128157

129158
strategy:
@@ -148,10 +177,13 @@ jobs:
148177
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
149178
with:
150179
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
180+
151181
- name: Add conda to system path
152182
run: echo $CONDA/bin >> $GITHUB_PATH
183+
153184
- name: Install conda-build
154185
run: conda install conda-build
186+
155187
- name: Create conda channel
156188
run: |
157189
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
@@ -161,16 +193,19 @@ jobs:
161193
# Test channel
162194
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
163195
cat ver.json
196+
164197
- name: Collect dependencies
165198
run: |
166199
. $CONDA/etc/profile.d/conda.sh
167200
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
168201
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
169202
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
170203
cat lockfile
204+
171205
- name: Set pkgs_dirs
172206
run: |
173207
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
208+
174209
- name: Cache conda packages
175210
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
176211
env:
@@ -189,8 +224,11 @@ jobs:
189224
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
190225
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
191226
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} $CHANNELS
227+
conda activate ${{ env.TEST_ENV_NAME }}
228+
192229
# Test installed packages
193230
conda list
231+
194232
- name: Run tests
195233
run: |
196234
. $CONDA/etc/profile.d/conda.sh
@@ -199,6 +237,7 @@ jobs:
199237
200238
test_windows:
201239
needs: build_windows
240+
202241
runs-on: windows-latest
203242

204243
strategy:
@@ -223,22 +262,28 @@ jobs:
223262
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
224263
with:
225264
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
265+
226266
- uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
227267
with:
228-
conda-remove-defaults: true
229-
auto-activate-base: true
230-
activate-environment: ""
231-
- name: Install conda-build
232-
# Needed to be able to run conda index
233-
run: conda install conda-build
268+
miniforge-version: latest
269+
use-mamba: 'true'
270+
conda-remove-defaults: 'true'
271+
activate-environment: 'test'
272+
python-version: '3.13' # no python 3.14 support by conda-index
273+
274+
- name: Install conda-index
275+
run: conda install conda-index
276+
234277
- name: Create conda channel
235278
run: |
236279
mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64
237280
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}\channel\win-64
238-
conda index ${{ env.GITHUB_WORKSPACE }}/channel
281+
python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel
282+
239283
# Test channel
240284
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json
241285
more ${{ env.GITHUB_WORKSPACE }}\ver.json
286+
242287
- name: Collect dependencies
243288
shell: cmd
244289
run: |
@@ -250,6 +295,7 @@ jobs:
250295
)
251296
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
252297
more lockfile
298+
253299
- name: Cache conda packages
254300
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
255301
env:
@@ -261,6 +307,7 @@ jobs:
261307
restore-keys: |
262308
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
263309
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
310+
264311
- name: Install mkl_random
265312
shell: cmd
266313
run: |
@@ -271,8 +318,11 @@ jobs:
271318
SET PACKAGE_VERSION=%%F
272319
)
273320
conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% pytest python=${{ matrix.python }} numpy=${{ matrix.numpy }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }}
321+
conda activate -n ${{ env.TEST_ENV_NAME }}
322+
274323
# Test installed packages
275324
conda list
325+
276326
- name: Run tests
277327
run: |
278328
conda activate -n ${{ env.TEST_ENV_NAME }}

.github/workflows/conda-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
test_linux:
135135
needs: build_linux
136136

137-
runs-on: ubuntu-latest
137+
runs-on: ubuntu-latest
138138

139139
strategy:
140140
matrix:
@@ -217,7 +217,7 @@ jobs:
217217
test_windows:
218218
needs: build_windows
219219

220-
runs-on: windows-latest
220+
runs-on: windows-latest
221221

222222
strategy:
223223
matrix:

0 commit comments

Comments
 (0)