Skip to content

Commit f247abe

Browse files
committed
add osx workflow
1 parent cd985ac commit f247abe

1 file changed

Lines changed: 168 additions & 0 deletions

File tree

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
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)['platform'])")
65+
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV"
66+
67+
- name: Build conda package
68+
shell: bash -el {0}
69+
run: |
70+
CHANNELS=(-c conda-forge -c conda-forge/label/python_rc --override-channels)
71+
VERSIONS=(--python "${{ matrix.python }}")
72+
TEST=(--no-test)
73+
74+
conda build \
75+
"${TEST[@]}" \
76+
"${VERSIONS[@]}" \
77+
"${CHANNELS[@]}" \
78+
conda-recipe-cf
79+
80+
- name: Upload artifact
81+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
82+
with:
83+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
84+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda
85+
86+
- name: Upload wheels artifact
87+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
88+
with:
89+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
90+
path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl
91+
92+
test_osx:
93+
needs: build_osx
94+
runs-on: ${{ matrix.runner }}
95+
96+
strategy:
97+
matrix:
98+
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
99+
experimental: [false]
100+
runner: [macos-latest]
101+
continue-on-error: ${{ matrix.experimental }}
102+
env:
103+
CHANNELS: -c conda-forge -c conda-forge/label/python_rc --override-channels
104+
105+
steps:
106+
- name: Download artifact
107+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
108+
with:
109+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
110+
111+
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
112+
with:
113+
miniforge-version: latest
114+
channels: conda-forge
115+
activate-environment: base
116+
117+
- name: Install conda-index
118+
shell: bash -el {0}
119+
run: conda install -n base -y conda-index
120+
121+
- name: Create conda channel
122+
shell: bash -el {0}
123+
run: |
124+
CONDA_SUBDIR=$(conda info --json | python -c "import json,sys; print(json.load(sys.stdin)['platform'])")
125+
mkdir -p "$GITHUB_WORKSPACE/channel/$CONDA_SUBDIR"
126+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
127+
mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/$CONDA_SUBDIR" || exit 1
128+
conda index "$GITHUB_WORKSPACE/channel" || exit 1
129+
# Test channel
130+
conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
131+
cat ver.json
132+
133+
- name: Collect dependencies
134+
shell: bash -el {0}
135+
run: |
136+
CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels)
137+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
138+
export PACKAGE_VERSION
139+
conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" "python=${{ matrix.python }}" "${CHANNELS[@]}" --only-deps --dry-run > lockfile
140+
cat lockfile
141+
142+
- name: Cache conda packages
143+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
144+
env:
145+
CACHE_NUMBER: 0 # Increase to reset cache
146+
with:
147+
path: /Users/runner/conda_pkgs_dir
148+
key:
149+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
150+
restore-keys: |
151+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
152+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
153+
154+
- name: Install mkl-service
155+
shell: bash -el {0}
156+
run: |
157+
CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels)
158+
PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")"
159+
export PACKAGE_VERSION
160+
conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" pytest "python=${{ matrix.python }}" "${CHANNELS[@]}"
161+
# Test installed packages
162+
conda list -n "${{ env.TEST_ENV_NAME }}"
163+
164+
- name: Run tests
165+
shell: bash -el {0}
166+
run: |
167+
conda activate ${{ env.TEST_ENV_NAME }}
168+
pytest -vv --pyargs ${{ env.MODULE_NAME }}

0 commit comments

Comments
 (0)