-
-
Notifications
You must be signed in to change notification settings - Fork 14
298 lines (261 loc) · 9.89 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
name: "Build and unit tests"
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.type }}
cancel-in-progress: true
on:
pull_request:
paths:
- "**"
push:
branches: [main]
paths:
- "**.py"
tags:
- "v*.*.*"
workflow_dispatch:
env:
INSTALLDIR: "build-install"
CCACHE_DIR: "${{ github.workspace }}/.ccache"
jobs:
build_and_test:
name: Meson ${{ matrix.os }} - py${{ matrix.python-version }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
os:
- "macos-latest"
- "ubuntu-latest"
# Python 3.9 is on macos-13 but not macos-latest (macos-14-arm64)
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760
exclude:
- { python-version: "3.9", os: "macos-latest" }
- { python-version: "3.10", os: "macos-latest" }
include:
- { python-version: "3.9", os: "macos-13" }
- { python-version: "3.10", os: "macos-13" }
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
env:
# to make sure coverage/test command builds cleanly
FORCE_SUBMODULE: True
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Install packages for Ubuntu
if: ${{ matrix.os == 'ubuntu-latest'}}
run: |
sudo apt-get update
sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev gfortran libgmp-dev libmpfr-dev libsuitesparse-dev ccache libmpc-dev
sudo apt-get install -y gcc
- name: Install Ccache for MacOSX
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-latest'}}
run: |
brew install ccache
brew install gcc
brew install gettext
- name: show-gcc
run: |
gcc --version
- name: Install Python packages
run: |
pip install spin
spin setup-submodule
pip install compilers
pip install -r build_requirements.txt
pip install -r test_requirements.txt
- name: Prepare compiler cache
id: prep-ccache
shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: Setup compiler cache
uses: actions/cache@v4
id: cache-ccachev1
# Reference: https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
# NOTE: The caching strategy is modeled in a way that it will always have a unique cache key for each workflow run
# (even if the same workflow is run multiple times). The restore keys are not unique and for a partial match, they will
# return the most recently created cache entry, according to the GitHub Action Docs.
with:
path: ${{ steps.prep-ccache.outputs.dir }}
# Restores ccache from either a previous build on this branch or on main
key: ${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-${{ steps.prep-ccache.outputs.timestamp }}
# This evaluates to `Linux Tests-3.9-ccache-linux-` which is not unique. As the CI matrix is expanded, this will
# need to be updated to be unique so that the cache is not restored from a different job altogether.
restore-keys: |
${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-
- name: Setup build and install scikit-tree
run: |
./spin build -j 2 --forcesubmodule
./spin install
- name: Ccache performance
shell: bash -l {0}
run: ccache -s
- name: build-path
run: |
echo "$PWD/build-install/"
export INSTALLED_PATH=$PWD/build-install/usr/lib/python${{matrix.python-version}}/site-packages
- name: Run unit tests and coverage
run: |
pytest ./sktree
- name: debug
run: |
ls $PWD/build-install/usr/lib/python${{matrix.python-version}}/site-packages/
echo "Okay..."
ls $PWD/build
ls ./
- name: Save build
uses: actions/upload-artifact@v4
with:
name: sktree-build
path: $PWD/build
build_and_test_slow:
name: Slow Meson build ${{ matrix.os }} - py${{ matrix.python-version }}
timeout-minutes: 20
needs: [build_and_test]
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python-version: ["3.11"]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
env:
# to make sure coverage/test command builds cleanly
FORCE_SUBMODULE: True
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: show-gcc
run: |
gcc --version
- name: Install packages for Ubuntu
run: |
sudo apt-get update
sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev gfortran libgmp-dev libmpfr-dev libsuitesparse-dev ccache libmpc-dev
- name: Install Python packages
run: |
pip install spin
spin setup-submodule
pip install compilers
pip install -r build_requirements.txt
pip install -r test_requirements.txt
- name: Prepare compiler cache
id: prep-ccache
shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: Setup compiler cache
uses: actions/cache@v4
id: cache-ccachev1
# Reference: https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
# NOTE: The caching strategy is modeled in a way that it will always have a unique cache key for each workflow run
# (even if the same workflow is run multiple times). The restore keys are not unique and for a partial match, they will
# return the most recently created cache entry, according to the GitHub Action Docs.
with:
path: ${{ steps.prep-ccache.outputs.dir }}
# Restores ccache from either a previous build on this branch or on main
key: ${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-${{ steps.prep-ccache.outputs.timestamp }}
# This evaluates to `Linux Tests-3.9-ccache-linux-` which is not unique. As the CI matrix is expanded, this will
# need to be updated to be unique so that the cache is not restored from a different job altogether.
restore-keys: |
${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-
- name: Setup build and install scikit-tree
run: |
./spin build -j4 --forcesubmodule
./spin install
- name: Ccache performance
shell: bash -l {0}
run: ccache -s
- name: debug
run: |
ls $PWD/build-install/usr/lib/python${{matrix.python-version}}/site-packages/
echo "Okay..."
ls $PWD/build
ls ./
- name: Run unit tests and coverage
run: |
./spin --help
./spin coverage
ls .
# cp $PWD/build-install/usr/lib/python${{matrix.python-version}}/site-packages/coverage.xml ./coverage.xml
- name: Upload coverage stats to codecov
uses: codecov/codecov-action@v4
with:
# spin goes into the INSTALLED path in order to run pytest
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Save build
uses: actions/upload-artifact@v4
with:
name: sktree-build
path: $PWD/build
build-windows:
name: Meson build Windows
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
architecture: "x64"
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Install rtools (mingw-w64)
run: |
choco install rtools -y --no-progress --force --version=4.0.0.20220206
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
- name: show-gcc
run: |
gcc --version
- name: pip-packages
run: |
pip install spin
pip install -r build_requirements.txt
pip install -r test_requirements.txt
- name: Build
run: |
echo "SCIPY_USE_PROPACK=1" >> $env:GITHUB_ENV
echo "FORCE_SUBMODULE=True" >> $env:GITHUB_ENV
spin setup_submodule --forcesubmodule
spin build -j 2
spin install
# Necessary because GitHub Actions checks out the repo to D:\ while OpenBLAS
# got installed to C:\ higher up. The copying with `--win-cp-openblas` fails
# when things are split over drives.
# cp C:\opt\64\bin\*.dll $pwd\build-install\Lib\site-packages\scikit-tree\.libs\
# python tools\openblas_support.py --write-init $PWD\build-install\Lib\site-packages\scikit-tree\
- name: test
run: |
pytest ./sktree