Skip to content

Commit 475ffe0

Browse files
committed
add osx workflow
1 parent cd985ac commit 475ffe0

1 file changed

Lines changed: 169 additions & 0 deletions

File tree

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: Conda package for osx using conda-forge
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions: read-all
10+
11+
env:
12+
PACKAGE_NAME: mkl-service
13+
MODULE_NAME: mkl
14+
TEST_ENV_NAME: test_mkl_service
15+
VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); "
16+
VER_SCRIPT2: "d = j['mkl-service'][0]; print('='.join((d[s] for s in ('version', 'build'))))"
17+
18+
jobs:
19+
build_osx:
20+
runs-on: macos-latest
21+
22+
strategy:
23+
matrix:
24+
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
25+
26+
steps:
27+
- name: Cancel Previous Runs
28+
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1
29+
with:
30+
access_token: ${{ github.token }}
31+
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
fetch-depth: 0
35+
36+
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
37+
with:
38+
miniforge-version: latest
39+
activate-environment: build
40+
channels: conda-forge
41+
python-version: ${{ matrix.python }}
42+
43+
- name: Cache conda packages
44+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
45+
env:
46+
CACHE_NUMBER: 0 # Increase to reset cache
47+
with:
48+
path: /Users/runner/conda_pkgs_dir
49+
key:
50+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
51+
restore-keys: |
52+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
53+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
54+
55+
- name: Install conda-build
56+
shell: bash -el {0}
57+
run: |
58+
conda install -n base -y conda-build
59+
conda list -n base
60+
61+
- name: Store conda paths as envs
62+
shell: bash -el {0}
63+
run: |
64+
CONDA_SUBDIR=$(conda info --json | python -c "import json,sys; print(json.load(sys.stdin)['subdir'])")
65+
echo "CONDA_BLD=$CONDA/conda-bld/$CONDA_SUBDIR/" >> "$GITHUB_ENV"
66+
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV"
67+
68+
- name: Build conda package
69+
shell: bash -el {0}
70+
run: |
71+
CHANNELS=(-c conda-forge -c conda-forge/label/python_rc --override-channels)
72+
VERSIONS=(--python "${{ matrix.python }}")
73+
TEST=(--no-test)
74+
75+
conda build \
76+
"${TEST[@]}" \
77+
"${VERSIONS[@]}" \
78+
"${CHANNELS[@]}" \
79+
conda-recipe-cf
80+
81+
- name: Upload artifact
82+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
83+
with:
84+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
85+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
86+
87+
- name: Upload wheels artifact
88+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
89+
with:
90+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
91+
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl
92+
93+
test_osx:
94+
needs: build_osx
95+
runs-on: ${{ matrix.runner }}
96+
97+
strategy:
98+
matrix:
99+
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
100+
experimental: [false]
101+
runner: [macos-latest]
102+
continue-on-error: ${{ matrix.experimental }}
103+
env:
104+
CHANNELS: -c conda-forge -c conda-forge/label/python_rc --override-channels
105+
106+
steps:
107+
- name: Download artifact
108+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
109+
with:
110+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
111+
112+
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
113+
with:
114+
miniforge-version: latest
115+
channels: conda-forge
116+
activate-environment: base
117+
118+
- name: Install conda-index
119+
shell: bash -el {0}
120+
run: conda install -n base -y conda-index
121+
122+
- name: Create conda channel
123+
shell: bash -el {0}
124+
run: |
125+
CONDA_SUBDIR=$(conda info --json | python -c "import json,sys; print(json.load(sys.stdin)['subdir'])")
126+
mkdir -p "$GITHUB_WORKSPACE/channel/$CONDA_SUBDIR"
127+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
128+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/$CONDA_SUBDIR" || exit 1
129+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
130+
# Test channel
131+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
132+
cat ver.json
133+
134+
- name: Collect dependencies
135+
shell: bash -el {0}
136+
run: |
137+
CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels)
138+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
139+
export PACKAGE_VERSION
140+
conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" "python=${{ matrix.python }}" "${CHANNELS[@]}" --only-deps --dry-run > lockfile
141+
cat lockfile
142+
143+
- name: Cache conda packages
144+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
145+
env:
146+
CACHE_NUMBER: 0 # Increase to reset cache
147+
with:
148+
path: /Users/runner/conda_pkgs_dir
149+
key:
150+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
151+
restore-keys: |
152+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
153+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
154+
155+
- name: Install mkl-service
156+
shell: bash -el {0}
157+
run: |
158+
CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels)
159+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
160+
export PACKAGE_VERSION
161+
conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" pytest "python=${{ matrix.python }}" "${CHANNELS[@]}"
162+
# Test installed packages
163+
conda list -n "${{ env.TEST_ENV_NAME }}"
164+
165+
- name: Run tests
166+
shell: bash -el {0}
167+
run: |
168+
conda activate ${{ env.TEST_ENV_NAME }}
169+
pytest -vv --pyargs ${{ env.MODULE_NAME }}

0 commit comments

Comments
 (0)