Skip to content

Commit 99cbbb4

Browse files
author
Vahid Tavanashad
committed
add a new workflow
1 parent 13967b9 commit 99cbbb4

File tree

6 files changed

+457
-83
lines changed

6 files changed

+457
-83
lines changed

.github/workflows/build_pip.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Editable build using pip
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions: read-all
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
shell: bash -el {0}
17+
18+
strategy:
19+
matrix:
20+
python: ['3.9', '3.10', '3.11', '3.12']
21+
numpy_ver: ['1.26']
22+
23+
steps:
24+
- name: Install jq
25+
shell: bash -l {0}
26+
run: |
27+
sudo apt-get install jq
28+
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- uses: conda-incubator/setup-miniconda@v3
34+
with:
35+
use-mamba: true
36+
miniforge-version: latest
37+
channels: conda-forge
38+
conda-remove-defaults: true
39+
activate-environment: test
40+
python-version: ${{ matrix.python }}
41+
42+
- name: Install Compiler and MKL
43+
run: |
44+
conda install mkl-devel mkl-service dpcpp_linux-64
45+
python -c "import sys; print(sys.executable)"
46+
which python
47+
python -c "import mkl; print(mkl.__file__)"
48+
49+
- name: Build conda package
50+
run: |
51+
pip install --no-cache-dir scikit-build cmake ninja cython
52+
pip install --no-cache-dir numpy==${{ matrix.numpy_ver }}
53+
echo "CONDA_PREFFIX is '${CONDA_PREFIX}'"
54+
export MKLROOT=${CONDA_PREFIX}
55+
pip install .[test] --no-build-isolation --verbose
56+
pip list
57+
cd ..
58+
python -m pytest -v mkl_umath/mkl_umath/tests
Lines changed: 316 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,316 @@
1+
name: Conda package with conda-forge channel only
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions: read-all
10+
11+
env:
12+
PACKAGE_NAME: mkl_umath
13+
TEST_ENV_NAME: test_mkl_umath
14+
VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); d = j['mkl_umath'][0];"
15+
VER_SCRIPT2: "print('='.join((d[s] for s in ('version', 'build'))))"
16+
17+
jobs:
18+
build_linux:
19+
runs-on: ubuntu-latest
20+
21+
strategy:
22+
matrix:
23+
python: ['3.9', '3.10', '3.11', '3.12']
24+
25+
steps:
26+
- name: Cancel Previous Runs
27+
uses: styfle/[email protected]
28+
with:
29+
access_token: ${{ github.token }}
30+
31+
- name: Checkout repo
32+
uses: actions/[email protected]
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Set pkgs_dirs
37+
run: |
38+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
39+
40+
- name: Cache conda packages
41+
uses: actions/[email protected]
42+
env:
43+
CACHE_NUMBER: 0 # Increase to reset cache
44+
with:
45+
path: ~/.conda/pkgs
46+
key:
47+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
48+
restore-keys: |
49+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
50+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
51+
52+
- name: Add conda to system path
53+
run: echo $CONDA/bin >> $GITHUB_PATH
54+
55+
- name: Install conda-build
56+
run: conda install conda-build
57+
58+
- name: Build conda package with NumPy 2.0
59+
run: |
60+
CHANNELS="-c conda-forge --override-channels"
61+
VERSIONS="--python ${{ matrix.python }} --numpy 2.0"
62+
TEST="--no-test"
63+
echo "CONDA_BLD=${CONDA}/conda-bld/linux-64" >> $GITHUB_ENV
64+
65+
conda build \
66+
$TEST \
67+
$VERSIONS \
68+
$CHANNELS \
69+
conda-recipe-cf
70+
71+
- name: Upload artifact
72+
uses: actions/[email protected]
73+
with:
74+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
75+
path: $CONDA_BLD/${{ env.PACKAGE_NAME }}-*.conda
76+
77+
test_linux:
78+
needs: build_linux
79+
runs-on: ${{ matrix.runner }}
80+
81+
strategy:
82+
matrix:
83+
python: ['3.9', '3.10', '3.11', '3.12']
84+
numpy: ['numpy"<2"', 'numpy">=2"']
85+
experimental: [false]
86+
runner: [ubuntu-latest]
87+
continue-on-error: ${{ matrix.experimental }}
88+
env:
89+
CHANNELS: -c conda-forge --override-channels
90+
91+
steps:
92+
- name: Download artifact
93+
uses: actions/[email protected]
94+
with:
95+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
96+
97+
- name: Add conda to system path
98+
run: echo $CONDA/bin >> $GITHUB_PATH
99+
100+
- name: Install conda-build
101+
run: conda install conda-build
102+
103+
- name: Create conda channel
104+
run: |
105+
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
106+
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64
107+
conda index $GITHUB_WORKSPACE/channel
108+
# Test channel
109+
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels
110+
111+
- name: Collect dependencies
112+
run: |
113+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
114+
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME python=${{ matrix.python }} ${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile
115+
116+
- name: Display lockfile
117+
run: cat lockfile
118+
119+
- name: Set pkgs_dirs
120+
run: |
121+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
122+
123+
- name: Cache conda packages
124+
uses: actions/[email protected]
125+
env:
126+
CACHE_NUMBER: 0 # Increase to reset cache
127+
with:
128+
path: ~/.conda/pkgs
129+
key:
130+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
131+
restore-keys: |
132+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
133+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
134+
135+
- name: Install mkl_umath
136+
run: |
137+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
138+
conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python }} ${{ matrix.numpy }} $PACKAGE_NAME pytest $CHANNELS
139+
# Test installed packages
140+
conda list -n ${{ env.TEST_ENV_NAME }}
141+
142+
- name: Run tests
143+
run: |
144+
source $CONDA/etc/profile.d/conda.sh
145+
conda activate ${{ env.TEST_ENV_NAME }}
146+
pytest -v --pyargs ${{ env.PACKAGE_NAME }}
147+
148+
build_windows:
149+
runs-on: windows-2019
150+
151+
strategy:
152+
matrix:
153+
python: ['3.9', '3.10', '3.11', '3.12']
154+
155+
steps:
156+
- name: Cancel Previous Runs
157+
uses: styfle/[email protected]
158+
with:
159+
access_token: ${{ github.token }}
160+
161+
- name: Checkout repo
162+
uses: actions/[email protected]
163+
with:
164+
fetch-depth: 0
165+
166+
- uses: conda-incubator/setup-miniconda@v3
167+
with:
168+
miniforge-version: latest
169+
activate-environment: build
170+
python-version: ${{ matrix.python }}
171+
channels: conda-forge
172+
conda-remove-defaults: 'true'
173+
174+
- name: Store conda paths as envs
175+
shell: bash -l {0}
176+
run: |
177+
echo "CONDA_BLD=$CONDA/conda-bld/win-64" | tr "\\\\" '/' >> $GITHUB_ENV
178+
179+
- name: Install conda-build
180+
run: |
181+
conda activate
182+
conda install -n base conda-build
183+
184+
- name: Cache conda packages
185+
uses: actions/[email protected]
186+
env:
187+
CACHE_NUMBER: 3 # Increase to reset cache
188+
with:
189+
path: /home/runner/conda_pkgs_dir
190+
key:
191+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
192+
restore-keys: |
193+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
194+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
195+
196+
- name: Build conda package with NumPy 2.0
197+
run: |
198+
conda activate
199+
conda build --no-test --python ${{ matrix.python }} --numpy 2.0 -c conda-forge --override-channels conda-recipe-cf
200+
201+
- name: Upload artifact
202+
uses: actions/[email protected]
203+
with:
204+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
205+
path: $CONDA_BLD/${{ env.PACKAGE_NAME }}-*.conda
206+
207+
test_windows:
208+
needs: build_windows
209+
runs-on: ${{ matrix.runner }}
210+
defaults:
211+
run:
212+
shell: cmd /C CALL {0}
213+
214+
strategy:
215+
matrix:
216+
python: ['3.9', '3.10', '3.11', '3.12']
217+
numpy: ['numpy"<2"', 'numpy">=2"']
218+
experimental: [false]
219+
runner: [windows-2019]
220+
continue-on-error: ${{ matrix.experimental }}
221+
env:
222+
workdir: '${{ github.workspace }}'
223+
CHANNELS: -c conda-forge --override-channels
224+
225+
steps:
226+
- name: Download artifact
227+
uses: actions/[email protected]
228+
with:
229+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
230+
231+
- uses: conda-incubator/setup-miniconda@v3
232+
with:
233+
miniforge-version: latest
234+
activate-environment: ${{ env.TEST_ENV_NAME }}
235+
python-version: ${{ matrix.python }}
236+
channels: conda-forge
237+
conda-remove-defaults: 'true'
238+
239+
- name: Create conda channel with the artifact bit
240+
run: |
241+
echo ${{ env.workdir }}
242+
mkdir ${{ env.workdir }}\channel
243+
mkdir ${{ env.workdir }}\channel\win-64
244+
move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.workdir }}\channel\win-64
245+
dir ${{ env.workdir }}\channel\win-64
246+
247+
- name: Install conda-index
248+
run: |
249+
conda install -n base conda-index
250+
251+
- name: Index the channel
252+
run: |
253+
conda index ${{ env.workdir }}\channel
254+
255+
- name: Dump mkl_umath version info from created channel into ver.json
256+
run: |
257+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json
258+
259+
- name: Output content of produced ver.json
260+
shell: pwsh
261+
run: Get-Content -Path ${{ env.workdir }}\ver.json
262+
263+
- name: Collect dependencies
264+
run: |
265+
@ECHO ON
266+
IF NOT EXIST ver.json (
267+
copy /Y ${{ env.workdir }}\ver.json .
268+
)
269+
SET "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
270+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
271+
SET PACKAGE_VERSION=%%F
272+
)
273+
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
274+
275+
- name: Display lockfile content
276+
shell: pwsh
277+
run: Get-Content -Path .\lockfile
278+
279+
- name: Cache conda packages
280+
uses: actions/[email protected]
281+
env:
282+
CACHE_NUMBER: 0 # Increase to reset cache
283+
with:
284+
path: /home/runner/conda_pkgs_dir
285+
key:
286+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
287+
restore-keys: |
288+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
289+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
290+
291+
# add intel-openmp as an explicit dependency
292+
# to avoid it being missed when package version is specified exactly
293+
- name: Install mkl_umath
294+
run: |
295+
@ECHO ON
296+
IF NOT EXIST ver.json (
297+
copy /Y ${{ env.workdir }}\ver.json .
298+
)
299+
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
300+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
301+
SET PACKAGE_VERSION=%%F
302+
)
303+
SET "TEST_DEPENDENCIES=pytest pytest-cov"
304+
SET "WORKAROUND_DEPENDENCIES=intel-openmp"
305+
SET "DEPENDENCIES=%TEST_DEPENDENCIES% %WORKAROUND_DEPENDENCIES%"
306+
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %DEPENDENCIES% python=${{ matrix.python }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
307+
308+
- name: Report content of test environment
309+
run: |
310+
echo "Value of CONDA environment variable was: " %CONDA%
311+
echo "Value of CONDA_PREFIX environment variable was: " %CONDA_PREFIX%
312+
conda info && conda list -n ${{ env.TEST_ENV_NAME }}
313+
314+
- name: Run tests
315+
run: |
316+
conda activate ${{ env.TEST_ENV_NAME }} && python -m pytest -v -s --pyargs ${{ env.PACKAGE_NAME }}

0 commit comments

Comments
 (0)