Skip to content

Commit 05d9756

Browse files
Add windows to build system
1 parent 50ec28d commit 05d9756

File tree

1 file changed

+129
-10
lines changed

1 file changed

+129
-10
lines changed

.github/workflows/conda-package.yml

Lines changed: 129 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ on: push
55
env:
66
PACKAGE_NAME: mkl_random
77
MODULE_NAME: mkl_random
8+
VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); "
9+
VER_SCRIPT2: "d = j['dpctl'][0]; print('='.join((d[s] for s in ('version', 'build'))))"
810

911
jobs:
10-
build:
12+
build_linux:
1113
runs-on: ubuntu-latest
1214
strategy:
1315
matrix:
@@ -53,8 +55,46 @@ jobs:
5355
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
5456
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2
5557

56-
test:
57-
needs: build
58+
build_windows:
59+
runs-on: windows-latest
60+
61+
strategy:
62+
matrix:
63+
python: ['3.9']
64+
env:
65+
conda-bld: C:\Miniconda\conda-bld\win-64\
66+
steps:
67+
- uses: actions/checkout@v2
68+
with:
69+
fetch-depth: 0
70+
- uses: conda-incubator/setup-miniconda@v2
71+
with:
72+
auto-activate-base: true
73+
activate-environment: ""
74+
75+
- name: Cache conda packages
76+
uses: actions/cache@v3
77+
env:
78+
CACHE_NUMBER: 3 # Increase to reset cache
79+
with:
80+
path: /home/runner/conda_pkgs_dir
81+
key:
82+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
83+
restore-keys: |
84+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
85+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
86+
- name: Install conda-build
87+
run: conda install conda-build
88+
- name: Build conda package
89+
run: conda build --no-test --python ${{ matrix.python }} -c intel -c defaults --override-channels conda-recipe
90+
- name: Upload artifact
91+
uses: actions/upload-artifact@v2
92+
with:
93+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
94+
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.tar.bz2
95+
96+
test_linux:
97+
needs: build_linux
5898
runs-on: ${{ matrix.runner }}
5999

60100
strategy:
@@ -78,15 +118,19 @@ jobs:
78118
- name: Create conda channel
79119
run: |
80120
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
81-
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64
82-
conda index $GITHUB_WORKSPACE/channel
121+
conda index $GITHUB_WORKSPACE/channel || exit 1
122+
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64 || exit 1
123+
conda index $GITHUB_WORKSPACE/channel || exit 1
83124
# Test channel
84-
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels
85-
125+
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
126+
cat ver.json
86127
- name: Collect dependencies
87128
run: |
129+
. $CONDA/etc/profile.d/conda.sh
88130
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
89-
conda install $PACKAGE_NAME python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile
131+
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
132+
conda create -n test_mkl_random $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile
133+
cat lockfile
90134
- name: Set pkgs_dirs
91135
run: |
92136
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
@@ -104,11 +148,86 @@ jobs:
104148
105149
- name: Install mkl_random
106150
run: |
151+
. $CONDA/etc/profile.d/conda.sh
107152
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
108-
conda install $PACKAGE_NAME nose python=${{ matrix.python }} $CHANNELS
153+
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
154+
conda create -n test_mkl_random $PACKAGE_NAME=${PACKAGE_VERSION} nose python=${{ matrix.python }} $CHANNELS
109155
# Test installed packages
110156
conda list
111157
- name: Run tests
112158
run: |
113-
# python -m pytest --pyargs $MODULE_NAME
159+
. $CONDA/etc/profile.d/conda.sh
160+
conda activate test_mkl_random
114161
nosetests -v mkl_random
162+
163+
test_windows:
164+
needs: build_windows
165+
runs-on: ${{ matrix.runner }}
166+
167+
strategy:
168+
matrix:
169+
python: ['3.9']
170+
experimental: [false]
171+
runner: [windows-latest]
172+
continue-on-error: ${{ matrix.experimental }}
173+
env:
174+
CHANNELS: -c intel -c defaults --override-channels
175+
176+
steps:
177+
- name: Download artifact
178+
uses: actions/download-artifact@v2
179+
with:
180+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
181+
- uses: conda-incubator/setup-miniconda@v2
182+
with:
183+
auto-activate-base: true
184+
activate-environment: ""
185+
- name: Install conda-build
186+
# Needed to be able to run conda index
187+
run: conda install conda-build
188+
- name: Create conda channel
189+
run: |
190+
mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64
191+
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.GITHUB_WORKSPACE }}\channel\win-64
192+
conda index ${{ env.GITHUB_WORKSPACE }}/channel
193+
# Test channel
194+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json
195+
more ${{ env.GITHUB_WORKSPACE }}\ver.json
196+
- name: Collect dependencies
197+
shell: cmd
198+
run: |
199+
@ECHO ON
200+
copy /Y ${{ env.GITHUB_WORKSPACE }}\ver.json .
201+
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
202+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
203+
SET PACKAGE_VERSION=%%F
204+
)
205+
conda create -n test_mkl_random ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
206+
more lockfile
207+
- name: Cache conda packages
208+
uses: actions/cache@v3
209+
env:
210+
CACHE_NUMBER: 3 # Increase to reset cache
211+
with:
212+
path: /home/runner/conda_pkgs_dir
213+
key:
214+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
215+
restore-keys: |
216+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
217+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
218+
- name: Install mkl_random
219+
shell: cmd
220+
run: |
221+
@ECHO ON
222+
copy /Y ${{ env.GITHUB_WORKSPACE }}\ver.json .
223+
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
224+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
225+
SET PACKAGE_VERSION=%%F
226+
)
227+
conda create -n test_mkl_random ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% nose python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }}
228+
# Test installed packages
229+
conda list
230+
- name: Run tests
231+
run: |
232+
conda activate -n test_mkl_random
233+
nosetests -v ${{ env.MODULE_NAME }}

0 commit comments

Comments
 (0)